Initial commit of Dance School App
This commit is contained in:
32
src/app/api/branches/[id]/route.ts
Normal file
32
src/app/api/branches/[id]/route.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { prisma } from '@/infrastructure/db/prisma';
|
||||
|
||||
export async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
await prisma.branch.delete({
|
||||
where: { id: params.id },
|
||||
});
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: 'Failed' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
try {
|
||||
const json = await request.json();
|
||||
const branch = await prisma.branch.update({
|
||||
where: { id: params.id },
|
||||
data: json,
|
||||
});
|
||||
return NextResponse.json(branch);
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: 'Failed' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user