feat: refactor category routes and components for improved organization and clarity

This commit is contained in:
Ardeman
2025-03-07 14:58:35 +08:00
parent 097268647a
commit 72e2dac328
7 changed files with 29 additions and 28 deletions
+18 -18
View File
@@ -1,5 +1,5 @@
import DataTable from 'datatables.net-dt'
import DT from 'datatables.net-react'
import DT from 'datatables.net-dt'
import DataTable from 'datatables.net-react'
import { Link, useRouteLoaderData } from 'react-router'
import { Button } from '~/components/ui/button'
@@ -10,9 +10,10 @@ export const CategoriesPage = () => {
const loaderData = useRouteLoaderData<typeof loader>(
'routes/_admin.lg-admin._dashboard.categories._index',
)
const dataTable = loaderData?.dataCategories
const categoriesData = loaderData?.dataCategories
DataTable.use(DT)
const dataTable = categoriesData
const dataColumns = [
{
title: 'No',
@@ -38,7 +39,18 @@ export const CategoriesPage = () => {
data: 'id',
},
]
const dataSlot = {
3: (value: string) => (
<Button
as="a"
href={`/lg-admin/categories/update/${value}`}
className="text-md rounded-md"
size="sm"
>
Update Kategori
</Button>
),
}
const dataOptions = {
paging: true,
searching: true,
@@ -46,18 +58,6 @@ export const CategoriesPage = () => {
info: true,
}
const dataSlot = {
3: (value: string) => (
<Button
as="a"
href={`/lg-admin/category/update/${value}`}
className="text-md rounded-md"
size="sm"
>
Lihat Detail
</Button>
),
}
return (
<div className="relative">
<TitleDashboard title="Kategori" />
@@ -65,11 +65,11 @@ export const CategoriesPage = () => {
<div className="flex-1">{/* TODO: Filter */}</div>
<Button
as={Link}
to="/lg-admin/category/create"
to="/lg-admin/categories/create"
className="text-md h-[42px] rounded-md"
size="lg"
>
Create New
Buat Kategori
</Button>
</div>