mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 22:36:29 +00:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 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';
|
|
|
|
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 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} />
|
|
</Suspense>
|
|
</Card>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default AttendanceDistributionPage; |