mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 11:06:29 +00:00
5a3629badf
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
95 lines
2.8 KiB
TypeScript
95 lines
2.8 KiB
TypeScript
'use client'
|
|
|
|
import { ChangeEvent, FC, useEffect, useState } from 'react';
|
|
import { Table } from 'antd';
|
|
import { TableProps, type ColumnsType } from 'antd/es/table';
|
|
import { MixerHorizontalIcon } from '@radix-ui/react-icons';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Input } from '@/components/ui/input';
|
|
import { type IRole } from './type';
|
|
|
|
type Props = {
|
|
data: IRole[]
|
|
};
|
|
|
|
const ComponentRolePage: FC<Props> = ({ data }) => {
|
|
const [filterData, setFilterData] = useState<IRole[]>([])
|
|
|
|
useEffect(() => {
|
|
if (data) {
|
|
setFilterData(data)
|
|
}
|
|
}, [data])
|
|
|
|
const handleSearch = (e: ChangeEvent<HTMLInputElement>) => {
|
|
const text = e.target.value
|
|
if (text) {
|
|
const newData = [...data!].filter(item => (
|
|
item.name?.toLowerCase().includes(text.toLowerCase()) ||
|
|
item.description?.toLowerCase().includes(text.toLowerCase())
|
|
))
|
|
setFilterData(newData)
|
|
} else {
|
|
setFilterData(data)
|
|
}
|
|
}
|
|
|
|
const Columns: ColumnsType<IRole> = [
|
|
{
|
|
title: 'Num',
|
|
dataIndex: 'key',
|
|
render: (text, record, index) => index + 1
|
|
},
|
|
{
|
|
title: 'Code',
|
|
dataIndex: 'code',
|
|
},
|
|
{
|
|
title: 'Name',
|
|
dataIndex: 'name',
|
|
sorter: (a, b) => a.name.localeCompare(b.name)
|
|
},
|
|
{
|
|
title: 'Description',
|
|
dataIndex: 'description',
|
|
}
|
|
];
|
|
|
|
const tableProps: TableProps<IRole> = {
|
|
bordered: false,
|
|
showHeader: true,
|
|
pagination: {
|
|
pageSizeOptions: [5, 10, 20, 50],
|
|
defaultPageSize: 10,
|
|
showSizeChanger: true,
|
|
showQuickJumper: true,
|
|
size: 'default'
|
|
},
|
|
scroll: { x: 'max-content' },
|
|
tableLayout: 'auto',
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<div className='flex flex-col space-y-4'>
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex flex-1 items-center space-x-2">
|
|
<Input placeholder="Search working status..." className="h-8 w-[150px] lg:w-[250px]" onChange={handleSearch} />
|
|
<Button variant="outline" size="sm" className="h-8 border-dashed">
|
|
<MixerHorizontalIcon className="mr-2 h-4 w-4" />
|
|
Filter
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
<Table
|
|
{...tableProps}
|
|
rowKey='code'
|
|
columns={Columns}
|
|
dataSource={filterData || []}
|
|
/>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default ComponentRolePage; |