refactor: update table component types and enhance admin menu with category and tag
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import DT from 'datatables.net-dt'
|
||||
import DataTable from 'datatables.net-react'
|
||||
import DT, { type Config, type ConfigColumns } from 'datatables.net-dt'
|
||||
import DataTable, { type DataTableSlots } from 'datatables.net-react'
|
||||
import { Link, useRouteLoaderData } from 'react-router'
|
||||
|
||||
import type { TCategoryResponse } from '~/apis/common/get-categories'
|
||||
@@ -13,12 +13,13 @@ export const CategoriesPage = () => {
|
||||
)
|
||||
|
||||
DataTable.use(DT)
|
||||
const dataTable = loaderData?.categoriesData?.sort((a, b) => {
|
||||
if (a.sequence === null) return 1
|
||||
if (b.sequence === null) return -1
|
||||
return a.sequence - b.sequence
|
||||
})
|
||||
const dataColumns = [
|
||||
const dataTable =
|
||||
loaderData?.categoriesData?.sort((a, b) => {
|
||||
if (a.sequence === null) return 1
|
||||
if (b.sequence === null) return -1
|
||||
return a.sequence - b.sequence
|
||||
}) || []
|
||||
const dataColumns: ConfigColumns[] = [
|
||||
{
|
||||
title: 'No',
|
||||
render: (
|
||||
@@ -46,7 +47,7 @@ export const CategoriesPage = () => {
|
||||
data: 'id',
|
||||
},
|
||||
]
|
||||
const dataSlot = {
|
||||
const dataSlot: DataTableSlots = {
|
||||
1: (_value: unknown, _type: unknown, data: TCategoryResponse) => (
|
||||
<div>
|
||||
<div>{data.name}</div>
|
||||
@@ -64,7 +65,7 @@ export const CategoriesPage = () => {
|
||||
</Button>
|
||||
),
|
||||
}
|
||||
const dataOptions = {
|
||||
const dataOptions: Config = {
|
||||
paging: true,
|
||||
searching: true,
|
||||
ordering: true,
|
||||
|
||||
Reference in New Issue
Block a user