diff --git a/app/[locale]/projects/page.tsx b/app/[locale]/projects/page.tsx
index 0831030..e2e3412 100644
--- a/app/[locale]/projects/page.tsx
+++ b/app/[locale]/projects/page.tsx
@@ -43,12 +43,23 @@ const ProjectsPage = () => {
setLoading(true);
const existingTags = structuredClone(tags);
- // we set tag active to true
- for (const exisitingTag of existingTags) {
+ // we set tags chosen to active and all the others to not
+ if (existingTags.every(value => value.isActive)) {
+ existingTags.forEach(existingTag => {
+ existingTag.isActive = false;
+ });
+ }
+
+ existingTags.forEach(exisitingTag => {
if (exisitingTag.name === tag.name) {
exisitingTag.isActive = !exisitingTag.isActive;
- break;
}
+ });
+
+ if (existingTags.every(value => !value.isActive)) {
+ existingTags.forEach(existingTag => {
+ existingTag.isActive = true;
+ });
}
setTags(existingTags);
diff --git a/components/Projects/FiltersBar/FilterBtnsGroup.tsx b/components/Projects/FiltersBar/FilterBtnsGroup.tsx
index 8c5804e..4de1d13 100644
--- a/components/Projects/FiltersBar/FilterBtnsGroup.tsx
+++ b/components/Projects/FiltersBar/FilterBtnsGroup.tsx
@@ -12,9 +12,9 @@ const FilterBtnsGroup = ({
filters,
handleFilterOptionChange,
}: FilterBtnsGroupProps) => {
- const handleBtnFilterClick = (filter: ProjectFilter) => {
- handleFilterOptionChange(filter);
- };
+ // const handleBtnFilterClick = (filter: ProjectFilter) => {
+ // handleFilterOptionChange(filter);
+ // };
return (
@@ -22,7 +22,7 @@ const FilterBtnsGroup = ({
handleBtnFilterClick(filter)}
+ onBtnClick={() => handleFilterOptionChange(filter)}
/>
))}
diff --git a/components/Projects/FiltersBar/FiltersBar.tsx b/components/Projects/FiltersBar/FiltersBar.tsx
index a5a02ce..30068b1 100644
--- a/components/Projects/FiltersBar/FiltersBar.tsx
+++ b/components/Projects/FiltersBar/FiltersBar.tsx
@@ -11,6 +11,7 @@ import Link from 'next/link';
import { ProjectPaginationFilter } from '@/types/project';
import { useTranslations } from 'next-intl';
import { SearchInput } from '@/components/Common/Inputs/SearchInput';
+import FiltersWindow from './FiltersWindow';
import SkeletonCards from './Skeleton/SkeletonCards';
interface FiltersBarProps {
@@ -112,59 +113,16 @@ const FiltersBar: React.FC = ({
height={27}
/>
{/* settings window on burger click */}
- {toggleFiltersWindow ? (
- <>
-
-
-
- {t('projectsFilters')}{' '}
-
- {/* sort by ProjectPaginationFilter (sortoptions,sortoptionsmapper) */}
-
-
- {t('filters')}
-
-
- {sortOptions.map(sortOption => (
-
- ))}
-
-
- {/* sort by set languages */}
-
-
- {t('tags')}
-
-
- {filters.map(filter => (
-
- handleFilterOptionChange(filter)
- }
- isSelected={filter.isActive}
- />
- ))}
-
-
-
-
-
-
- >
- ) : null}
+ {toggleFiltersWindow && (
+
+ )}
;
+ sortOptions: string[];
+ selectedSortOption: any;
+ handleCategoryOptionSelection: any;
+ filters: ProjectFilter[];
+ handleFilterOptionChange: any;
+}
+
+const FiltersWindow = ({
+ filterRef,
+ sortOptions,
+ selectedSortOption,
+ handleCategoryOptionSelection,
+ filters,
+ handleFilterOptionChange,
+}: FiltersWindow) => {
+ const t = useTranslations('Projects.FiltersBar');
+
+ return (
+
+
+
+
+ {t('projectsFilters')}{' '}
+
+ {/* sort by ProjectPaginationFilter (sortoptions,sortoptionsmapper) */}
+
+
+ {t('filters')}
+
+
+ {sortOptions.map(sortOption => (
+
+ ))}
+
+
+ {/* sort by set languages */}
+
+
+ {t('tags')}
+
+
+ {filters.map(filter => (
+ handleFilterOptionChange(filter)}
+ isSelected={filter.isActive}
+ />
+ ))}
+
+
+
+
+
+
+
+ );
+};
+
+export default FiltersWindow;