From 90bb521511b9f6c57dec3d0f2fbd6d2713bb5ae8 Mon Sep 17 00:00:00 2001 From: franco sanchez Date: Thu, 8 Aug 2024 10:02:39 -0300 Subject: [PATCH] chore: renamed the fields returned by the options route --- src/components/Categories.tsx | 8 +- src/components/forms/filters/Filter.tsx | 12 +-- src/pages/Search.tsx | 132 ++++++++++++------------ 3 files changed, 78 insertions(+), 74 deletions(-) diff --git a/src/components/Categories.tsx b/src/components/Categories.tsx index e078d02..d984907 100644 --- a/src/components/Categories.tsx +++ b/src/components/Categories.tsx @@ -12,12 +12,12 @@ export default function Categories() { return ( <> {data && - data[0].categories[0].map(({ _id, count }) => ( + data[0].categories[0].map(({ category, count }) => ( @@ -25,7 +25,7 @@ export default function Categories() { bg='green.50' color='green.900' icon={BsTag} - name={_id} + name={category} size='lg' tabIndex={0} isFocused={true} diff --git a/src/components/forms/filters/Filter.tsx b/src/components/forms/filters/Filter.tsx index b976196..05ae720 100644 --- a/src/components/forms/filters/Filter.tsx +++ b/src/components/forms/filters/Filter.tsx @@ -26,22 +26,22 @@ export default function Filter({ onClose }: Props) { const categories = data && - data[0].categories[0].map(({ _id, count }) => ({ - value: _id, + data[0].categories[0].map(({ category, count }) => ({ + value: category, total: count, })); const years = data && - data[0].years[0].map(({ _id, count }) => ({ - value: _id, + data[0].years[0].map(({ year, count }) => ({ + value: year, total: count, })); const languages = data && - data[0].languages[0].map(({ _id, count }) => ({ - value: _id, + data[0].languages[0].map(({ language, count }) => ({ + value: language, total: count, })); diff --git a/src/pages/Search.tsx b/src/pages/Search.tsx index ff1ad09..f0aa785 100644 --- a/src/pages/Search.tsx +++ b/src/pages/Search.tsx @@ -48,6 +48,8 @@ export default function Search() { let buttonFilter; let fetchingNextPageUI; const isFiltering = !!selectedLanguage || !!selectedYear; // Verificar si los radios estan activos o no. + const hasMultipleLanguages = languages.length > 1; + const hasMultipleYears = years.length > 1; const { data: dataPaginated, @@ -119,73 +121,75 @@ export default function Search() { setSelectedYear(''); }, [location.pathname]); - asideFilter = ( - - - - Filtrar por: - - - - Idioma - - - Todos los Idiomas - {Array.isArray(languages) && - languages.map(({ language, count }: any) => ( - - {language} - - ({count}) - - - ))} - - - - - Año - - - Todos los Años - {Array.isArray(years) && - years.map(({ year, count }: any) => ( - - {year} - - ({count}) - - - ))} + + + Filtrar por: - - - ); + + + Idioma + + + Todos los Idiomas + {Array.isArray(languages) && + languages.map(({ language, count }: any) => ( + + {language} + + ({count}) + + + ))} + + + + + Año + + + Todos los Años + {Array.isArray(years) && + years.map(({ year, count }: any) => ( + + {year} + + ({count}) + + + ))} + + + + ); - buttonFilter = ( - - ); + buttonFilter = ( + + ); + } // Verifica si los 3 campos de aboutCategories esten con info o no const categoryCheck = aboutCategories.find((item) => {