import { FC, Fragment, ReactElement, useState } from 'react'; import { SearchOutlined, EditOutlined, DeleteOutlined, PlusOutlined, } from '@ant-design/icons'; import { Button, Input } from '@imphnen-frontend-service/ui/atoms'; import { DataTable } from '@imphnen-frontend-service/ui/organisms'; import { ColumnDef, getCoreRowModel, getPaginationRowModel, PaginationState, RowSelectionState, useReactTable, } from '@tanstack/react-table'; import ModalAddRole from './_components/modal-add-role'; import ModalUpdateRole from './_components/modal-update-role'; import ModalDeleteRole from './_components/modal-delete-role'; import { useQueryState } from '@imphnen-frontend-service/utils'; import React from 'react'; interface Role { id: number; name: string; } const mockData: Role[] = [ { id: 1, name: 'Admin' }, { id: 2, name: 'Admin Pembayaran' }, { id: 3, name: 'Staff' }, { id: 4, name: 'Staff Aktivasi User' }, { id: 5, name: 'User' }, ]; export const Components: FC = (): ReactElement => { const [showModalAddItem, setShowModalAddItem] = useState(false); const [showModalUpdateItem, setShowModalUpdateItem] = useState(false); const [showModalDeleteItem, setShowModalDeleteItem] = useState(false); const { step: currentStep, nextStep, prevStep, resetStep, } = useQueryState('step', { defaultValue: 1, maxValue: 2, minValue: 1, }); const [pagination, setPagination] = React.useState({ pageIndex: 0, pageSize: 9, }); const [rowSelection, setRowSelection] = React.useState({}); const columns: ColumnDef[] = [ { id: 'select', header: ({ table }) => ( ), cell: ({ row }) => ( ), }, { header: 'ID', accessorKey: 'id', }, { header: 'Roles Name', accessorKey: 'name', }, { header: 'Action', cell: () => (
), }, ]; const table = useReactTable({ data: mockData, columns, state: { pagination, rowSelection, }, enableRowSelection: true, onRowSelectionChange: setRowSelection, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), onPaginationChange: setPagination, pageCount: Math.ceil(mockData.length / pagination.pageSize), manualPagination: false, }); return (

Roles

setShowModalAddItem(false)} nextStep={nextStep} prevStep={prevStep} resetStep={resetStep} /> setShowModalUpdateItem(false)} nextStep={nextStep} prevStep={prevStep} resetStep={resetStep} /> setShowModalDeleteItem(false)} nextStep={nextStep} prevStep={prevStep} resetStep={resetStep} />
); }; export default Components;