Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor categories management #7468

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3630768
rewrite categoriesHelpers
tconte-pass Jan 2, 2025
a52a8c0
refactor categories modal
tconte-pass Jan 6, 2025
e594a12
remove usage of useAvailableCategories
tconte-pass Jan 6, 2025
4d8484d
update deeplink generator
tconte-pass Jan 2, 2025
69d2163
adapt AutocompleteOfferItem
tconte-pass Jan 2, 2025
9c3bd50
remove native categories from search state
tconte-pass Jan 2, 2025
f44ee7f
adapt useShowResultsForCategory
tconte-pass Jan 2, 2025
8066983
rename useSortedSearchCategories to useSearchLandingButtonsProps
tconte-pass Jan 2, 2025
32caa87
adapt CategoriesButtons
tconte-pass Jan 2, 2025
68066d4
adapt ThematicSearch
tconte-pass Jan 2, 2025
34394a9
adat SubcategoryButtonList
tconte-pass Jan 2, 2025
0f12cd5
clean search reducer
tconte-pass Jan 2, 2025
d93147c
clean getCategoriesFacetFilters
tconte-pass Jan 2, 2025
532a5ff
adapt useSearchHistory
tconte-pass Jan 2, 2025
8d7dd5b
refacto AutocompleteOfferItem
tconte-pass Jan 3, 2025
2363b43
remove `as unknown as AlgoliaSuggestionHit`
tconte-pass Jan 3, 2025
2202bfa
adapt import for CategoriesListDumb
tconte-pass Jan 5, 2025
8650eb3
implement roughly descriptions
tconte-pass Jan 6, 2025
39a1f40
fixup in categories modal
tconte-pass Jan 7, 2025
247a75e
enable showing blocks with children in modal
tconte-pass Jan 8, 2025
696366b
fix go back when at root level
tconte-pass Jan 8, 2025
d2d733a
remove typing errors in Category.tsx
tconte-pass Jan 7, 2025
12067fa
WIP - update search state from categories modal
tconte-pass Jan 8, 2025
2f49516
move mapping to separated file
tconte-pass Jan 9, 2025
992cd6b
WIP - build query parameters for Algolia
tconte-pass Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adapt useSearchHistory
tconte-pass committed Jan 8, 2025
commit 532a5ff072b5dab51098444bd47b8b3201874884
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import {
SubcategoryIdEnumv2,
} from 'api/gen'
import { ALL_CATEGORIES_LABEL } from 'features/search/constants'
import { NativeCategoryEnum } from 'features/search/types'
import { FACETS_FILTERS_ENUM } from 'libs/algolia/enums/facetsEnums'
import { PLACEHOLDER_DATA } from 'libs/subcategories/placeholderData'
import { useSubcategories } from 'libs/subcategories/useSubcategories'
@@ -136,7 +135,7 @@ export function getBooksNativeCategories(data: SubcategoriesResponseModelv2) {
*/
export function getNativeCategoryFromEnum(
data: SubcategoriesResponseModelv2 | undefined,
enumValue: NativeCategoryEnum | undefined
enumValue?: CategoryKey
) {
if (data && enumValue) {
return (
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ import AsyncStorage from '@react-native-async-storage/async-storage'
import { useCallback, useEffect, useMemo, useState } from 'react'

import { HISTORY_KEY, MAX_HISTORY_RESULTS, MIN_HISTORY_RESULTS } from 'features/search/constants'
import { getNativeCategoryFromEnum } from 'features/search/helpers/categoriesHelpers/categoriesHelpers'
import { getHistoryItemLabel } from 'features/search/helpers/getHistoryItemLabel/getHistoryItemLabel'
import { getHistoryLessThan30Days } from 'features/search/helpers/useSearchHistory/helpers/getHistoryLessThan30Days'
import { CreateHistoryItem, HistoryItem } from 'features/search/types'
@@ -12,6 +11,10 @@ import { LogTypeEnum } from 'libs/monitoring/errors'
import { useSearchGroupLabelMapping } from 'libs/subcategories/mappings'
import { useSubcategories } from 'libs/subcategories/useSubcategories'
import { SNACK_BAR_TIME_OUT, useSnackBarContext } from 'ui/components/snackBar/SnackBarContext'
import {
getCategory,
getNativeCategoryFromEnum,
} from 'features/search/helpers/categoriesHelpers/categoriesHelpers'

export function useSearchHistory() {
const { showErrorSnackBar } = useSnackBarContext()
@@ -87,7 +90,7 @@ export function useSearchHistory() {
currentHistory = await getHistoryFromStorage()
}

const categoryLabel = item.category ? searchGroupLabelMapping[item.category] : undefined
const categoryLabel = item.category ? getCategory(item.category)?.label : undefined
const nativeCategoryLabel =
getNativeCategoryFromEnum(subcategoriesData, item.nativeCategory)?.value ?? undefined