diff --git a/src/components/okrs/OKRsList.tsx b/src/components/okrs/OKRsList.tsx
index 6a91579..5f4bca9 100644
--- a/src/components/okrs/OKRsList.tsx
+++ b/src/components/okrs/OKRsList.tsx
@@ -1,9 +1,10 @@
'use client';
-import { useState, useEffect } from 'react';
+import { useState, useEffect, useMemo } from 'react';
import { OKRCard } from './OKRCard';
-import { Card, ToggleGroup } from '@/components/ui';
+import { Card, ToggleGroup, Button } from '@/components/ui';
import { getGravatarUrl } from '@/lib/gravatar';
+import { getCurrentQuarterPeriod, isCurrentQuarterPeriod } from '@/lib/okr-utils';
import type { OKR } from '@/lib/types';
type ViewMode = 'grid' | 'grouped';
@@ -33,6 +34,7 @@ export function OKRsList({ okrsData, teamId, isAdmin = false }: OKRsListProps) {
}
return 'detailed';
});
+ const [showAllPeriods, setShowAllPeriods] = useState(false);
useEffect(() => {
if (typeof window !== 'undefined') {
@@ -40,8 +42,21 @@ export function OKRsList({ okrsData, teamId, isAdmin = false }: OKRsListProps) {
}
}, [cardViewMode]);
+ const currentQuarterPeriod = getCurrentQuarterPeriod();
+
+ // Filter OKRs based on period filter
+ const filteredOKRsData = useMemo(() => {
+ if (showAllPeriods) {
+ return okrsData;
+ }
+ return okrsData.map((tm) => ({
+ ...tm,
+ okrs: tm.okrs.filter((okr) => isCurrentQuarterPeriod(okr.period)),
+ }));
+ }, [okrsData, showAllPeriods]);
+
// Flatten OKRs for grid view
- const allOKRs = okrsData.flatMap((tm) =>
+ const allOKRs = filteredOKRsData.flatMap((tm) =>
tm.okrs.map((okr) => ({
...okr,
teamMember: {
@@ -52,11 +67,37 @@ export function OKRsList({ okrsData, teamId, isAdmin = false }: OKRsListProps) {
if (allOKRs.length === 0) {
return (
- Aucun OKR n'a encore été défini pour cette équipeAucun OKR défini
-
+ {showAllPeriods + ? "Aucun OKR n'a encore été défini pour cette équipe" + : `Aucun OKR n'a été défini pour le trimestre ${currentQuarterPeriod}. Cliquez sur "Afficher tous les OKR" pour voir les OKR d'autres périodes.`} +
+