import { SearchOutlined } from '@ant-design/icons'; import { Button, Input, Select } from '@imphnen-frontend-service/ui/atoms'; import { BackofficeWrapper, DataTable, } from '@imphnen-frontend-service/ui/organisms'; import { cn, For } from '@imphnen-frontend-service/utils'; import { ColumnDef, getCoreRowModel, getPaginationRowModel, PaginationState, RowSelectionState, useReactTable, } from '@tanstack/react-table'; import { ReactElement, useState } from 'react'; import { ModalDetailUser } from './_components/modal/detail'; type UserStatus = 'active' | 'inactive'; interface UserType { id: number; name: string; email: string; rating: number; status: UserStatus; } const mockData: UserType[] = Array.from({ length: 90 }, (_, i) => ({ id: i + 1, name: i % 3 === 0 ? 'Ahmad Wijuana' : 'Sofia Wijuana', email: 'fullname23@gmail.com', rating: 4.5, status: i % 2 === 0 ? 'active' : 'inactive', })); export default function Components(): ReactElement { const TABS = ['mentor', 'mentee'] as const; const [activeTab, setActiveTab] = useState<'mentor' | 'mentee'>('mentor'); const [showDetail, setShowDetail] = useState(false); const [selectedUserId, setSelectedUserId] = useState(null); const [rowSelection, setRowSelection] = useState({}); const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 9, }); const columns: ColumnDef[] = [ { id: 'select', meta: { cellClassName: cn('w-20') }, header: ({ table }) => ( ), cell: ({ row }) => ( ), }, { id: 'name', header: 'Name', accessorKey: 'name', }, { id: 'email', header: 'Email', accessorKey: 'email', }, { id: 'rating', header: 'Rating', accessorKey: 'rating', }, { id: 'status', header: 'Status', accessorKey: 'status', cell: ({ row }) => { const status = row.original.status; const statusColors: Record = { active: 'bg-success-200 text-success-500', inactive: 'bg-danger-200 text-danger-500', }; const statusText: Record = { active: 'Active', inactive: 'Inactive', }; return (
{statusText[status]}
); }, }, { header: 'Action', meta: { cellClassName: cn('w-72') }, cell: ({ row }) => ( ), }, ]; 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 (

User Management

{(tab) => ( )}
); }