mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 19:26:28 +00:00
50 lines
2.0 KiB
TypeScript
50 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 | Leave, Permit and Sick Report",
|
|
}
|
|
|
|
type Props = {
|
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
|
|
};
|
|
|
|
const LeavePermitSickReportPage: FC<Props> = async ({ searchParams }) => {
|
|
const start_date = (await searchParams)!.start_date
|
|
const end_date = (await searchParams)!.end_date
|
|
|
|
const data = await fetchDataWithPost('/application-form/history', { start_date: start_date || dayjs().subtract(1, 'month'), end_date: end_date || dayjs().add(1, 'month').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>Leave, Permit and Sick Report</CardTitle>
|
|
<CardDescription className='mt-1 sm:block hidden'>Here's a list of application form for leave, permit and sick!</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 LeavePermitSickReportPage; |