build fix
This commit is contained in:
parent
656b74f9d5
commit
70a921b0f5
@ -22,7 +22,7 @@ async function userExists(userId: string): Promise<boolean> {
|
||||
// GET - Retrieve a specific announcement
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const session = await getServerSession(authOptions);
|
||||
@ -31,7 +31,7 @@ export async function GET(
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { id } = params;
|
||||
const { id } = await params;
|
||||
|
||||
// Find announcement by ID
|
||||
const announcement = await prisma.announcement.findUnique({
|
||||
@ -76,7 +76,7 @@ export async function GET(
|
||||
// DELETE - Remove an announcement
|
||||
export async function DELETE(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const session = await getServerSession(authOptions);
|
||||
@ -107,7 +107,7 @@ export async function DELETE(
|
||||
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||
}
|
||||
|
||||
const { id } = params;
|
||||
const { id } = await params;
|
||||
|
||||
// Check if announcement exists
|
||||
const announcement = await prisma.announcement.findUnique({
|
||||
|
||||
@ -19,7 +19,7 @@ import { prisma } from "@/lib/prisma";
|
||||
*/
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
const session = await getServerSession(authOptions);
|
||||
|
||||
@ -28,9 +28,11 @@ export async function GET(
|
||||
}
|
||||
|
||||
try {
|
||||
const { id } = await params;
|
||||
|
||||
const calendar = await prisma.calendar.findUnique({
|
||||
where: {
|
||||
id: params.id,
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
|
||||
@ -69,7 +71,7 @@ export async function GET(
|
||||
*/
|
||||
export async function PUT(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
const session = await getServerSession(authOptions);
|
||||
|
||||
@ -78,10 +80,12 @@ export async function PUT(
|
||||
}
|
||||
|
||||
try {
|
||||
const { id } = await params;
|
||||
|
||||
// Vérifier que le calendrier existe et appartient à l'utilisateur
|
||||
const existingCalendar = await prisma.calendar.findUnique({
|
||||
where: {
|
||||
id: params.id,
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
|
||||
@ -108,7 +112,7 @@ export async function PUT(
|
||||
|
||||
const updatedCalendar = await prisma.calendar.update({
|
||||
where: {
|
||||
id: params.id,
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
name,
|
||||
@ -140,7 +144,7 @@ export async function PUT(
|
||||
*/
|
||||
export async function DELETE(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
const session = await getServerSession(authOptions);
|
||||
|
||||
@ -149,10 +153,12 @@ export async function DELETE(
|
||||
}
|
||||
|
||||
try {
|
||||
const { id } = await params;
|
||||
|
||||
// Verify calendar ownership
|
||||
const calendar = await prisma.calendar.findFirst({
|
||||
where: {
|
||||
id: params.id,
|
||||
id: 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)
|
||||
await prisma.calendar.delete({
|
||||
where: {
|
||||
id: params.id,
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user