From 4e26b958fe52fccaadd80e48f9bd3e54b552a8f7 Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 16 Jan 2026 15:03:06 +0100 Subject: [PATCH] Pages corrections pages missions --- .../[missionId]/files/folder/route.ts | 23 ++++++++++++++----- app/api/missions/[missionId]/files/route.ts | 23 ++++++++++++++----- .../[missionId]/files/upload/route.ts | 23 ++++++++++++++----- app/api/missions/[missionId]/route.ts | 1 + app/pages/page.tsx | 2 ++ components/carnet/mission-files-manager.tsx | 4 +++- 6 files changed, 57 insertions(+), 19 deletions(-) diff --git a/app/api/missions/[missionId]/files/folder/route.ts b/app/api/missions/[missionId]/files/folder/route.ts index 35eceee..867fa66 100644 --- a/app/api/missions/[missionId]/files/folder/route.ts +++ b/app/api/missions/[missionId]/files/folder/route.ts @@ -19,11 +19,13 @@ const missionsS3Client = new S3Client({ const MISSIONS_BUCKET = 'missions'; // Helper function to check if user can manage files (creator or gardien) -async function checkCanManage(userId: string, missionId: string): Promise { +// Also checks if mission is closed (closed missions cannot be modified) +async function checkCanManage(userId: string, missionId: string): Promise<{ canManage: boolean; isClosed: boolean }> { const mission = await prisma.mission.findFirst({ where: { id: missionId }, select: { creatorId: true, + isClosed: true, missionUsers: { where: { userId }, select: { role: true } @@ -31,14 +33,20 @@ async function checkCanManage(userId: string, missionId: string): Promise { +// Also checks if mission is closed (closed missions cannot be modified) +async function checkCanManage(userId: string, missionId: string): Promise<{ canManage: boolean; isClosed: boolean }> { const mission = await prisma.mission.findFirst({ where: { id: missionId }, select: { creatorId: true, + isClosed: true, missionUsers: { where: { userId }, select: { role: true } @@ -46,14 +48,20 @@ async function checkCanManage(userId: string, missionId: string): Promise { +// Also checks if mission is closed (closed missions cannot be modified) +async function checkCanManage(userId: string, missionId: string): Promise<{ canManage: boolean; isClosed: boolean }> { const mission = await prisma.mission.findFirst({ where: { id: missionId }, select: { creatorId: true, + isClosed: true, missionUsers: { where: { userId }, select: { role: true } @@ -17,14 +19,20 @@ async function checkCanManage(userId: string, missionId: string): Promise = ({ const isCreator = mission.creatorId === currentUserId; const userRole = mission.missionUsers?.find(mu => mu.userId === currentUserId)?.role; const isGardien = userRole === 'gardien-temps' || userRole === 'gardien-parole' || userRole === 'gardien-memoire'; - const canManage = isCreator || isGardien; + const isClosed = mission.isClosed || false; + const canManage = (isCreator || isGardien) && !isClosed; // Cannot manage if mission is closed const fetchFiles = async () => { try {