mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 11:06:29 +00:00
279b642a7a
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.
55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
import { type Metadata } from 'next';
|
|
import { FC, Suspense, lazy } from 'react';
|
|
import dayjs from 'dayjs';
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
import LazyLoading from '@/components/loader/LazyLoading';
|
|
import { fetchDataWithPost } from '@/lib/fetchData';
|
|
import { getAccessPagePermission } from '@/lib/get-access-data';
|
|
|
|
const ExportComponent = lazy(() => import('./component/Export'));
|
|
const ComponentPage = lazy(() => import('./component'));
|
|
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Admin | Manual Attendance & Approval",
|
|
}
|
|
|
|
type Props = {
|
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
|
|
};
|
|
|
|
const ApprovalNonWFOPage: FC<Props> = async ({ searchParams }) => {
|
|
const actions = await getAccessPagePermission('/manual/approval')
|
|
|
|
const start_date = (await searchParams)!.start_date
|
|
const end_date = (await searchParams)!.end_date
|
|
|
|
const data = await fetchDataWithPost('/presence/history/non-wfo', { 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>Approval Attendance</CardTitle>
|
|
<CardDescription className='mt-1 sm:block hidden'>Here's a list of approval attendance those working outside the office!</CardDescription>
|
|
</div>
|
|
{actions.includes('EXPORT') &&
|
|
<Suspense fallback={<LazyLoading />}>
|
|
<ExportComponent data={data.history} />
|
|
</Suspense>
|
|
}
|
|
</CardHeader>
|
|
<CardContent>
|
|
<Suspense fallback={<LazyLoading />}>
|
|
<ComponentPage data={data.history} />
|
|
</Suspense>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default ApprovalNonWFOPage; |