mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
109 lines
8.0 KiB
TypeScript
109 lines
8.0 KiB
TypeScript
import { FC, Fragment } from 'react';
|
|
import Link from 'next/link';
|
|
import dayjs from 'dayjs';
|
|
import { ScrollArea } from '@/components/ui/scroll-area';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Badge } from '@/components/ui/badge';
|
|
import { getVariantApproved } from '@/lib/helper';
|
|
|
|
type Props = {
|
|
data: any
|
|
};
|
|
|
|
const PresenceHistory: FC<Props> = ({ data }) => {
|
|
|
|
// console.log(data)
|
|
return (
|
|
<>
|
|
<ScrollArea className="px-6" height='max-h-[325px] sm:max-h-[370px]'>
|
|
<div className="space-y-6 overflow-x-auto">
|
|
{data && data.length > 0 ?
|
|
<>
|
|
{
|
|
data.slice(0, 4).map((item: any, key: number) =>
|
|
<Fragment key={key}>
|
|
{item.presence_checkout &&
|
|
<div className="flex sm:items-center" >
|
|
<div className="min-w-9 min-h-9 max-w-9 max-h-9 object-cover rounded-full flex grow-0 justify-center items-center bg-rose-100 text-rose-600 shadow-sm">
|
|
<i className="ti ti-logout icon text-xl"></i>
|
|
</div>
|
|
<div className='ml-4 space-y-1'>
|
|
<p className="text-xs sm:text-sm font-medium leading-none">{dayjs(item.presence_checkout?.working_hours_end).format('dddd, DD MMM YYYY')}</p>
|
|
{item.working_status === 'WFO' ?
|
|
item.presence_checkout.auto_checkout || item.presence_checkout.manual_presence ?
|
|
<div className='flex items-center'>
|
|
<p className='text-xs md:text-sm text-muted-foreground'>{item.working_status} - </p>
|
|
{item.presence_checkout.auto_checkout && <Badge className='ml-1' variant='his'>auto checkout</Badge>}
|
|
{item.presence_checkout.manual_presence && <Badge className='ml-1' variant='his'>manual presence</Badge>}
|
|
</div>
|
|
:
|
|
<p className='text-xs md:text-sm text-muted-foreground'>{item.presence_checkout?.device?.name} - {item.presence_checkout?.area ? item.presence_checkout?.area?.name : item.presence_checkout?.location_name}</p>
|
|
:
|
|
item.presence_checkout.auto_checkout || item.presence_checkout.manual_presence ?
|
|
<div className='flex items-center'>
|
|
<p className='text-xs md:text-sm text-muted-foreground'>{item.working_status} - </p>
|
|
{item.presence_checkout.auto_checkout && <Badge className='ml-1' variant='his'>auto checkout</Badge>}
|
|
{item.presence_checkout.manual_presence && <Badge className='ml-1' variant='his'>manual presence</Badge>}
|
|
</div>
|
|
:
|
|
<p className='text-xs md:text-sm text-muted-foreground'>
|
|
{
|
|
item.working_status + ' - ' + item.presence_checkout?.location_name
|
|
}
|
|
</p>
|
|
}
|
|
{item.is_clear_auto_checkout === false &&
|
|
<Badge>need to be approve</Badge>
|
|
}
|
|
{item.is_clear_auto_checkout === true &&
|
|
<Badge variant='secondary'>approved</Badge>
|
|
}
|
|
</div>
|
|
<div className="ml-auto font-semibold text-xs sm:text-base min-w-[70px]! sm:min-w-[90px]! text-right text-rose-500">{dayjs(item.presence_checkout?.working_hours_end).format('HH:mm A')}</div>
|
|
</div>
|
|
}
|
|
<div className="flex sm:items-center" >
|
|
<div className="min-w-9 min-h-9 max-w-9 max-h-9 object-cover rounded-full flex grow-0 justify-center items-center bg-green-100 text-green-600 shadow-sm">
|
|
<i className="ti ti-login icon text-xl"></i>
|
|
</div>
|
|
<div className={`ml-4 ${item.working_status === 'WFH' || item.working_status === 'WFS' ? 'space-y-0' : 'space-y-1'}`}>
|
|
<p className="text-xs sm:text-sm font-medium leading-none">{dayjs(item.working_hours_start).format('dddd, DD MMM YYYY')}</p>
|
|
<div className="text-xs md:text-sm text-muted-foreground">
|
|
{item.manual_presence ?
|
|
<div className='flex items-center'>
|
|
<p className='text-xs md:text-sm text-muted-foreground'>{item.working_status} - </p>
|
|
<Badge className='ml-1' variant='his'>manual presence</Badge>
|
|
</div>
|
|
:
|
|
item.working_status === 'WFO' ?
|
|
item.device.name + ' - ' + item.area.name
|
|
:
|
|
item.working_status + ' - ' + item.location_name
|
|
}
|
|
</div>
|
|
{!item.manual_presence && (item.working_status === 'WFH' || item.working_status === 'WFS') &&
|
|
<Badge variant={getVariantApproved(item.status.code)}>{item.status.name}</Badge>
|
|
}
|
|
</div>
|
|
<div className="ml-auto font-semibold text-xs sm:text-base min-w-[70px]! sm:min-w-[90px]! text-right text-green-500">{dayjs(item.working_hours_start).format('HH:mm A')}</div>
|
|
</div>
|
|
</Fragment>
|
|
)
|
|
}
|
|
<Link href='/history'>
|
|
<Button className="w-full mt-10">Show More</Button>
|
|
</Link>
|
|
</>
|
|
|
|
:
|
|
<div className="h-32 w-full flex justify-center items-center" >
|
|
No results.
|
|
</div>
|
|
}
|
|
</div>
|
|
</ScrollArea>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default PresenceHistory; |