From fa167bac9b99d3bf49c7436aa87fe81145eebb25 Mon Sep 17 00:00:00 2001 From: alma Date: Tue, 6 May 2025 10:01:00 +0200 Subject: [PATCH] missions carrousse --- app/missions/page.tsx | 234 ++++++++++++++++++++++++++++++++---------- 1 file changed, 177 insertions(+), 57 deletions(-) diff --git a/app/missions/page.tsx b/app/missions/page.tsx index be50138d..90955e5a 100644 --- a/app/missions/page.tsx +++ b/app/missions/page.tsx @@ -27,6 +27,8 @@ interface Mission { niveau: string; missionType: string; projection: string; + participation?: string; + services?: string[]; createdAt: string; creator: User; missionUsers: MissionUser[]; @@ -82,11 +84,62 @@ export default function MissionsPage() { }); }; - // Function to get mission category - const getCategory = (mission: Mission) => { - return mission.oddScope && mission.oddScope.length > 0 - ? mission.oddScope[0].replace('odd-', 'ODD ') - : "Non catégorisé"; + // Function to get mission category and icon + const getODDInfo = (mission: Mission) => { + const oddCode = mission.oddScope && mission.oddScope.length > 0 + ? mission.oddScope[0] + : null; + + // Extract number from odd code (e.g., "odd-3" -> "3") + const oddNumber = oddCode ? oddCode.replace('odd-', '') : null; + + return { + number: oddNumber, + label: oddNumber ? `ODD ${oddNumber}` : "Non catégorisé", + iconPath: oddNumber ? `/images/odd/odd-${oddNumber}.png` : "/images/odd/default.png" + }; + }; + + // Function to get appropriate badge color based on niveau + const getNiveauBadgeColor = (niveau: string) => { + switch(niveau) { + case 'a': return 'bg-green-100 text-green-800'; + case 'b': return 'bg-blue-100 text-blue-800'; + case 'c': return 'bg-purple-100 text-purple-800'; + case 's': return 'bg-amber-100 text-amber-800'; + default: return 'bg-gray-100 text-gray-800'; + } + }; + + // Function to get full niveau label + const getNiveauLabel = (niveau: string) => { + switch(niveau) { + case 'a': return 'A- Apprentissage'; + case 'b': return 'B- Basique'; + case 'c': return 'C- Complexe'; + case 's': return 'S- Spécial'; + default: return niveau; + } + }; + + // Function to get mission type label + const getMissionTypeLabel = (type: string) => { + switch(type) { + case 'remote': return 'À distance'; + case 'onsite': return 'Sur site'; + case 'hybrid': return 'Hybride'; + default: return type; + } + }; + + // Function to get participation label + const getParticipationLabel = (participation: string | null | undefined) => { + if (!participation) return 'Non spécifié'; + switch(participation) { + case 'volontaire': return 'Volontaire'; + case 'cooptation': return 'Cooptation'; + default: return participation; + } }; // Function to get mission duration @@ -101,74 +154,141 @@ export default function MissionsPage() { return (
-
+
-

Gérez vos missions et opportunités de bénévolat

-
- - setSearchTerm(e.target.value)} - /> +

Gérez vos missions et opportunités de bénévolat

+
+
+ + setSearchTerm(e.target.value)} + /> +
+ + +
-
+
{loading ? (
-
+
) : filteredMissions.length > 0 ? ( -
- {filteredMissions.map((mission) => ( -
-
-
- - {getCategory(mission)} - - - {getDuration(mission.projection)} - -
- -
-

{mission.name}

-

Type: {mission.missionType}

+
+ {filteredMissions.map((mission) => { + const oddInfo = getODDInfo(mission); + const niveauColor = getNiveauBadgeColor(mission.niveau); + + return ( +
+
+ {/* Card Header with Logo and ODD */} +
+
+ {mission.logo ? ( + {mission.name} + ) : ( +
+ {mission.name.slice(0, 2).toUpperCase()} +
+ )} +
+
+
+ {oddInfo.number && ( +
+ {oddInfo.label} { + // Fallback if image fails to load + (e.target as HTMLImageElement).style.display = 'none'; + }} + /> + {oddInfo.label} +
+ )} + + {getNiveauLabel(mission.niveau)} + +
+

{mission.name}

+
+
-
- {mission.missionUsers.slice(0, 3).map(missionUser => ( - - {missionUser.role === 'gardien-temps' ? 'Gardien du Temps' : - missionUser.role === 'gardien-parole' ? 'Gardien de la Parole' : - missionUser.role === 'gardien-memoire' ? 'Gardien de la Mémoire' : 'Volontaire'} - - ))} + {/* Card Content */} +
+
+
+ Type: + {getMissionTypeLabel(mission.missionType)} +
+ +
+ Durée: + {getDuration(mission.projection)} +
+ +
+ Participation: + {getParticipationLabel(mission.participation)} +
+ + {mission.services && mission.services.length > 0 && ( +
+ Services: +
+ {mission.services.map(service => ( + + {service} + + ))} +
+
+ )} +
+
+ + {/* Card Footer */} +
+ + Créée le {formatDate(mission.createdAt)} + + + +
- -
- - Créée le {formatDate(mission.createdAt)} - - - - -
-
- ))} + ); + })}
) : ( -
-

Aucune mission trouvée

+
+
+ +
+

Aucune mission trouvée

+

+ Créez votre première mission pour commencer à organiser vos projets et inviter des participants. +

-