From 98f0f8532ab4bf9a517117042a3e28e9c1f5e852 Mon Sep 17 00:00:00 2001 From: alma Date: Tue, 13 Jan 2026 23:10:33 +0100 Subject: [PATCH] Missions Corrections --- app/api/missions/mission-created/route.ts | 20 ++++++------- app/mission-tab/[missionId]/page.tsx | 13 +++++---- app/missions/[missionId]/page.tsx | 28 +++++++++++++++---- app/missions/equipe/page.tsx | 17 +++++------ components/missions/mission-members-panel.tsx | 17 +++++++---- 5 files changed, 61 insertions(+), 34 deletions(-) diff --git a/app/api/missions/mission-created/route.ts b/app/api/missions/mission-created/route.ts index d61f49f..c5403be 100644 --- a/app/api/missions/mission-created/route.ts +++ b/app/api/missions/mission-created/route.ts @@ -126,27 +126,27 @@ export async function POST(request: Request) { } = {}; // Mapper les champs N8N vers notre schéma Prisma + // Vérifier que les valeurs ne sont pas des chaînes vides if (body.gitRepoUrl !== undefined) { - updateData.giteaRepositoryUrl = body.gitRepoUrl || null; - logger.debug('Updating giteaRepositoryUrl', { hasUrl: !!body.gitRepoUrl }); + updateData.giteaRepositoryUrl = (body.gitRepoUrl && body.gitRepoUrl.trim() !== '') ? body.gitRepoUrl : null; + logger.debug('Updating giteaRepositoryUrl', { hasUrl: !!updateData.giteaRepositoryUrl, value: body.gitRepoUrl }); } if (body.leantimeProjectId !== undefined) { // N8N peut retourner un number, on le convertit en string - updateData.leantimeProjectId = body.leantimeProjectId - ? String(body.leantimeProjectId) - : null; - logger.debug('Updating leantimeProjectId', { hasId: !!updateData.leantimeProjectId }); + const projectId = body.leantimeProjectId ? String(body.leantimeProjectId).trim() : ''; + updateData.leantimeProjectId = projectId !== '' ? projectId : null; + logger.debug('Updating leantimeProjectId', { hasId: !!updateData.leantimeProjectId, value: body.leantimeProjectId }); } if (body.documentationCollectionId !== undefined) { - updateData.outlineCollectionId = body.documentationCollectionId || null; - logger.debug('Updating outlineCollectionId', { hasId: !!updateData.outlineCollectionId }); + updateData.outlineCollectionId = (body.documentationCollectionId && body.documentationCollectionId.trim() !== '') ? body.documentationCollectionId : null; + logger.debug('Updating outlineCollectionId', { hasId: !!updateData.outlineCollectionId, value: body.documentationCollectionId }); } if (body.rocketchatChannelId !== undefined) { - updateData.rocketChatChannelId = body.rocketchatChannelId || null; - logger.debug('Updating rocketChatChannelId', { hasId: !!updateData.rocketChatChannelId }); + updateData.rocketChatChannelId = (body.rocketchatChannelId && body.rocketchatChannelId.trim() !== '') ? body.rocketchatChannelId : null; + logger.debug('Updating rocketChatChannelId', { hasId: !!updateData.rocketChatChannelId, value: body.rocketchatChannelId }); } // Vérifier qu'il y a au moins un champ à mettre à jour diff --git a/app/mission-tab/[missionId]/page.tsx b/app/mission-tab/[missionId]/page.tsx index c9a1dc5..8e854b3 100644 --- a/app/mission-tab/[missionId]/page.tsx +++ b/app/mission-tab/[missionId]/page.tsx @@ -384,11 +384,14 @@ export default function MissionTabDetailPage() { )} {/* Ressources Métiers */} - {(mission.rocketChatChannelId || mission.outlineCollectionId || mission.giteaRepositoryUrl || mission.leantimeProjectId) && ( + {((mission.rocketChatChannelId && mission.rocketChatChannelId.trim() !== '') || + (mission.outlineCollectionId && mission.outlineCollectionId.trim() !== '') || + (mission.giteaRepositoryUrl && mission.giteaRepositoryUrl.trim() !== '') || + (mission.leantimeProjectId && mission.leantimeProjectId.toString().trim() !== '')) && (

Ressources Métiers

- {mission.rocketChatChannelId && (() => { + {mission.rocketChatChannelId && mission.rocketChatChannelId.trim() !== '' && (() => { // Build RocketChat URL: parole.slm-lab.net/channel/[channelId] // If it's already a full URL, use it; otherwise build from ID const rocketChatUrl = mission.rocketChatChannelId.startsWith('http') @@ -413,7 +416,7 @@ export default function MissionTabDetailPage() { ); })()} - {mission.outlineCollectionId && (() => { + {mission.outlineCollectionId && mission.outlineCollectionId.trim() !== '' && (() => { // Build Outline URL: chapitre.slm-lab.net/collection/[collectionId] // If it's already a full URL, use it; otherwise build from ID const outlineUrl = mission.outlineCollectionId.startsWith('http') @@ -438,7 +441,7 @@ export default function MissionTabDetailPage() { ); })()} - {mission.giteaRepositoryUrl && (() => { + {mission.giteaRepositoryUrl && mission.giteaRepositoryUrl.trim() !== '' && (() => { // Use mission name (sanitized) as repo name const repoName = sanitizeMissionName(mission.name); @@ -469,7 +472,7 @@ export default function MissionTabDetailPage() { ); })()} - {mission.leantimeProjectId && (() => { + {mission.leantimeProjectId && mission.leantimeProjectId.toString().trim() !== '' && (() => { // Build Leantime URL: agilite.slm-lab.net/projects/showProject/[projectId] // If it's already a full URL, use it; otherwise build from ID const leantimeUrl = mission.leantimeProjectId.startsWith('http') diff --git a/app/missions/[missionId]/page.tsx b/app/missions/[missionId]/page.tsx index 55fcd77..7286988 100644 --- a/app/missions/[missionId]/page.tsx +++ b/app/missions/[missionId]/page.tsx @@ -18,7 +18,8 @@ import { Loader2, FileText, Lock, - CheckCircle + CheckCircle, + ArrowLeft } from "lucide-react"; import { useToast } from "@/components/ui/use-toast"; import { useParams, useRouter } from "next/navigation"; @@ -396,6 +397,18 @@ export default function MissionDetailPage() { return (
+ {/* Back Button */} +
+ +
+ {/* Header with Name and Logo */}
@@ -591,11 +604,14 @@ export default function MissionDetailPage() { )} {/* Ressources Métiers */} - {(mission.rocketChatChannelId || mission.outlineCollectionId || mission.giteaRepositoryUrl || mission.leantimeProjectId) && ( + {((mission.rocketChatChannelId && mission.rocketChatChannelId.trim() !== '') || + (mission.outlineCollectionId && mission.outlineCollectionId.trim() !== '') || + (mission.giteaRepositoryUrl && mission.giteaRepositoryUrl.trim() !== '') || + (mission.leantimeProjectId && mission.leantimeProjectId.toString().trim() !== '')) && (

Ressources Métiers

- {mission.rocketChatChannelId && (() => { + {mission.rocketChatChannelId && mission.rocketChatChannelId.trim() !== '' && (() => { // Build RocketChat URL: parole.slm-lab.net/channel/[channelId] // If it's already a full URL, use it; otherwise build from ID const rocketChatUrl = mission.rocketChatChannelId.startsWith('http') @@ -620,7 +636,7 @@ export default function MissionDetailPage() { ); })()} - {mission.outlineCollectionId && (() => { + {mission.outlineCollectionId && mission.outlineCollectionId.trim() !== '' && (() => { // Build Outline URL: chapitre.slm-lab.net/collection/[collectionId] // If it's already a full URL, use it; otherwise build from ID const outlineUrl = mission.outlineCollectionId.startsWith('http') @@ -645,7 +661,7 @@ export default function MissionDetailPage() { ); })()} - {mission.giteaRepositoryUrl && (() => { + {mission.giteaRepositoryUrl && mission.giteaRepositoryUrl.trim() !== '' && (() => { // Use mission name (sanitized) as repo name const repoName = sanitizeMissionName(mission.name); @@ -676,7 +692,7 @@ export default function MissionDetailPage() { ); })()} - {mission.leantimeProjectId && (() => { + {mission.leantimeProjectId && mission.leantimeProjectId.toString().trim() !== '' && (() => { // Build Leantime URL: agilite.slm-lab.net/projects/showProject/[projectId] // If it's already a full URL, use it; otherwise build from ID const leantimeUrl = mission.leantimeProjectId.startsWith('http') diff --git a/app/missions/equipe/page.tsx b/app/missions/equipe/page.tsx index 127b3f1..a2df439 100644 --- a/app/missions/equipe/page.tsx +++ b/app/missions/equipe/page.tsx @@ -769,14 +769,15 @@ export default function EquipePage() { {user.email}
- {(user.roles || []).slice(0, 3).map(role => ( - - {role} - - ))} - {(user.roles || []).length > 3 && ( - - +{user.roles.length - 3} + {Array.isArray(user.roles) && user.roles.length > 0 ? ( + user.roles.map(role => ( + + {role} + + )) + ) : ( + + Aucun rôle )}
diff --git a/components/missions/mission-members-panel.tsx b/components/missions/mission-members-panel.tsx index c86a1f6..f97b28f 100644 --- a/components/missions/mission-members-panel.tsx +++ b/components/missions/mission-members-panel.tsx @@ -481,15 +481,21 @@ export function MissionMembersPanel({ {selectedTab === 'users' ? ( filteredUsers.length > 0 ? (
- {filteredUsers.map(user => ( + {filteredUsers.map(user => { + const displayName = (user.firstName && user.lastName) + ? `${user.firstName} ${user.lastName}` + : user.firstName || user.lastName || user.username || user.email || 'Utilisateur'; + const initials = (user.firstName?.[0] || "") + (user.lastName?.[0] || "") || user.username?.[0]?.toUpperCase() || user.email?.[0]?.toUpperCase() || "?"; + + return (
- {user.firstName?.[0] || ""}{user.lastName?.[0] || ""} + {initials}
-
{user.firstName} {user.lastName}
-
{user.email}
+
{displayName}
+
{user.email || user.username || ''}
{isUserAssigned(user.id) && (
{getUserRoles(user.id).map((role) => ( @@ -570,7 +576,8 @@ export function MissionMembersPanel({ )}
- ))} + ); + })}
) : (