Files
dance_school/src/app/api/branches/[id]/route.ts
2026-01-08 00:51:13 +03:00

33 lines
869 B
TypeScript

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 });
}
}