import { IHistory } from '@/app/(dashboard)/history/components/type'; import { Badge } from '@/components/ui/badge'; import { getVariantApproved, getVariantWorkingStatus } from '@/lib/helper'; import { type ColumnsType } from 'antd/es/table'; import dayjs from 'dayjs'; import Link from 'next/link'; const ColumnsHistory: ColumnsType = [ { title: 'Date', dataIndex: 'presence_date', sorter: ((a, b) => (dayjs(a.presence_date).isAfter(dayjs(b.presence_date)) ? 1 : -1)), render: (val) => dayjs(val).format('MMM DD, YYYY') }, { title: 'Name', dataIndex: 'fullname', sorter: (a, b) => a.user.fullname.localeCompare(b.user.fullname), render: (val, record) => record.user.fullname }, { title: 'Working Status', dataIndex: 'working_status', align: 'center', filters: [ { text: 'WFO', value: 'WFO', }, { text: 'WFS', value: 'WFS', }, { text: 'WFH', value: 'WFH', }, { text: 'Sakit', value: 'SKT', }, { text: 'Izin', value: 'IZ01', } ], onFilter: (value, record) => record.working_status!.indexOf(value as string) === 0, sorter: (a, b) => a.working_status?.localeCompare(b.working_status), render: (val, record) => {val} }, { title: 'Approval', dataIndex: 'status', align: 'center', filters: [ { text: 'Approved', value: 'AP', }, { text: 'Rejected', value: 'R', }, { text: 'Need to be Appove', value: 'NA', } ], onFilter: (value, record) => record.status.code!.indexOf(value as string) === 0, render: (val, record) => !record.manual_presence && (record.working_status === 'WFH' || record.working_status === 'WFS') ? {record.status.name} : '' }, { title: 'Check-in', dataIndex: 'working_hours_start', filters: [ { text: 'Less than 10:00 AM', value: 'lt_10', // You can use any value you prefer }, { text: 'More than or equal to 10:00 AM', value: 'gte_10', // You can use any value you prefer }, ], onFilter: (value, record) => { const time = new Date(record.working_hours_start).getHours(); if (value === 'lt_10') { return time < 10; } else if (value === 'gte_10') { return time >= 10; } return false; // If the value doesn't match any filter }, render: (val) => {dayjs(val).format('HH:mm A')} }, { title: 'Check-in Device', dataIndex: 'device', filters: [ { text: 'FR Device', value: '11001', }, { text: 'Web App', value: '40001', }, { text: 'Android App', value: '20001', }, { text: 'IOS App', value: '30001', } ], onFilter: (value, record) => record.device.code!.indexOf(value as string) === 0, render: (val, record) => record.device.name, }, { title: 'Check-in Location', dataIndex: 'location_name', onCell: (record, index) => { return { onClick: (evt) => { const url = `http://maps.google.com/maps?q=${record.latitude}+${record.longitude}` window.open(url, '_blank'); } } } }, { title: 'Check-in Note', dataIndex: 'note', }, { title: 'Check-in Photo', dataIndex: 'face_image', render: (val, record) => val ? e.stopPropagation()} className='text-his! hover:opacity-70 duration-200' href={process.env.BASE_URL_IMG + val} target="_blank">View Photo : '' }, { title: 'Check-out', dataIndex: 'working_hours_end', filters: [ { text: 'Less than 17:00 PM', value: 'lt_17', // You can use any value you prefer }, { text: 'More than or equal to 17:00 PM', value: 'gte_17', // You can use any value you prefer }, ], onFilter: (value, record) => { const time = new Date(record.presence_checkout?.working_hours_end).getHours(); if (value === 'lt_17') { return time < 17; } else if (value === 'gte_17') { return time >= 17; } return false; // If the value doesn't match any filter }, render: (val, record) => record.presence_checkout?.working_hours_end ? {dayjs(record.presence_checkout?.working_hours_end).format('HH:mm A')} : undefined }, { title: 'Check-out Device', dataIndex: 'device', filters: [ { text: 'FR Device', value: '11001', }, { text: 'Web App', value: '40001', }, { text: 'Android App', value: '20001', }, { text: 'IOS App', value: '30001', } ], onFilter: (value, record) => record.presence_checkout?.device?.code!.indexOf(value as string) === 0, render: (val, record) => record.presence_checkout?.device?.name, }, { title: 'Check-out Location', dataIndex: 'location_name', render: (val, record) => record.presence_checkout?.location_name }, { title: 'Check-out Note', dataIndex: 'note', render: (val, record) => record.presence_checkout?.note }, { title: 'Check-out Photo', dataIndex: 'face_image', render: (val, record) => record.presence_checkout?.face_image ? e.stopPropagation()} className='text-his! hover:opacity-70 duration-200' href={process.env.BASE_URL_IMG + record.presence_checkout?.face_image} target="_blank">View Photo : '' }, { title: 'Auto Checkout', dataIndex: 'autocheckout', align: 'center', filters: [ { text: 'Auto Checkout', value: true, } ], onFilter: (value, record) => record.presence_checkout?.auto_checkout?.valueOf() === true, render: (val, record) => record.presence_checkout?.auto_checkout ? : null }, { title: 'Clear AutoChekout', dataIndex: 'status', align: 'center', render: (val, record) => record?.is_clear_auto_checkout === false ? need to be approve : record.is_clear_auto_checkout === true ? approved : undefined }, { title: 'Manual Presence', dataIndex: 'manual_presence', align: 'center', render: (val, record) => val ? : null }, ]; export default ColumnsHistory