From e9c8edc33ee63dd6e25e02f8ee4d3ce0a4f4fe13 Mon Sep 17 00:00:00 2001 From: thconte <128476306+thconte@users.noreply.github.com> Date: Thu, 2 Jan 2025 17:26:23 +0100 Subject: [PATCH] adapt useSearchHistory --- .../search/helpers/categoriesHelpers/categoriesHelpers.ts | 3 +-- .../search/helpers/useSearchHistory/useSearchHistory.ts | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/features/search/helpers/categoriesHelpers/categoriesHelpers.ts b/src/features/search/helpers/categoriesHelpers/categoriesHelpers.ts index a5286442d44..85f7b452ae8 100644 --- a/src/features/search/helpers/categoriesHelpers/categoriesHelpers.ts +++ b/src/features/search/helpers/categoriesHelpers/categoriesHelpers.ts @@ -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' @@ -129,7 +128,7 @@ export function getBooksNativeCategories(data: SubcategoriesResponseModelv2) { */ export function getNativeCategoryFromEnum( data: SubcategoriesResponseModelv2 | undefined, - enumValue: NativeCategoryEnum | undefined + enumValue?: CategoryKey ) { if (data && enumValue) { return ( diff --git a/src/features/search/helpers/useSearchHistory/useSearchHistory.ts b/src/features/search/helpers/useSearchHistory/useSearchHistory.ts index f5a5a30c2b5..aa85752ba36 100644 --- a/src/features/search/helpers/useSearchHistory/useSearchHistory.ts +++ b/src/features/search/helpers/useSearchHistory/useSearchHistory.ts @@ -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