Files
hats-app/app/performance/[id]/components/Table.tsx
T
Ichsan Kurniawan 5a3629badf update performance, manual attendance, redownload leave form
Added the ability to view and re-download leave application forms in the Employee History page (Leave, Permit, and Sick tabs)
Added employee alpha stats and employee alpha detail in Employee Performance Page
Added total WFO, WFH and WFS in Admin Summary Report
Added batch import from Excel files in Admin Manual Attendance
2026-02-20 15:19:42 +07:00

75 lines
2.5 KiB
TypeScript

'use client'
import { ChangeEvent, FC, useEffect, useState } from 'react';
import { Table } from 'antd';
import { TableProps } from 'antd/es/table';
import { Input } from '@/components/ui/input';
import { IHistory } from '@/app/(dashboard)/history/components/type';
import ColumnsHistory from '@/app/admin/report/history/component/Columns';
type Props = {
data: IHistory[]
};
const TableAttendanceHistory: FC<Props> = ({ data }) => {
const [filterData, setFilterData] = useState<IHistory[]>([])
useEffect(() => {
if (data) {
setFilterData(data)
}
}, [data])
const handleSearch = (e: ChangeEvent<HTMLInputElement>) => {
const text = e.target.value
if (text) {
const newData = [...data!].filter(item => (
item.user.fullname?.toLowerCase().includes(text.toLowerCase()) ||
item.working_status?.toLowerCase().includes(text.toLowerCase()) ||
item.device.name?.toLowerCase().includes(text.toLowerCase()) ||
item.location_name?.toLowerCase().includes(text.toLowerCase()) ||
item.note?.toLowerCase().includes(text.toLowerCase()) ||
item.presence_checkout?.location_name?.toLowerCase().includes(text.toLowerCase()) ||
item.presence_checkout?.note?.toLowerCase().includes(text.toLowerCase())
))
setFilterData(newData)
} else {
setFilterData(data)
}
}
const tableProps: TableProps<IHistory> = {
size: 'small',
bordered: false,
showHeader: true,
pagination: {
pageSizeOptions: [5, 10, 20, 50],
defaultPageSize: 15,
showSizeChanger: true,
showQuickJumper: true,
size: 'default'
},
scroll: { x: 'max-content' },
tableLayout: 'auto',
};
return (
<>
<div className='flex flex-col space-y-4 w-full'>
<div className="flex items-center justify-between">
<div className="flex flex-1 items-center space-x-2">
<Input placeholder="Search attendance..." className="h-8 w-full sm:w-[250px]" onChange={handleSearch} />
</div>
</div>
<Table
{...tableProps}
rowKey='presence_checkin_code'
columns={ColumnsHistory}
dataSource={filterData || []}
/>
</div>
</>
);
}
export default TableAttendanceHistory;