build fix

This commit is contained in:
alma 2025-05-05 12:53:28 +02:00
parent 656b74f9d5
commit 70a921b0f5
2 changed files with 18 additions and 12 deletions

View File

@ -22,7 +22,7 @@ async function userExists(userId: string): Promise<boolean> {
// GET - Retrieve a specific announcement // GET - Retrieve a specific announcement
export async function GET( export async function GET(
req: NextRequest, req: NextRequest,
{ params }: { params: { id: string } } { params }: { params: Promise<{ id: string }> }
) { ) {
try { try {
const session = await getServerSession(authOptions); const session = await getServerSession(authOptions);
@ -31,7 +31,7 @@ export async function GET(
return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
} }
const { id } = params; const { id } = await params;
// Find announcement by ID // Find announcement by ID
const announcement = await prisma.announcement.findUnique({ const announcement = await prisma.announcement.findUnique({
@ -76,7 +76,7 @@ export async function GET(
// DELETE - Remove an announcement // DELETE - Remove an announcement
export async function DELETE( export async function DELETE(
req: NextRequest, req: NextRequest,
{ params }: { params: { id: string } } { params }: { params: Promise<{ id: string }> }
) { ) {
try { try {
const session = await getServerSession(authOptions); const session = await getServerSession(authOptions);
@ -107,7 +107,7 @@ export async function DELETE(
return NextResponse.json({ error: "Forbidden" }, { status: 403 }); return NextResponse.json({ error: "Forbidden" }, { status: 403 });
} }
const { id } = params; const { id } = await params;
// Check if announcement exists // Check if announcement exists
const announcement = await prisma.announcement.findUnique({ const announcement = await prisma.announcement.findUnique({

View File

@ -19,7 +19,7 @@ import { prisma } from "@/lib/prisma";
*/ */
export async function GET( export async function GET(
req: NextRequest, req: NextRequest,
{ params }: { params: { id: string } } { params }: { params: Promise<{ id: string }> }
) { ) {
const session = await getServerSession(authOptions); const session = await getServerSession(authOptions);
@ -28,9 +28,11 @@ export async function GET(
} }
try { try {
const { id } = await params;
const calendar = await prisma.calendar.findUnique({ const calendar = await prisma.calendar.findUnique({
where: { where: {
id: params.id, id: id,
}, },
}); });
@ -69,7 +71,7 @@ export async function GET(
*/ */
export async function PUT( export async function PUT(
req: NextRequest, req: NextRequest,
{ params }: { params: { id: string } } { params }: { params: Promise<{ id: string }> }
) { ) {
const session = await getServerSession(authOptions); const session = await getServerSession(authOptions);
@ -78,10 +80,12 @@ export async function PUT(
} }
try { try {
const { id } = await params;
// Vérifier que le calendrier existe et appartient à l'utilisateur // Vérifier que le calendrier existe et appartient à l'utilisateur
const existingCalendar = await prisma.calendar.findUnique({ const existingCalendar = await prisma.calendar.findUnique({
where: { where: {
id: params.id, id: id,
}, },
}); });
@ -108,7 +112,7 @@ export async function PUT(
const updatedCalendar = await prisma.calendar.update({ const updatedCalendar = await prisma.calendar.update({
where: { where: {
id: params.id, id: id,
}, },
data: { data: {
name, name,
@ -140,7 +144,7 @@ export async function PUT(
*/ */
export async function DELETE( export async function DELETE(
req: NextRequest, req: NextRequest,
{ params }: { params: { id: string } } { params }: { params: Promise<{ id: string }> }
) { ) {
const session = await getServerSession(authOptions); const session = await getServerSession(authOptions);
@ -149,10 +153,12 @@ export async function DELETE(
} }
try { try {
const { id } = await params;
// Verify calendar ownership // Verify calendar ownership
const calendar = await prisma.calendar.findFirst({ const calendar = await prisma.calendar.findFirst({
where: { where: {
id: params.id, id: id,
userId: session.user.id, userId: session.user.id,
}, },
}); });
@ -167,7 +173,7 @@ export async function DELETE(
// Delete the calendar (this will also delete all associated events due to the cascade delete) // Delete the calendar (this will also delete all associated events due to the cascade delete)
await prisma.calendar.delete({ await prisma.calendar.delete({
where: { where: {
id: params.id, id: id,
}, },
}); });