Skip to content

Commit

Permalink
adapt useSearchHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
tconte-pass committed Jan 2, 2025
1 parent a463d90 commit e9c8edc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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'
Expand Down Expand Up @@ -129,7 +128,7 @@ export function getBooksNativeCategories(data: SubcategoriesResponseModelv2) {
*/
export function getNativeCategoryFromEnum(
data: SubcategoriesResponseModelv2 | undefined,
enumValue: NativeCategoryEnum | undefined
enumValue?: CategoryKey
) {
if (data && enumValue) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e9c8edc

Please sign in to comment.