Replace public legal files and switch booking to a contact request without a schedule.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { createInquiry } from "@/lib/api";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
function asText(value: unknown) {
|
||||
return typeof value === "string" ? value.trim() : "";
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const body = (await request.json()) as Record<string, unknown>;
|
||||
const name = asText(body.name ?? body.patientName);
|
||||
const email = asText(body.email);
|
||||
const phone = asText(body.phone);
|
||||
const branchId = asText(body.branchId);
|
||||
const serviceId = asText(body.serviceId) || undefined;
|
||||
const doctorId = asText(body.doctorId) || undefined;
|
||||
|
||||
if (!name || !email || !phone || !branchId || (!serviceId && !doctorId)) {
|
||||
return NextResponse.json({ error: "invalid" }, { status: 400 });
|
||||
}
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
return NextResponse.json({ error: "email" }, { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
const inquiry = await createInquiry({
|
||||
name,
|
||||
email,
|
||||
phone,
|
||||
branchId,
|
||||
serviceId,
|
||||
doctorId,
|
||||
});
|
||||
return NextResponse.json(inquiry);
|
||||
} catch {
|
||||
return NextResponse.json({ error: "unavailable" }, { status: 503 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user