40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
export const dynamic = 'force-dynamic'
|
|
|
|
import Link from 'next/link'
|
|
import { redirect } from 'next/navigation'
|
|
import { getSession } from '@/lib/auth/get-session'
|
|
import { buttonClass } from '@/components/ui/button'
|
|
import { IncidentTable } from '@/components/incidents/incident-table'
|
|
import { loadIncidentList } from '@/lib/incidents/list-query'
|
|
import { parseListParams } from '@/lib/incidents/list-params'
|
|
|
|
export default async function SupervisorInboxPage({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<Record<string, string | undefined>>
|
|
}) {
|
|
const session = await getSession()
|
|
if (!session) redirect('/login')
|
|
|
|
const params = parseListParams(await searchParams)
|
|
const data = await loadIncidentList(params)
|
|
|
|
return (
|
|
<div className="px-4 py-5 md:px-8 md:py-6 space-y-4">
|
|
<div className="flex items-center justify-between">
|
|
<h1 className="text-[22px] md:text-xl font-[650]">Incidents</h1>
|
|
<Link href="/report" className={buttonClass('primary')}>Report incident</Link>
|
|
</div>
|
|
<IncidentTable
|
|
incidents={data.incidents}
|
|
basePath="/supervisor"
|
|
total={data.total}
|
|
counts={data.counts}
|
|
params={params}
|
|
sites={data.sites}
|
|
trucks={data.trucks}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|