Per request. /attendance is now a client view: a 'Here now' section with host badges + inline self check-in / check-in-as-host / check-out with a note; and a history with name search, a day picker, grouped-by- day headers, per-visit duration, status, notes, and a live visits/members summary for the current filter. New pure tested helpers dayKey (tz-stable UTC bucket) + visitDurationMinutes (+5 tests, suite 459).
24 lines
1.0 KiB
TypeScript
24 lines
1.0 KiB
TypeScript
import { redirect } from 'next/navigation'
|
|
import { createClient } from '@/lib/supabase/server'
|
|
import { listAttendance, listPresentNow } from '@/lib/actions'
|
|
import { AttendanceClient } from './attendance-client'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
export default async function AttendancePage() {
|
|
const supabase = await createClient()
|
|
const { data: { user } } = await supabase.auth.getUser()
|
|
if (!user) redirect('/login')
|
|
|
|
const [presentRes, historyRes] = await Promise.all([listPresentNow(), listAttendance()])
|
|
const present = ('data' in presentRes ? presentRes.data : []) as {
|
|
id: string; name: string; isHost: boolean; isMe: boolean; checkedInAt: string; note: string | null
|
|
}[]
|
|
const history = ('data' in historyRes ? historyRes.data : []) as {
|
|
id: string; name: string; isHost: boolean; status: 'present' | 'checked_out' | 'stale'
|
|
checkedInAt: string; checkedOutAt: string | null; checkInNote: string | null; checkOutNote: string | null
|
|
}[]
|
|
|
|
return <AttendanceClient present={present} history={history} />
|
|
}
|