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) => {