import DT from 'datatables.net-dt' import DataTable from 'datatables.net-react' import { Link, useRouteLoaderData } from 'react-router' import type { TCategoryResponse } from '~/apis/common/get-categories' import { Button } from '~/components/ui/button' import { UiTable } from '~/components/ui/table' import { TitleDashboard } from '~/components/ui/title-dashboard' import type { loader } from '~/routes/_admin.lg-admin._dashboard.categories._index' export const CategoriesPage = () => { const loaderData = useRouteLoaderData( 'routes/_admin.lg-admin._dashboard.categories._index', ) const categoriesData = loaderData?.dataCategories DataTable.use(DT) const dataTable = categoriesData?.sort((a, b) => { if (a.sequence === null) return 1 if (b.sequence === null) return -1 return a.sequence - b.sequence }) const dataColumns = [ { title: 'No', render: ( data: unknown, type: unknown, row: TCategoryResponse, meta: { row: number }, ) => { return `
${meta.row + 1}
${ row.sequence === null ? '' : `
Urutan: ${row.sequence}
` }` }, }, { title: 'Kategori', }, { title: 'Deskripsi', data: 'description', }, { title: 'Action', data: 'id', }, ] const dataSlot = { 1: (_value: unknown, _type: unknown, data: TCategoryResponse) => (
{data.name}
Kode: {data.code}
), 3: (value: string) => ( ), } const dataOptions = { paging: true, searching: true, ordering: true, info: true, } return (
{/* TODO: Filter */}
) }