2026-04-11 15:10:08 +02:00
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
|
import { prisma } from "../../../../../lib/prisma";
|
|
|
|
|
|
|
|
|
|
type Params = { params: Promise<{ id: string }> };
|
|
|
|
|
|
2026-04-11 15:20:29 +02:00
|
|
|
// PATCH /api/admin/daily/[id] - modifier un puzzle
|
2026-04-11 15:10:08 +02:00
|
|
|
export async function PATCH(req: Request, { params }: Params) {
|
|
|
|
|
const { id } = await params;
|
2026-04-11 15:20:29 +02:00
|
|
|
const { startArticle, targetArticle } = (await req.json()) as {
|
2026-04-11 15:10:08 +02:00
|
|
|
startArticle: string;
|
|
|
|
|
targetArticle: string;
|
|
|
|
|
};
|
|
|
|
|
const puzzle = await prisma.dailyPuzzle.update({
|
|
|
|
|
where: { id },
|
|
|
|
|
data: { startArticle, targetArticle },
|
|
|
|
|
});
|
|
|
|
|
return NextResponse.json(puzzle);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 15:20:29 +02:00
|
|
|
// DELETE /api/admin/daily/[id] - supprimer un puzzle
|
2026-04-11 15:10:08 +02:00
|
|
|
export async function DELETE(_req: Request, { params }: Params) {
|
|
|
|
|
const { id } = await params;
|
|
|
|
|
await prisma.dailyPuzzle.delete({ where: { id } });
|
|
|
|
|
return NextResponse.json({ ok: true });
|
|
|
|
|
}
|