- E1.S1: FullCalendar setup with React wrapper - E1.S2: Day view (timeGridDay) with hourly slots - E1.S3: Week view (timeGridWeek) with 7-day grid - E1.S4: Workweek view (timeGridWorkWeek, Mon-Fri) Features: - View switcher toolbar (Dag/Week/Werkweek) - Date navigation (prev/next/today) - Dutch localization (nl) - Business hours highlighting (08:00-18:00) - Color-coded appointments by type - Drag-and-drop rescheduling support - Server actions for encounter CRUD 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import { z } from 'zod'
|
|
import { createClient } from '@/lib/auth/server'
|
|
|
|
const payloadSchema = z.object({
|
|
action: z.enum(['start', 'stop', 'final']),
|
|
context: z.string().min(1),
|
|
patientId: z.string().min(1).optional(),
|
|
intakeId: z.string().min(1).optional(),
|
|
reportId: z.string().min(1).optional(),
|
|
metadata: z.record(z.string(), z.any()).optional(),
|
|
})
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const json = await request.json()
|
|
const payload = payloadSchema.safeParse(json)
|
|
|
|
if (!payload.success) {
|
|
return NextResponse.json({ error: 'Invalid payload' }, { status: 400 })
|
|
}
|
|
|
|
const supabase = await createClient()
|
|
const {
|
|
data: { user },
|
|
error: authError,
|
|
} = await supabase.auth.getUser()
|
|
|
|
if (authError) throw authError
|
|
if (!user) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
|
}
|
|
|
|
const { action, context, patientId, intakeId, reportId, metadata } = payload.data
|
|
|
|
// @ts-expect-error speech_usage_events table not in generated types yet
|
|
const { error } = await supabase.from('speech_usage_events').insert({
|
|
action,
|
|
context,
|
|
user_id: user.id,
|
|
patient_id: patientId ?? null,
|
|
intake_id: intakeId ?? null,
|
|
report_id: reportId ?? null,
|
|
metadata: metadata ?? {},
|
|
})
|
|
|
|
if (error) {
|
|
console.error('Failed to persist speech telemetry', error)
|
|
return NextResponse.json({ error: 'Database error' }, { status: 500 })
|
|
}
|
|
|
|
return NextResponse.json({ ok: true })
|
|
} catch (error) {
|
|
console.error('Speech telemetry error', error)
|
|
return NextResponse.json({ error: 'Server error' }, { status: 500 })
|
|
}
|
|
}
|