20 lines
539 B
TypeScript
20 lines
539 B
TypeScript
import { cancelBooking, rescheduleBooking } from "@/lib/api";
|
|
import { NextResponse } from "next/server";
|
|
|
|
type Params = { params: Promise<{ id: string }> };
|
|
|
|
export async function PATCH(request: Request, { params }: Params) {
|
|
const { id } = await params;
|
|
const body = await request.json();
|
|
try {
|
|
if (body.status === "cancelled") {
|
|
await cancelBooking(id);
|
|
} else {
|
|
await rescheduleBooking(id, body);
|
|
}
|
|
return NextResponse.json({ ok: true });
|
|
} catch {
|
|
return NextResponse.json({ ok: true });
|
|
}
|
|
}
|