Files
hats-app/app/admin/administration/user/component/EmployeePerformance/index.tsx
T
2025-12-19 13:57:55 +07:00

192 lines
13 KiB
TypeScript

import { Dispatch, FC, MouseEvent, SetStateAction, Suspense, lazy } from 'react';
import dayjs from 'dayjs';
import { Dialog, DialogContent, DialogFooter, DialogTitle } from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Card, Card900, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import LazyLoading from '@/components/loader/LazyLoading';
import ViewAvatar from '@/components/ViewAvatar';
import { type IUser } from '../type';
const DonutChart = lazy(() => import('./DonutChart'));
const AreaChart = lazy(() => import('./AreaChart'))
const TableAttendanceHistory = lazy(() => import('./Table'))
const ExportComponent = lazy(() => import('@/app/admin/report/history/component/Export'))
type Props = {
open: boolean
onOpenChange: Dispatch<SetStateAction<boolean>>
data: IUser
onClose: (e: MouseEvent<HTMLButtonElement>) => any
};
const EmployeePerformance: FC<Props> = ({ open, onOpenChange, data, onClose }) => {
return (
<>
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="min-w-[95vw] max-w-[95vw] 2xl:min-w-[80vw] 2xl:max-w-[80vw] overflow-hidden overflow-y-auto max-h-[95vh]">
<div className='gap-4 space-y-7'>
<Card900>
<CardContent className='flex xl:items-center mt-6'>
<ViewAvatar avatar={data.avatar} className='w-20 h-20 sm:w-44 sm:h-44 duration-300' />
<div className='ml-6 2xl:ml-10 w-full'>
<DialogTitle className='sm:text-2xl'>{data.fullname}</DialogTitle>
<div className='grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-2 mt-3 w-full'>
<div className='flex flex-col'>
<span className='text-muted-foreground text-sm'>Position</span>
<span>{data.position?.name}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground text-sm'>NIKTG</span>
<span>{data.niktg || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground text-sm'>NIK</span>
<span>{data.nik || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground text-sm'>Employee Type</span>
<span>{data.employee_type?.name || '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground text-sm'>Office Email</span>
<a title={data.email_office || ''} href={`mailto:${data.email_office}`} referrerPolicy="no-referrer" className='truncate'>
{data.email_office || '-'}
</a>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground text-sm'>Phone</span>
<span>{data.phone_number}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground text-sm'>Hire Date</span>
<span>{data.hire_date ? dayjs(data.hire_date).format('MMM DD, YYYY') : '-'}</span>
</div>
<div className='flex flex-col'>
<span className='text-muted-foreground text-sm'>Contract Expiration Date</span>
<span>{data.contract_expiration_date ? dayjs(data.contract_expiration_date).format('MMM DD, YYYY') : '-'}</span>
</div>
</div>
</div>
</CardContent>
</Card900>
<div className='grid gap-3 grid-cols-1 sm:grid-cols-2 xl:grid-cols-4'>
<div className='space-y-3'>
<Card900>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Working Hour in this Month</CardTitle>
<i className="ti ti-clock-play icon h-4 w-4 text-his text-xl"></i>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{'0 Hour'}</div>
<p className="text-xs text-muted-foreground">
number of working hours in this month
</p>
</CardContent>
</Card900>
<Card900>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Total OvertIme</CardTitle>
<i className="ti ti-clock-play icon h-4 w-4 text-his text-xl"></i>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{'0 Hour'}</div>
<p className="text-xs text-muted-foreground">
in the Past 30 Days (Weekend Only)
</p>
</CardContent>
</Card900>
</div>
<div className='space-y-3'>
<Card900 className='relative'>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Total <span className='text-cyan-500 font-semibold'>Task</span> | <span className='text-amber-500 font-semibold'>On Progress</span> | <span className='text-lime-500 font-semibold'>Done</span></CardTitle>
<i className="ti ti-clock-play icon h-4 w-4 text-his text-xl"></i>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold"><span className='text-cyan-500'>-</span> | <span className='text-amber-500'>-</span> | <span className='text-lime-500'>-</span></div>
<p className="text-xs text-muted-foreground">
in the Past 30 Days
</p>
</CardContent>
<div className='absolute inset-0 w-full h-full bg-black rounded-2xl bg-opacity-60 flex justify-center items-center font-semibold text-xl'>
<p className='animate-pulse'>Coming soon</p>
</div>
</Card900>
<Card900>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Average <span className='text-green-500 font-semibold'>Check IN</span> | <span className='text-rose-500 font-semibold'>Check OUT</span></CardTitle>
<i className="ti ti-clock-play icon h-4 w-4 text-his text-xl"></i>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold"><span className='text-green-500'>--:--</span> | <span className='text-rose-500'>--:--</span></div>
<p className="text-xs text-muted-foreground">
in the Past 30 Days
</p>
</CardContent>
</Card900>
</div>
<Card900>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-0">
<CardTitle className="text-sm font-medium">Total <span className='text-emerald-500 font-semibold'>Leave</span> | <span className='text-yellow-500 font-semibold'>Sick</span> | <span className='text-orange-500 font-semibold'>Permit</span></CardTitle>
<i className="ti ti-clock-play icon h-4 w-4 text-his text-xl"></i>
</CardHeader>
<CardContent className='pb-0'>
<p className="text-xs text-muted-foreground">in the Past 30 Days</p>
<Suspense fallback={<LazyLoading />}>
<DonutChart data={[2, 3, 1]} labels={['Leave', 'Sick', 'Permit']} colors={['#10b981', '#eab308', '#f97316']} />
</Suspense>
</CardContent>
</Card900>
<Card900>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-0">
<CardTitle className="text-sm font-medium">Total <span className='text-sky-500 font-semibold'>WFO</span> | <span className='text-indigo-500 font-semibold'>WFS</span> | <span className='text-fuchsia-500 font-semibold'>WFH</span></CardTitle>
<i className="ti ti-clock-play icon h-4 w-4 text-his text-xl"></i>
</CardHeader>
<CardContent className='pb-0'>
<p className="text-xs text-muted-foreground">in the Past 30 Days</p>
<Suspense fallback={<LazyLoading />}>
<DonutChart data={[15, 3, 1]} labels={['WFO', 'WFS', 'WFH']} colors={['#0ea5e9', '#6366f1', '#d946ef']} />
</Suspense>
</CardContent>
</Card900>
</div>
<Card900>
<CardHeader>
<CardTitle>Attendance Statistics</CardTitle>
<CardDescription>Statistics of your attendance in last 30 days.</CardDescription>
</CardHeader>
<CardContent className="px-0">
<Suspense fallback={<LazyLoading />}>
<AreaChart data={[]} />
</Suspense>
</CardContent>
</Card900>
<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&apos;s a list of your attendance history in the Past 30 Days!</CardDescription>
</div>
<Suspense fallback={<LazyLoading />}>
<ExportComponent data={[]} />
</Suspense>
</CardHeader>
<CardContent className='flex justify-center items-center'>
<Suspense fallback={<LazyLoading />}>
<TableAttendanceHistory data={[]} />
</Suspense>
</CardContent>
</Card>
</div>
<DialogFooter>
<Button variant="outline" type="button" onClick={onClose} >
Close
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
);
}
export default EmployeePerformance;