mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 22:56:27 +00:00
52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
import { type Metadata } from 'next';
|
|
import { FC, Suspense, lazy } from 'react';
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
import LazyLoading from '@/components/loader/LazyLoading';
|
|
import dayjs from 'dayjs';
|
|
import { fetchDataWithPost } from '@/lib/fetchData';
|
|
|
|
const ExportComponent = lazy(() => import('./component/Export'));
|
|
const ComponentPage = lazy(() => import('./component'));
|
|
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Admin | Attendance History",
|
|
}
|
|
|
|
type Props = {
|
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
|
|
};
|
|
|
|
const MonthlyPresencePage: 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>
|
|
<CardHeader className='flex flex-col md:flex-row items-center justify-between space-y-5 sm:space-y-0'>
|
|
<div>
|
|
<CardTitle>Attendance History</CardTitle>
|
|
<CardDescription className='mt-1 sm:block hidden'>Here's a list of all employee attendance history!</CardDescription>
|
|
</div>
|
|
<Suspense fallback={<LazyLoading />}>
|
|
<ExportComponent data={data.history} />
|
|
</Suspense>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<Suspense fallback={<LazyLoading />}>
|
|
<ComponentPage
|
|
data={data.history}
|
|
/>
|
|
</Suspense>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default MonthlyPresencePage; |