42 lines
835 B
TypeScript
42 lines
835 B
TypeScript
|
|
import { PrismaClient } from "@/generated/prisma";
|
||
|
|
|
||
|
|
export async function GET(
|
||
|
|
request: Request,
|
||
|
|
{ params }: { params: Promise<{ id: number }> },
|
||
|
|
) {
|
||
|
|
const prisma = new PrismaClient();
|
||
|
|
const { id }: { id: number } = await params;
|
||
|
|
|
||
|
|
const cliente = await prisma.intervento.findMany({
|
||
|
|
where: {
|
||
|
|
id_registratore: Number(id),
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
return Response.json({ cliente });
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function POST(
|
||
|
|
request: Request,
|
||
|
|
{ params }: { params: Promise<{ id: number }> },
|
||
|
|
) {
|
||
|
|
const prisma = new PrismaClient();
|
||
|
|
const { id }: { id: number } = await params;
|
||
|
|
|
||
|
|
|
||
|
|
await prisma.intervento.create({
|
||
|
|
data: {
|
||
|
|
id_registratore: id,
|
||
|
|
data:
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
const cliente = await prisma.intervento.findMany({
|
||
|
|
where: {
|
||
|
|
id_registratore: Number(id),
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
return Response.json({ cliente });
|
||
|
|
}
|