initial commit for new hats app

This commit is contained in:
Ichsan Kurniawan
2025-12-19 13:57:55 +07:00
parent aa949d71ff
commit 7e172f5cf7
314 changed files with 31102 additions and 208 deletions
@@ -0,0 +1,91 @@
'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 IMasterStatus } from './type';
type Props = {
data: IMasterStatus[]
};
const ComponentRolePage: FC<Props> = ({ data }) => {
const [filterData, setFilterData] = useState<IMasterStatus[]>([])
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<IMasterStatus> = [
{
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<IMasterStatus> = {
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 master status..." className="h-8 w-[150px] lg:w-[250px]" onChange={handleSearch} />
</div>
</div>
<Table
{...tableProps}
rowKey='id'
columns={Columns}
dataSource={filterData || []}
/>
</div>
</>
);
}
export default ComponentRolePage;
@@ -0,0 +1,6 @@
export interface IMasterStatus {
id: number,
name: string,
code: string,
description: string
}