Files
hats-app/app/admin/manual/approval/component/Detail.tsx
T
Ichsan Kurniawan 5e439ea9f7 remove next image
2026-01-28 21:10:07 +07:00

84 lines
5.1 KiB
TypeScript

import ViewAvatar from '@/components/ViewAvatar';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import { getVariantApproved, getVariantWorkingStatus } from '@/lib/helper';
import dayjs from 'dayjs';
import { Dispatch, FC, MouseEvent, SetStateAction } from 'react';
type Props = {
open: boolean
onOpenChange: Dispatch<SetStateAction<boolean>>
data: any
onClose: (e: MouseEvent<HTMLButtonElement>) => any
};
const DetailModalComponent: FC<Props> = ({ data, open, onOpenChange, onClose }) => {
return (
<>
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className='max-w-full md:max-w-[760px] py-6 md:px-10 overflow-y-auto max-h-[95vh]'>
<DialogHeader className='flex flex-row justify-between'>
<div>
<DialogTitle>Detail Attendance</DialogTitle>
<DialogDescription>
Attendance details of those working outside the office.
</DialogDescription>
</div>
</DialogHeader>
<div className='grid grid-cols-1 md:grid-cols-5 text-center md:text-left text-sm md:text-base md:my-3'>
<div className='col-span-2 flex flex-col items-center md:items-start'>
<ViewAvatar isPresence avatar={data.presence_checkin_face_image} className='w-52 h-52 sm:w-52 sm:h-52 rounded-xl shadow' />
<span className='text-base font-semibold mt-2'>{data.fullname}</span>
<span className='text-muted-foreground max-w-full! truncate'>{data?.position_name || data?.nickname}</span>
</div>
<div className='col-span-3 space-y-3 mt-5 md:mt-0'>
<div className='flex flex-col items-center md:items-start'>
<p className='text-muted-foreground text-xs md:text-sm font-medium'>Check-In :</p>
<div className='flex items-center space-x-2'>
<p>{dayjs(data.working_hours_start).format('dddd, DD MMM YYYY HH:mm A')}</p>
<Badge variant={getVariantWorkingStatus(data.working_status)}>{data.working_status}</Badge>
</div>
</div>
<div className='flex flex-col'>
<p className='text-muted-foreground text-xs md:text-sm font-medium'>Location :</p>
<p className='font-medium text-xs'>{data.presence_checkin_latitude}, {data.presence_checkin_longitude}</p>
<div>
{data.presence_checkin_location_name || '-'}
</div>
</div>
<div>
<p className='text-muted-foreground text-xs md:text-sm font-medium'>Device :</p>
<p className='wrap-break-word'>{data.presence_checkin_device_name || '-'}</p>
</div>
<div>
<p className='text-muted-foreground text-xs md:text-sm font-medium'>Notes :</p>
<p className='wrap-break-word'>{data.presence_checkin_note || '-'}</p>
</div>
<div>
<p className='text-muted-foreground text-xs md:text-sm font-medium'>Check-out time :</p>
<p>{data?.working_hours_end ? dayjs(data?.working_hours_end).format('HH:mm A') : 'Not check-out yet'}</p>
</div>
<div>
<p className='text-muted-foreground text-xs md:text-sm font-medium'>Approval :</p>
<Badge variant={getVariantApproved(data.presence_checkin_status_code)}>{data.presence_checkin_status_name}</Badge>
{(data.approved_by || data.rejected_by) &&
<div className='flex flex-col'>
<p className='font-semibold'>by {data.approved_by || data.rejected_by}</p>
<p>at {data.approved_by ? dayjs(data.approved_at).format('dddd, DD MMM YYYY HH:mm A') : dayjs(data.rejected_at).format('ddd, DD MMM YYYY HH:mm A')}</p>
</div>
}
</div>
</div>
</div>
<DialogFooter>
<Button onClick={onClose}>Close</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
);
}
export default DetailModalComponent;