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 } from "@imphnen-frontend-service/utils"; import { ColumnDef, getCoreRowModel, getPaginationRowModel, PaginationState, RowSelectionState, useReactTable } from "@tanstack/react-table"; import { ReactElement, useState } from "react"; import { ModalDetailSession } from "./_components/modal/detail"; import { useMySessions, TSessionListItem } from "@imphnen-frontend-service/service"; export default function Components(): ReactElement { const [openDetail, setOpenDetail] = useState(false); const [statusFilter, setStatusFilter] = useState(''); const [rowSelection, setRowSelection] = useState({}) const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 9, }); const { data: sessionsData, isLoading } = useMySessions( statusFilter ? { status: statusFilter } : undefined ); const sessions: TSessionListItem[] = sessionsData?.sessions ?? []; const totalItems = sessionsData?.total ?? sessions.length; const columns: ColumnDef[] = [ { id: 'select', meta: { cellClassName: cn("w-20") }, header: ({ table }) => ( ), cell: ({ row }) => ( ), }, { id: 'id', header: 'ID Sesi', accessorKey: 'id', }, { id: 'mentorId', header: 'Nama Mentor', accessorKey: 'mentor_id', }, { id: 'menteeName', header: 'Nama Mentee', accessorKey: 'mentee_fullname', }, { id: 'datetime', header: 'Waktu', accessorKey: 'scheduled_at', cell: ({ row }) => ( {new Date(row.original.scheduled_at).toLocaleString('id-ID')} ), }, { id: 'status', header: 'Status', accessorKey: 'status', cell: ({ row }) => { const status = row.original.status; const statusColors: Record = { pending: 'bg-warning-200 text-warning-700', confirmed: 'bg-primary-200 text-primary-700', ongoing: 'bg-warning-200 text-warning-700', completed: 'bg-success-200 text-success-500', cancelled: 'bg-danger-200 text-danger-500', }; return (
{status}
); }, }, { header: 'Action', meta: { cellClassName: cn("w-52") }, cell: () => ( ), }, ] const table = useReactTable({ data: sessions, columns, state: { pagination, rowSelection, }, enableRowSelection: true, onRowSelectionChange: setRowSelection, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), onPaginationChange: setPagination, pageCount: Math.ceil(totalItems / pagination.pageSize), manualPagination: true, }); return (

Session Management

{isLoading ? (
Loading...
) : ( )}
) }