2026-04-12 23:01:47 +07:00
|
|
|
import { createFileRoute, useNavigate } from '@tanstack/react-router';
|
|
|
|
|
import * as React from 'react';
|
|
|
|
|
import { Search, Eye } from 'lucide-react';
|
|
|
|
|
import {
|
|
|
|
|
Badge,
|
|
|
|
|
Button,
|
|
|
|
|
Card,
|
|
|
|
|
CardContent,
|
|
|
|
|
CardHeader,
|
|
|
|
|
Input,
|
|
|
|
|
Select,
|
|
|
|
|
SelectContent,
|
|
|
|
|
SelectItem,
|
|
|
|
|
SelectTrigger,
|
|
|
|
|
SelectValue,
|
|
|
|
|
} 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 {
|
|
|
|
|
useMySessions,
|
|
|
|
|
TSessionListItem,
|
|
|
|
|
} from '@imphnen-frontend-service/service';
|
|
|
|
|
import {
|
|
|
|
|
SelectAllCheckbox,
|
|
|
|
|
RowSelectCheckbox,
|
|
|
|
|
} from '../../components/list-helpers';
|
2025-08-20 21:58:28 +07:00
|
|
|
|
2026-04-11 17:04:14 +07:00
|
|
|
export const Route = createFileRoute('/_authenticated/session-dimentorin')({
|
|
|
|
|
component: SessionDimentorinPage,
|
2026-04-12 23:01:47 +07:00
|
|
|
});
|
2026-04-11 17:04:14 +07:00
|
|
|
|
2026-04-12 23:01:47 +07:00
|
|
|
function SessionDimentorinPage() {
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const [statusFilter, setStatusFilter] = React.useState('all');
|
|
|
|
|
const [rowSelection, setRowSelection] =
|
|
|
|
|
React.useState<RowSelectionState>({});
|
|
|
|
|
const [pagination, setPagination] = React.useState<PaginationState>({
|
2025-08-20 21:58:28 +07:00
|
|
|
pageIndex: 0,
|
2026-04-12 23:01:47 +07:00
|
|
|
pageSize: 10,
|
|
|
|
|
});
|
2025-08-20 21:58:28 +07:00
|
|
|
|
2026-04-05 17:08:42 +07:00
|
|
|
const { data: sessionsData, isLoading } = useMySessions(
|
2026-04-12 23:01:47 +07:00
|
|
|
statusFilter !== 'all' ? { status: statusFilter } : undefined
|
|
|
|
|
);
|
2026-04-05 17:08:42 +07:00
|
|
|
|
2026-04-12 23:01:47 +07:00
|
|
|
const sessions: TSessionListItem[] = sessionsData?.sessions ?? [];
|
|
|
|
|
const totalItems = sessionsData?.total ?? sessions.length;
|
|
|
|
|
|
|
|
|
|
const statusVariants: Record<
|
|
|
|
|
string,
|
|
|
|
|
'warning' | 'info' | 'success' | 'destructive' | 'secondary'
|
|
|
|
|
> = {
|
|
|
|
|
pending: 'warning',
|
|
|
|
|
confirmed: 'info',
|
|
|
|
|
ongoing: 'warning',
|
|
|
|
|
completed: 'success',
|
|
|
|
|
cancelled: 'destructive',
|
|
|
|
|
};
|
2026-04-05 17:08:42 +07:00
|
|
|
|
|
|
|
|
const columns: ColumnDef<TSessionListItem>[] = [
|
2025-08-20 21:58:28 +07:00
|
|
|
{
|
|
|
|
|
id: 'select',
|
2026-04-12 23:01:47 +07:00
|
|
|
meta: { cellClassName: cn('w-10') },
|
|
|
|
|
header: ({ table }) => <SelectAllCheckbox table={table} />,
|
|
|
|
|
cell: ({ row }) => <RowSelectCheckbox row={row} />,
|
2025-08-20 21:58:28 +07:00
|
|
|
},
|
2026-04-12 23:01:47 +07:00
|
|
|
{ id: 'id', header: 'ID Sesi', accessorKey: 'id' },
|
|
|
|
|
{ id: 'mentorId', header: 'Nama Mentor', accessorKey: 'mentor_id' },
|
2025-08-20 21:58:28 +07:00
|
|
|
{
|
|
|
|
|
id: 'menteeName',
|
|
|
|
|
header: 'Nama Mentee',
|
2026-04-05 17:08:42 +07:00
|
|
|
accessorKey: 'mentee_fullname',
|
2025-08-20 21:58:28 +07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'datetime',
|
|
|
|
|
header: 'Waktu',
|
2026-04-05 17:08:42 +07:00
|
|
|
accessorKey: 'scheduled_at',
|
|
|
|
|
cell: ({ row }) => (
|
2026-04-12 23:01:47 +07:00
|
|
|
<span>
|
|
|
|
|
{new Date(row.original.scheduled_at).toLocaleString('id-ID')}
|
|
|
|
|
</span>
|
2026-04-05 17:08:42 +07:00
|
|
|
),
|
2025-08-20 21:58:28 +07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'status',
|
|
|
|
|
header: 'Status',
|
|
|
|
|
accessorKey: 'status',
|
2026-04-12 23:01:47 +07:00
|
|
|
cell: ({ row }) => (
|
|
|
|
|
<Badge
|
|
|
|
|
variant={statusVariants[row.original.status] ?? 'secondary'}
|
|
|
|
|
className="capitalize"
|
|
|
|
|
>
|
|
|
|
|
{row.original.status}
|
|
|
|
|
</Badge>
|
|
|
|
|
),
|
2025-08-20 21:58:28 +07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
header: 'Action',
|
2026-04-11 22:19:06 +07:00
|
|
|
cell: ({ row }) => (
|
2025-08-20 21:58:28 +07:00
|
|
|
<Button
|
2026-04-12 23:01:47 +07:00
|
|
|
variant="secondary"
|
2025-08-20 21:58:28 +07:00
|
|
|
size="sm"
|
|
|
|
|
onClick={(e) => {
|
2026-04-12 23:01:47 +07:00
|
|
|
e.stopPropagation();
|
|
|
|
|
navigate({
|
|
|
|
|
to: '/session-dimentorin/$id',
|
|
|
|
|
params: { id: row.original.id },
|
|
|
|
|
});
|
2025-08-20 21:58:28 +07:00
|
|
|
}}
|
|
|
|
|
>
|
2026-04-12 23:01:47 +07:00
|
|
|
<Eye className="size-3.5" />
|
|
|
|
|
Detail
|
2025-08-20 21:58:28 +07:00
|
|
|
</Button>
|
|
|
|
|
),
|
|
|
|
|
},
|
2026-04-12 23:01:47 +07:00
|
|
|
];
|
2025-08-20 21:58:28 +07:00
|
|
|
|
|
|
|
|
const table = useReactTable({
|
2026-04-05 17:08:42 +07:00
|
|
|
data: sessions,
|
2025-08-20 21:58:28 +07:00
|
|
|
columns,
|
2026-04-12 23:01:47 +07:00
|
|
|
state: { pagination, rowSelection },
|
2025-08-20 21:58:28 +07:00
|
|
|
enableRowSelection: true,
|
|
|
|
|
onRowSelectionChange: setRowSelection,
|
|
|
|
|
getCoreRowModel: getCoreRowModel(),
|
|
|
|
|
getPaginationRowModel: getPaginationRowModel(),
|
|
|
|
|
onPaginationChange: setPagination,
|
2026-04-05 17:08:42 +07:00
|
|
|
pageCount: Math.ceil(totalItems / pagination.pageSize),
|
|
|
|
|
manualPagination: true,
|
2026-04-12 23:01:47 +07:00
|
|
|
});
|
2025-08-20 21:58:28 +07:00
|
|
|
|
|
|
|
|
return (
|
2026-04-12 23:01:47 +07:00
|
|
|
<BackofficeWrapper
|
|
|
|
|
title="Session Management"
|
|
|
|
|
description="Kelola sesi mentoring aktif"
|
|
|
|
|
>
|
|
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
|
|
|
|
<div className="relative w-full sm:max-w-sm">
|
|
|
|
|
<Search className="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
|
|
|
|
|
<Input className="pl-9" placeholder="Cari nama lengkap…" />
|
2025-08-20 21:58:28 +07:00
|
|
|
</div>
|
2026-04-12 23:01:47 +07:00
|
|
|
<Select value={statusFilter} onValueChange={setStatusFilter}>
|
|
|
|
|
<SelectTrigger className="w-40">
|
|
|
|
|
<SelectValue placeholder="Status" />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
<SelectItem value="all">Semua Status</SelectItem>
|
|
|
|
|
<SelectItem value="pending">Pending</SelectItem>
|
|
|
|
|
<SelectItem value="confirmed">Confirmed</SelectItem>
|
|
|
|
|
<SelectItem value="ongoing">On Going</SelectItem>
|
|
|
|
|
<SelectItem value="completed">Completed</SelectItem>
|
|
|
|
|
<SelectItem value="cancelled">Cancelled</SelectItem>
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
2025-08-20 21:58:28 +07:00
|
|
|
</div>
|
2026-04-12 23:01:47 +07:00
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
{isLoading ? (
|
|
|
|
|
<div className="py-10 text-center text-sm text-muted-foreground">
|
|
|
|
|
Memuat data…
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<DataTable
|
|
|
|
|
data={sessions}
|
|
|
|
|
columns={columns}
|
|
|
|
|
table={table}
|
|
|
|
|
manualPagination
|
|
|
|
|
pageCount={Math.ceil(totalItems / pagination.pageSize)}
|
|
|
|
|
currentPage={pagination.pageIndex + 1}
|
|
|
|
|
onPageChange={(p) =>
|
|
|
|
|
setPagination((prev) => ({ ...prev, pageIndex: p - 1 }))
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
2025-08-20 21:58:28 +07:00
|
|
|
</BackofficeWrapper>
|
2026-04-12 23:01:47 +07:00
|
|
|
);
|
2025-08-20 21:58:28 +07:00
|
|
|
}
|