feat: add reminders tab with status tracking (coming/pending/cancelled)
Auto-surfaces bookings for today and tomorrow. Admin sets status per person: coming, no answer, or cancelled. Summary stats per day. DB migration 8 adds reminder_status column to all booking tables. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
36
src/app/api/admin/reminders/route.ts
Normal file
36
src/app/api/admin/reminders/route.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getUpcomingReminders, setReminderStatus } from "@/lib/db";
|
||||
import type { ReminderStatus } from "@/lib/db";
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json(getUpcomingReminders());
|
||||
}
|
||||
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { table, id, status } = body;
|
||||
|
||||
const validTables = ["mc_registrations", "group_bookings", "open_day_bookings"];
|
||||
const validStatuses = ["pending", "coming", "cancelled", null];
|
||||
|
||||
if (!validTables.includes(table)) {
|
||||
return NextResponse.json({ error: "Invalid table" }, { status: 400 });
|
||||
}
|
||||
if (!id || typeof id !== "number") {
|
||||
return NextResponse.json({ error: "id is required" }, { status: 400 });
|
||||
}
|
||||
if (!validStatuses.includes(status)) {
|
||||
return NextResponse.json({ error: "Invalid status" }, { status: 400 });
|
||||
}
|
||||
|
||||
setReminderStatus(
|
||||
table as "mc_registrations" | "group_bookings" | "open_day_bookings",
|
||||
id,
|
||||
status as ReminderStatus | null
|
||||
);
|
||||
return NextResponse.json({ ok: true });
|
||||
} catch {
|
||||
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user