1
0
mirror of https://github.com/Fayorg/calendrier-avant.git synced 2026-05-27 17:18:38 +02:00

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	app/results/page.tsx
#	components/custom/dayCard.tsx
This commit is contained in:
timhaller
2023-12-05 21:45:11 +01:00
2 changed files with 95 additions and 8 deletions

View File

@@ -1,18 +1,11 @@
import {NextResponse} from "next/server";
import prisma from '@lib/prisma';
import prisma from "@/lib/prisma";
interface IBody {
key: string
grade: number
}
export async function POST(req: Request){
const body = await req.json() as IBody
const grade = await prisma.grade.findFirst({ select: { id: true}, where: { oral: 1, key: { key: body.key } } });
if(grade) return NextResponse.json({message: 'Deja vote'}, {status: 403});
const gradeCreated = await prisma.grade.create({ data: { key: { connect: { key: body.key } }, grade: body.grade, oral: 1 } });
if(gradeCreated) return NextResponse.json({message: 'Vote enregistré'}, {status: 200});
return NextResponse.json({message: 'Server error'}, {status: 500})
}