diff --git a/app/apis/common/get-categories.ts b/app/apis/common/get-categories.ts index c074cee..778e58d 100644 --- a/app/apis/common/get-categories.ts +++ b/app/apis/common/get-categories.ts @@ -6,6 +6,8 @@ export const categoryResponseSchema = z.object({ id: z.string(), name: z.string(), code: z.string(), + sequence: z.number().nullable(), + description: z.string().nullable(), }) const categoriesResponseSchema = z.object({ data: z.array(categoryResponseSchema), diff --git a/app/pages/dashboard-categories/index.tsx b/app/pages/dashboard-categories/index.tsx index f3ee82e..163e64c 100644 --- a/app/pages/dashboard-categories/index.tsx +++ b/app/pages/dashboard-categories/index.tsx @@ -2,6 +2,7 @@ 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' @@ -13,26 +14,33 @@ export const CategoriesPage = () => { const categoriesData = loaderData?.dataCategories DataTable.use(DT) - const dataTable = categoriesData + 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: unknown, + row: TCategoryResponse, meta: { row: number }, ) => { - return meta.row + 1 + return `
Urutan: ${row.sequence}`
+ }`
},
},
{
- title: 'Nama',
- data: 'name',
+ title: 'Kategori',
},
{
- title: 'Kode',
- data: 'code',
+ title: 'Deskripsi',
+ data: 'description',
},
{
title: 'Action',
@@ -40,6 +48,12 @@ export const CategoriesPage = () => {
},
]
const dataSlot = {
+ 1: (_value: unknown, _type: unknown, data: TCategoryResponse) => (
+ Kode: {data.code}
+