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() !== '')) && (