Files
hats-app/app/admin/report/distribution/page.tsx
T
Ichsan Kurniawan 279b642a7a Apply RBAC permissions across admin and tasks
Enforce page access and action-level permissions across admin and task views, including exports and record actions. Move user creation to a client component behind server-side permission checks, standardize data fetching, and remove the deprecated user-role route.
2026-11-09 17:32:31 +07:00

42 lines
1.3 KiB
TypeScript

import { type Metadata } from 'next';
import { FC, Suspense, lazy } from 'react';
import { Card } from '@/components/ui/card';
import LazyLoading from '@/components/loader/LazyLoading';
import dayjs from 'dayjs';
import { fetchDataWithPost } from '@/lib/fetchData';
import { getAccessPagePermission } from '@/lib/get-access-data';
const ComponentPage = lazy(() => import('./component'));
export const metadata: Metadata = {
title: "Admin | Attendance Distribution",
}
type Props = {
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
};
const AttendanceDistributionPage: FC<Props> = async ({ searchParams }) => {
const actions = await getAccessPagePermission('/report/distribution')
const start_date = (await searchParams)!.start_date
const end_date = (await searchParams)!.end_date
const data = await fetchDataWithPost('/presence/history', { start_date: start_date || dayjs().subtract(1, 'month'), end_date: end_date || dayjs().format('YYYY-MM-DD') })
return (
<>
<div className="flex flex-col">
<Card>
<Suspense fallback={<LazyLoading />}>
<ComponentPage data={data.history} actions={actions} />
</Suspense>
</Card>
</div>
</>
);
}
export default AttendanceDistributionPage;