diff --git a/__snapshots__/features/internal/marketingAndCommunication/pages/DeeplinksGenerator.native.test.tsx.native-snap b/__snapshots__/features/internal/marketingAndCommunication/pages/DeeplinksGenerator.native.test.tsx.native-snap index adbe793f1f3..05158994cff 100644 --- a/__snapshots__/features/internal/marketingAndCommunication/pages/DeeplinksGenerator.native.test.tsx.native-snap +++ b/__snapshots__/features/internal/marketingAndCommunication/pages/DeeplinksGenerator.native.test.tsx.native-snap @@ -1610,6 +1610,138 @@ exports[` should render DeeplinksGenerator 1`] = ` ] } /> + + + + + ThematicSearch + + + + + + + undefined-SVG-Mock + + + + + ({ @@ -10,33 +11,46 @@ jest.mock('libs/subcategories/useSubcategories', () => ({ data: mockData, }), })) +const user = userEvent.setup() describe('', () => { + jest.useFakeTimers() + afterEach(() => { mockData = PLACEHOLDER_DATA }) - it('should call onChange with proper category when toggling', () => { + it('should change selected category when toggling', async () => { const onChange = jest.fn() - render() + render() - fireEvent.press(screen.getByText('Arts & loisirs créatifs')) + await user.press(screen.getByText('Arts & loisirs créatifs')) expect(onChange).toHaveBeenNthCalledWith(1, ['ARTS_LOISIRS_CREATIFS']) - fireEvent.press(screen.getByText('Conférences & rencontres')) + await user.press(screen.getByText('Conférences & rencontres')) expect(onChange).toHaveBeenNthCalledWith(2, ['RENCONTRES_CONFERENCES']) + }) + + it('should deleselect category when toggling again a selected category', async () => { + const onChange = jest.fn() + render( + + ) - fireEvent.press(screen.getByText('Conférences & rencontres')) + await user.press(screen.getByText('Conférences & rencontres')) - expect(onChange).toHaveBeenNthCalledWith(3, []) + expect(onChange).toHaveBeenNthCalledWith(1, []) }) it('should not return labels when no categories sent by backend', () => { mockData = { ...mockData, searchGroups: [] } const onChange = jest.fn() - render() + render() expect(screen.queryByText('Arts & loisirs créatifs')).not.toBeOnTheScreen() expect(screen.queryByText('Conférences & rencontres')).not.toBeOnTheScreen() diff --git a/src/features/internal/marketingAndCommunication/atoms/OfferCategoryChoices.tsx b/src/features/internal/marketingAndCommunication/atoms/OfferCategoryChoices.tsx index 0b0dcdc9e45..7c3d829832e 100644 --- a/src/features/internal/marketingAndCommunication/atoms/OfferCategoryChoices.tsx +++ b/src/features/internal/marketingAndCommunication/atoms/OfferCategoryChoices.tsx @@ -1,40 +1,43 @@ -import React, { useCallback, useState } from 'react' +import React from 'react' import styled from 'styled-components/native' import { SearchGroupNameEnumv2 } from 'api/gen' import { SelectionLabel } from 'features/search/components/SelectionLabel/SelectionLabel' -import { useAvailableCategories } from 'features/search/helpers/useAvailableCategories/useAvailableCategories' +import { CategoryCriteria } from 'features/search/enums' +import { + useAvailableCategories, + useAvailableThematicSearchCategories, +} from 'features/search/helpers/useAvailableCategories/useAvailableCategories' import { useSearchGroupLabelMapping } from 'libs/subcategories/mappings' import { Li } from 'ui/components/Li' import { Ul } from 'ui/components/Ul' import { getSpacing } from 'ui/theme' -interface Props { +type CategoryChoicesProps = { onChange: (selection: SearchGroupNameEnumv2[]) => void + selection: SearchGroupNameEnumv2[] } -export const OfferCategoryChoices = (props: Props) => { - const [selection, setSelection] = useState([] as SearchGroupNameEnumv2[]) - const searchGroupLabelMapping = useSearchGroupLabelMapping() +type CategoryChoicesWithCategoryCriteria = CategoryChoicesProps & { + categories: ReadonlyArray +} + +export const OfferCategoryChoices = (props: CategoryChoicesProps) => { const categories = useAvailableCategories() + return +} - const { onChange } = props +export const ThematicSearchCategoryChoices = (props: CategoryChoicesProps) => { + const categories = useAvailableThematicSearchCategories() + return +} - const onPress = useCallback( - (facetFilter: SearchGroupNameEnumv2) => { - setSelection((prevSelection) => { - let nextSelection = [...prevSelection] - if (nextSelection.includes(facetFilter)) { - nextSelection = [] - } else { - nextSelection = [facetFilter] - } - onChange(nextSelection) - return nextSelection - }) - }, - [onChange] - ) +const CategoryChoices = ({ + onChange, + selection, + categories, +}: CategoryChoicesWithCategoryCriteria) => { + const searchGroupLabelMapping = useSearchGroupLabelMapping() if (categories.length === 0) { return null @@ -47,8 +50,10 @@ export const OfferCategoryChoices = (props: Props) => {
  • onPress(category.facetFilter)} + selected={!!selection?.includes(category.facetFilter)} + onPress={() => + onChange(selection?.includes(category.facetFilter) ? [] : [category.facetFilter]) + } />
  • ))} diff --git a/src/features/internal/marketingAndCommunication/atoms/OfferNativeCategoryChoices.native.test.tsx b/src/features/internal/marketingAndCommunication/atoms/OfferNativeCategoryChoices.native.test.tsx index 9ed27697345..93ed7741ed6 100644 --- a/src/features/internal/marketingAndCommunication/atoms/OfferNativeCategoryChoices.native.test.tsx +++ b/src/features/internal/marketingAndCommunication/atoms/OfferNativeCategoryChoices.native.test.tsx @@ -2,14 +2,17 @@ import React from 'react' import { SearchGroupNameEnumv2 } from 'api/gen' import { OfferNativeCategoryChoices } from 'features/internal/marketingAndCommunication/atoms/OfferNativeCategoryChoices' -import { fireEvent, render, screen } from 'tests/utils' +import { render, screen, userEvent } from 'tests/utils' jest.mock('libs/subcategories/useSubcategories') jest.mock('libs/firebase/analytics/analytics') +const user = userEvent.setup() describe('', () => { - it('should call onChange with proper subcategory when toggling', () => { + jest.useFakeTimers() + + it('should call onChange with proper subcategory when toggling', async () => { const onChange = jest.fn() render( ', () => { /> ) - fireEvent.press(screen.getByText('Arts visuels')) + await user.press(screen.getByText('Arts visuels')) expect(onChange).toHaveBeenNthCalledWith(1, ['ARTS_VISUELS']) - fireEvent.press(screen.getByText('Matériels créatifs')) + await user.press(screen.getByText('Matériels créatifs')) expect(onChange).toHaveBeenNthCalledWith(2, ['MATERIELS_CREATIFS']) - fireEvent.press(screen.getByText('Matériels créatifs')) + await user.press(screen.getByText('Matériels créatifs')) expect(onChange).toHaveBeenNthCalledWith(3, []) }) diff --git a/src/features/internal/marketingAndCommunication/components/DeeplinksGeneratorForm.native.test.tsx b/src/features/internal/marketingAndCommunication/components/DeeplinksGeneratorForm.native.test.tsx index 3554a76f3b0..9ed13f18d3d 100644 --- a/src/features/internal/marketingAndCommunication/components/DeeplinksGeneratorForm.native.test.tsx +++ b/src/features/internal/marketingAndCommunication/components/DeeplinksGeneratorForm.native.test.tsx @@ -7,7 +7,7 @@ import { } from 'features/internal/marketingAndCommunication/components/DeeplinksGeneratorForm' import { ScreensUsedByMarketing } from 'features/internal/marketingAndCommunication/config/deeplinksExportConfig' import { LocationMode } from 'libs/location/types' -import { fireEvent, render, screen } from 'tests/utils' +import { render, screen, userEvent, fireEvent } from 'tests/utils' jest.mock('libs/subcategories/useSubcategories') @@ -22,17 +22,21 @@ jest.mock('react-native/Libraries/Animated/createAnimatedComponent', () => { } }) +const user = userEvent.setup() + describe('', () => { - it('should render deeplink generator form with marketing as default utm_gen', () => { + jest.useFakeTimers() + + it('should render deeplink generator form with marketing as default utm_gen', async () => { const onCreate = jest.fn() render() const generateButton = screen.getByTestId('Générer le lien') const home = screen.getByText('Home') const profile = screen.getByText('Profile') - fireEvent.press(home) + await user.press(home) - fireEvent.press(generateButton) + await user.press(generateButton) expect(onCreate).toHaveBeenNthCalledWith(1, { firebaseLink: @@ -40,9 +44,9 @@ describe('', () => { universalLink: 'https://webapp-v2.example.com/accueil?from=deeplink&utm_gen=marketing', }) - fireEvent.press(profile) + await user.press(profile) - fireEvent.press(generateButton) + await user.press(generateButton) expect(onCreate).toHaveBeenNthCalledWith(2, { firebaseLink: @@ -51,7 +55,7 @@ describe('', () => { }) }) - it('should create url with utm params', () => { + it('should create url with utm params', async () => { const onCreate = jest.fn() render() @@ -59,7 +63,7 @@ describe('', () => { fireEvent.changeText(screen.getByPlaceholderText('utm_campaign'), 'campaign') fireEvent.changeText(screen.getByPlaceholderText('utm_source'), 'source') fireEvent.changeText(screen.getByPlaceholderText('utm_medium'), 'medium') - fireEvent.press(screen.getByText('Générer le lien')) + await user.press(screen.getByText('Générer le lien')) expect(onCreate).toHaveBeenNthCalledWith(1, { firebaseLink: @@ -69,15 +73,15 @@ describe('', () => { }) }) - it('should add showResults param when the user generate a search link', () => { + it('should add showResults param when the user generate a search link', async () => { const onCreate = jest.fn() render() const generateButton = screen.getByTestId('Générer le lien') const search = screen.getByText('SearchResults') - fireEvent.press(search) + await user.press(search) - fireEvent.press(generateButton) + await user.press(generateButton) expect(onCreate).toHaveBeenNthCalledWith(1, { firebaseLink: @@ -87,21 +91,21 @@ describe('', () => { }) }) - it('should remove subcategory param when the user change the category and generate a search link', () => { + it('should remove subcategory param when the user change the category and generate a search link', async () => { const onCreate = jest.fn() render() const search = screen.getByText('SearchResults') - fireEvent.press(search) + await user.press(search) let categoryButton = screen.getByText('Arts & loisirs créatifs') - fireEvent.press(categoryButton) + await user.press(categoryButton) const subcategoryButton = screen.getByText('Arts visuels') - fireEvent.press(subcategoryButton) + await user.press(subcategoryButton) let generateButton = screen.getByText('Générer le lien') - fireEvent.press(generateButton) + await user.press(generateButton) expect(onCreate).toHaveBeenNthCalledWith(1, { firebaseLink: @@ -111,10 +115,10 @@ describe('', () => { }) categoryButton = screen.getByText('Concerts & festivals') - fireEvent.press(categoryButton) + await user.press(categoryButton) generateButton = screen.getByText('Générer le lien') - fireEvent.press(generateButton) + await user.press(generateButton) expect(onCreate).toHaveBeenNthCalledWith(2, { firebaseLink: @@ -123,6 +127,38 @@ describe('', () => { 'https://webapp-v2.example.com/recherche/resultats?locationFilter=%5Bobject%20Object%5D&from=deeplink&offerCategories=CONCERTS_FESTIVALS&utm_gen=marketing', }) }) + + it("should have disabled button when a category isn't selected in ThematicSearch", async () => { + const onCreate = jest.fn() + render() + + const thematicSearch = screen.getByText('ThematicSearch') + await user.press(thematicSearch) + const generateButton = screen.getByText('Générer le lien') + + expect(generateButton).toBeDisabled() + }) + + it('should generate link when a category is selected in ThematicSearch', async () => { + const onCreate = jest.fn() + render() + + const thematicSearch = screen.getByText('ThematicSearch') + await user.press(thematicSearch) + + const categoryButton = screen.getByText('Cinéma') + await user.press(categoryButton) + + const generateButton = screen.getByText('Générer le lien') + await user.press(generateButton) + + expect(onCreate).toHaveBeenNthCalledWith(1, { + firebaseLink: + 'https://passcultureapptesting.page.link/?link=https%3A%2F%2Fwebapp-v2.example.com%2FThematicSearch%3Ffrom%3Ddeeplink%26offerCategories%3DCINEMA%26utm_gen%3Dmarketing&apn=app.android&isi=1557887412&ibi=app.ios&efr=1', + universalLink: + 'https://webapp-v2.example.com/ThematicSearch?from=deeplink&offerCategories=CINEMA&utm_gen=marketing', + }) + }) }) jest.mock('libs/firebase/analytics/analytics') @@ -137,7 +173,7 @@ describe('getDefaultScreenParams', () => { }) }) - it.each(['Offer', 'Venue', 'Home', 'Profile', 'SignupForm', 'ThematicHome'])( + it.each(['Offer', 'Venue', 'Home', 'Profile', 'SignupForm', 'ThematicHome', 'ThematicSearch'])( 'should return an object with from param set to "deeplink" when screen is %s', (screen) => { const defaultParams = getDefaultScreenParams(screen as ScreensUsedByMarketing) diff --git a/src/features/internal/marketingAndCommunication/components/DeeplinksGeneratorForm.tsx b/src/features/internal/marketingAndCommunication/components/DeeplinksGeneratorForm.tsx index c3b644b5fd3..499152cf244 100644 --- a/src/features/internal/marketingAndCommunication/components/DeeplinksGeneratorForm.tsx +++ b/src/features/internal/marketingAndCommunication/components/DeeplinksGeneratorForm.tsx @@ -7,7 +7,10 @@ import { generateLongFirebaseDynamicLink } from 'features/deeplinks/helpers' import { ControlledFilterSwitch } from 'features/internal/marketingAndCommunication/atoms/ControlledFilterSwitch' import { DateChoice } from 'features/internal/marketingAndCommunication/atoms/DateChoice' import { LocationFilterChoice } from 'features/internal/marketingAndCommunication/atoms/LocationFilterChoice' -import { OfferCategoryChoices } from 'features/internal/marketingAndCommunication/atoms/OfferCategoryChoices' +import { + OfferCategoryChoices, + ThematicSearchCategoryChoices, +} from 'features/internal/marketingAndCommunication/atoms/OfferCategoryChoices' import { OfferNativeCategoryChoices } from 'features/internal/marketingAndCommunication/atoms/OfferNativeCategoryChoices' import { FDL_CONFIG, @@ -235,7 +238,10 @@ export const DeeplinksGeneratorForm = ({ onCreate }: Props) => { ) : null} {config.type === 'offerCategories' ? ( - + ) : null} {config.type === 'offerNativeCategories' && screenParams.offerCategories ? ( { onChange={onChangeOfferNativeCategories} /> ) : null} + {config.type === 'thematicSearchCategories' ? ( + + ) : null} {config.type === 'date' ? ( diff --git a/src/features/internal/marketingAndCommunication/config/deeplinksExportConfig.ts b/src/features/internal/marketingAndCommunication/config/deeplinksExportConfig.ts index a72cb332211..256b99f8c56 100644 --- a/src/features/internal/marketingAndCommunication/config/deeplinksExportConfig.ts +++ b/src/features/internal/marketingAndCommunication/config/deeplinksExportConfig.ts @@ -13,6 +13,7 @@ export type ScreensUsedByMarketing = Extract< | 'SignupForm' | 'ThematicHome' | 'Stepper' + | 'ThematicSearch' > type ScreensUsedByMarketingParamsList = Pick @@ -27,6 +28,7 @@ export type ParamConfig = { | 'offerNativeCategories' | 'date' | 'locationFilter' + | 'thematicSearchCategories' required?: boolean description: string serverValidator?: (value: unknown) => Promise @@ -132,6 +134,13 @@ export const SCREENS_CONFIG: { Profile: {}, SignupForm: {}, Stepper: {}, + ThematicSearch: { + offerCategories: { + type: 'thematicSearchCategories', + required: true, + description: 'Categories', + }, + }, } type MarketingParams = 'utm_campaign' | 'utm_source' | 'utm_medium' | 'utm_content' | 'utm_gen' diff --git a/src/features/navigation/RootNavigator/types.ts b/src/features/navigation/RootNavigator/types.ts index df6267f9eb2..21dbab21a29 100644 --- a/src/features/navigation/RootNavigator/types.ts +++ b/src/features/navigation/RootNavigator/types.ts @@ -190,58 +190,62 @@ export type SubscriptionRootStackParamList = { * please update the deeplink handler in consequence. */ export type RootStackParamList = { - SignupForm: - | { accountCreationToken?: string; email?: string; offerId?: number; from: StepperOrigin } - | undefined - Maintenance: undefined ABTestingPOC: undefined AccountCreated: undefined AccountReactivationSuccess: undefined + AccountStatusScreenHandler: undefined AfterSignupEmailValidationBuffer: { token: string; expiration_timestamp: number; email: string } AppComponents: undefined + Artist: { + fromOfferId: number + } BannedCountryError: undefined + BookingConfirmation: { offerId: number; bookingId: number; apiRecoParams?: string } + BookingDetails: { id: number } + Bookings: { activeTab?: BookingsTab } | undefined ChangeCity: undefined - ChangePassword: undefined ChangeEmail: { showModal: boolean } | undefined + ChangeEmailExpiredLink: undefined ChangeEmailSetPassword: { token: string; emailSelectionToken: string } + ChangePassword: undefined ChangeStatus: undefined - FeedbackInApp: undefined - TrackEmailChange: undefined - NewEmailSelection: { token: string } - ChangeEmailExpiredLink: undefined CheatCodes: undefined CheatMenu: undefined ConfirmChangeEmail: { token: string; expiration_timestamp: number } - DeleteProfileReason: undefined - DeleteProfileContactSupport: undefined - DeleteProfileEmailHacked: undefined - DeleteProfileAccountHacked: undefined - DeleteProfileAccountNotDeletable: undefined ConfirmDeleteProfile: undefined - SuspendAccountConfirmationWithoutAuthentication: undefined - BookingConfirmation: { offerId: number; bookingId: number; apiRecoParams?: string } - BookingDetails: { id: number } ConsentSettings: { onGoBack?: () => void } | undefined CulturalSurvey: undefined + DeactivateProfileSuccess: undefined + DeeplinksGenerator: undefined + DeleteProfileAccountHacked: undefined + DeleteProfileAccountNotDeletable: undefined DeleteProfileConfirmation: undefined + DeleteProfileContactSupport: undefined + DeleteProfileEmailHacked: undefined + DeleteProfileReason: undefined DeleteProfileSuccess: undefined - DeactivateProfileSuccess: undefined - Bookings: { activeTab?: BookingsTab } | undefined + EighteenBirthday: undefined EndedBookings: undefined FavoritesSorts: undefined + FeedbackInApp: undefined ForgottenPassword: undefined FraudulentSuspendedAccount: undefined + LegalNotices: undefined + LocationFilter?: { selectedVenue?: Venue; selectedPlace?: SuggestedPlace } + LocationPicker: undefined Login?: { displayForcedLoginHelpMessage?: boolean offerId?: number from?: StepperOrigin } + Maintenance: undefined Navigation: undefined NavigationAccountSuspension: undefined NavigationNotScreensPages: undefined NavigationProfile: undefined NavigationAchievements: undefined NavigationSubscription: undefined + NewEmailSelection: { token: string } NotificationsSettings: undefined Offer: { id: number @@ -258,8 +262,10 @@ export type RootStackParamList = { OfferDescription: { id: number } OfferPreview: { id: number; defaultIndex?: number } OnboardingSubscription: undefined - SuspendAccountConfirmation: { token: string } - AccountStatusScreenHandler: undefined + NotYetUnderageEligibility: { eligibilityStartDatetime: string } + PageNotFound: undefined + PersonalData: undefined + RecreditBirthdayNotification: undefined ReinitializePassword: { email: string token: string @@ -268,39 +274,33 @@ export type RootStackParamList = { } ResetPasswordEmailSent: { email: string } ResetPasswordExpiredLink: { email: string } - LegalNotices: undefined - LocationFilter?: { selectedVenue?: Venue; selectedPlace?: SuggestedPlace } - LocationPicker: undefined - PersonalData: undefined SearchFilter: Partial }> SignupConfirmationEmailSent: { email: string } SignupConfirmationExpiredLink: { email: string } + SignupForm: + | { accountCreationToken?: string; email?: string; offerId?: number; from: StepperOrigin } + | undefined + SuspendAccountConfirmation: { token: string } + SuspendAccountConfirmationWithoutAuthentication: undefined SuspendedAccountUponUserRequest: undefined TabNavigator: { screen: TabRouteName params: TabParamList[TabRouteName] } - VerifyEligibility: undefined - NotYetUnderageEligibility: { eligibilityStartDatetime: string } + ThematicHome: ThematicHomeParams + TrackEmailChange: undefined Tutorial?: { selectedAge?: 15 | 16 | 17 | 18 } - EighteenBirthday: undefined - RecreditBirthdayNotification: undefined - PageNotFound: undefined + UTMParameters: undefined ValidateEmailChange: { token: string } Venue: { id: number from?: Referrals searchId?: string } - VenuePreviewCarousel: { id: number; defaultIndex?: number } - Artist: { - fromOfferId: number - } VenueMap: undefined VenueMapFiltersStackNavigator: undefined - DeeplinksGenerator: undefined - UTMParameters: undefined - ThematicHome: ThematicHomeParams + VenuePreviewCarousel: { id: number; defaultIndex?: number } + VerifyEligibility: undefined // cheatcodes AccesLibre: undefined NewCaledonia: undefined diff --git a/src/features/navigation/SearchStackNavigator/types.ts b/src/features/navigation/SearchStackNavigator/types.ts index 668921c5a31..4df04854351 100644 --- a/src/features/navigation/SearchStackNavigator/types.ts +++ b/src/features/navigation/SearchStackNavigator/types.ts @@ -1,13 +1,30 @@ +import { SearchGroupNameEnumv2 } from 'api/gen' import { DisabilitiesProperties } from 'features/accessibility/types' import { GenericRoute } from 'features/navigation/RootNavigator/types' import { SearchState } from 'features/search/types' export type SearchStackRouteName = keyof SearchStackParamList +export const hasAThematicSearch = [ + SearchGroupNameEnumv2.CINEMA, + SearchGroupNameEnumv2.LIVRES, + SearchGroupNameEnumv2.MUSIQUE, + SearchGroupNameEnumv2.FILMS_DOCUMENTAIRES_SERIES, +] as const + +type HasAThematicSearch = typeof hasAThematicSearch + +type ThematicSearchCategories = Extract + export type SearchStackParamList = { SearchLanding?: Partial }> SearchResults?: Partial }> - ThematicSearch?: Partial }> + ThematicSearch?: Partial< + SearchState & { + offerCategories: ThematicSearchCategories[] + accessibilityFilter: Partial + } + > } export type SearchStackScreenNames = keyof SearchStackParamList diff --git a/src/features/search/enums.ts b/src/features/search/enums.ts index b8470766645..267c7f5b969 100644 --- a/src/features/search/enums.ts +++ b/src/features/search/enums.ts @@ -53,22 +53,37 @@ export const SearchCategoriesIllustrations = { export type Gradient = Array -type CategoryCriteria = { - [category in SearchGroupNameEnumv2]: { - icon: React.FC - illustration: category extends SearchGroupNameEnumv2.NONE ? undefined : React.FC - facetFilter: SearchGroupNameEnumv2 - baseColor: category extends SearchGroupNameEnumv2.NONE ? undefined : ColorsEnum - gradients: category extends SearchGroupNameEnumv2.NONE ? undefined : Gradient - position: category extends SearchGroupNameEnumv2.NONE ? undefined : number - // v2 App Design - fillColor: category extends SearchGroupNameEnumv2.NONE ? undefined : ColorsEnum - borderColor: category extends SearchGroupNameEnumv2.NONE ? undefined : ColorsEnum - textColor: category extends SearchGroupNameEnumv2.NONE ? undefined : ColorsEnum - } +export type CategoryCriteria = { + icon: React.FC + illustration: React.FC + facetFilter: SearchGroupNameEnumv2 + baseColor: ColorsEnum + gradients: Gradient + position: number + // v2 App Design + fillColor: ColorsEnum + borderColor: ColorsEnum + textColor: ColorsEnum } -export const CATEGORY_CRITERIA: CategoryCriteria = { +type CategoryCriteriaWithNone = { + [category in SearchGroupNameEnumv2]: category extends SearchGroupNameEnumv2.NONE + ? { + icon: React.FC + illustration: undefined + facetFilter: SearchGroupNameEnumv2 + baseColor: undefined + gradients: undefined + position: undefined + // v2 App Design + fillColor: undefined + borderColor: undefined + textColor: undefined + } + : CategoryCriteria +} + +export const CATEGORY_CRITERIA: CategoryCriteriaWithNone = { [SearchGroupNameEnumv2.NONE]: { icon: categoriesIcons.All, illustration: undefined, diff --git a/src/features/search/helpers/useAvailableCategories/useAvailableCategories.tsx b/src/features/search/helpers/useAvailableCategories/useAvailableCategories.tsx index 84e692a3c65..25d99f3dd97 100644 --- a/src/features/search/helpers/useAvailableCategories/useAvailableCategories.tsx +++ b/src/features/search/helpers/useAvailableCategories/useAvailableCategories.tsx @@ -1,7 +1,9 @@ +import { hasAThematicSearch } from 'features/navigation/SearchStackNavigator/types' +import { CategoryCriteria } from 'features/search/enums' import { availableCategories } from 'features/search/helpers/availableCategories/availableCategories' import { useSubcategories } from 'libs/subcategories/useSubcategories' -export const useAvailableCategories = () => { +export const useAvailableCategories = (): CategoryCriteria[] => { const { data } = useSubcategories() const searchGroupsEnum = data?.searchGroups.map((searchGroup) => searchGroup.name) ?? [] const categories = Object.values(availableCategories).filter((category) => @@ -10,3 +12,9 @@ export const useAvailableCategories = () => { return categories } + +export const useAvailableThematicSearchCategories = (): CategoryCriteria[] => { + return Object.values(availableCategories).filter((category) => + hasAThematicSearch.find((thematicSearch) => thematicSearch === category.facetFilter) + ) +}