import * as React from 'react'; import { FC, ReactElement, useState } from 'react'; import { FilterOutlined, SearchOutlined, EditOutlined, ArrowRightOutlined, ArrowLeftOutlined, } from '@ant-design/icons'; import { Button, Input } from '@imphnen-frontend-service/ui/atoms'; import { Pagination } from '@imphnen-frontend-service/ui/molecules'; import { DataTable } from '@imphnen-frontend-service/ui/organisms'; import { ColumnDef, flexRender, getCoreRowModel, getPaginationRowModel, PaginationState, useReactTable, } from '@tanstack/react-table'; // Define account interface interface Account { id: number; name: string; email: string; phone: string; address: string; } // Mock data for demonstration const mockData: Account[] = Array.from({ length: 90 }, (_, i) => ({ id: i + 1, name: i === 0 ? 'Ahmad Wijuana' : 'Nama Lengkap', email: 'fullname23@gmail.com', phone: '081904423804', address: 'Jl. Pantai Cibaduyut Indonesia', })); const columns: ColumnDef[] = [ { header: 'No', accessorKey: 'id', }, { header: 'Nama Lengkap', accessorKey: 'name', }, { header: 'Email', accessorKey: 'email', }, { header: 'Nomor Telp', accessorKey: 'phone', }, { header: 'Alamat Pengiriman', accessorKey: 'address', }, { header: 'Action', cell: ({ row }) => { return ( ); }, }, ]; // const columnHelper = createColumnHelper(); // const columns = [ // columnHelper.accessor('id', { // cell: (info) => info.column.id, // }), // columnHelper.accessor('name', { // header: 'Nama Lengkap', // cell: (info) => info.getValue(), // }), // columnHelper.accessor('name', { // header: 'Nama Lengkap', // cell: (info) => info.getValue(), // }), // columnHelper.accessor('name', { // header: 'Nama Lengkap', // cell: (info) => info.getValue(), // }), // ]; export const Components: FC = (): ReactElement => { const [searchQuery, setSearchQuery] = useState(''); // Filter data based on search query const filteredData = mockData.filter( (item) => item.name.toLowerCase().includes(searchQuery.toLowerCase()) || item.email.toLowerCase().includes(searchQuery.toLowerCase()) ); // const handleEdit = (id: number) => { // console.log(`Edit item with id: ${id}`); // // Implement edit functionality // }; const handleSearch = (e: React.ChangeEvent) => { setSearchQuery(e.target.value); // setCurrentPage(1); // Reset to first page when searching }; // const [data, _setData] = React.useState(() => [...mockData]); const [pagination, setPagination] = React.useState({ pageIndex: 0, pageSize: 9, }); const table = useReactTable({ data: mockData, columns, state: { pagination, }, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), onPaginationChange: setPagination, }); return (
{/* Header */}

Data Akun

{/* Account Table Section */}
{/* Search and Filter */}
{/* Table */}
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( ))} ))} {table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell, index) => ( ))} ))}
{header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext() )}
{flexRender( cell.column.columnDef.cell, cell.getContext() )}
{/* index + 1 + indexOfFirstItem, }, { label: 'Nama Lengkap', key: 'name' }, { label: 'Email', key: 'email' }, { label: 'Nomor Telp', key: 'phone' }, { label: 'Alamat Pengiriman', key: 'address' }, { label: 'Action', render: (item: Account) => ( ), }, ]} /> */} {/* Pagination */} {/* */}
{/* {table.getPageCount().map((page, index) => ( ))} */} {/*
{getPageNumbers().map((page, index) => typeof page === 'number' ? ( ) : ( {page} ) )}
*/}
{/* */}
Page
{table.getState().pagination.pageIndex + 1} of{' '} {table.getPageCount().toLocaleString()}
| Go to page: { const page = e.target.value ? Number(e.target.value) - 1 : 0; table.setPageIndex(page); }} className="border p-1 rounded w-16" />
); }; export default Components;