missions finition
This commit is contained in:
parent
680abdbc54
commit
d743f4f980
@ -40,7 +40,7 @@ export async function GET(
|
||||
const { missionId } = await params;
|
||||
const userId = session.user.id;
|
||||
|
||||
// Find mission and check access
|
||||
// Find mission and check access - return all fields like the list endpoint
|
||||
const mission = await prisma.mission.findFirst({
|
||||
where: {
|
||||
id: missionId,
|
||||
@ -49,11 +49,7 @@ export async function GET(
|
||||
{ missionUsers: { some: { userId } } }
|
||||
]
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
creatorId: true,
|
||||
isClosed: true,
|
||||
include: {
|
||||
creator: {
|
||||
select: {
|
||||
id: true,
|
||||
@ -61,10 +57,7 @@ export async function GET(
|
||||
}
|
||||
},
|
||||
missionUsers: {
|
||||
select: {
|
||||
id: true,
|
||||
role: true,
|
||||
userId: true,
|
||||
include: {
|
||||
user: {
|
||||
select: {
|
||||
id: true,
|
||||
@ -72,6 +65,17 @@ export async function GET(
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
attachments: {
|
||||
select: {
|
||||
id: true,
|
||||
filename: true,
|
||||
filePath: true,
|
||||
fileType: true,
|
||||
fileSize: true,
|
||||
createdAt: true
|
||||
},
|
||||
orderBy: { createdAt: 'desc' }
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -80,7 +84,17 @@ export async function GET(
|
||||
return NextResponse.json({ error: 'Mission not found or access denied' }, { status: 404 });
|
||||
}
|
||||
|
||||
return NextResponse.json(mission);
|
||||
// Transform mission to include public URLs (same as list endpoint)
|
||||
const missionWithUrls = {
|
||||
...mission,
|
||||
logoUrl: mission.logo ? `/api/missions/image/${mission.logo}` : null,
|
||||
attachments: mission.attachments?.map(attachment => ({
|
||||
...attachment,
|
||||
publicUrl: `/api/missions/image/${attachment.filePath}`
|
||||
})) || []
|
||||
};
|
||||
|
||||
return NextResponse.json(missionWithUrls);
|
||||
} catch (error: any) {
|
||||
console.error('Error fetching mission:', error);
|
||||
return NextResponse.json(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user