diff --git a/app/pages/dashboard-categories/index.tsx b/app/pages/dashboard-categories/index.tsx new file mode 100644 index 0000000..2cd031f --- /dev/null +++ b/app/pages/dashboard-categories/index.tsx @@ -0,0 +1,68 @@ +import DataTable from 'datatables.net-dt' +import DT from 'datatables.net-react' +import { Link, useRouteLoaderData } from 'react-router' + +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 dataTable = loaderData?.dataCategories + + DataTable.use(DT) + const dataColumns = [ + { + title: 'No', + render: ( + data: unknown, + type: unknown, + row: unknown, + meta: { row: number }, + ) => { + return meta.row + 1 + }, + }, + { + title: 'Nama Kategori', + data: 'name', + }, + { + title: 'Code Katgeori', + data: 'code', + }, + ] + + const dataOptions = { + paging: true, + searching: true, + ordering: true, + info: true, + } + + return ( +
+ +
+
{/* TODO: Filter */}
+ +
+ + +
+ ) +} diff --git a/app/routes/_admin.lg-admin._dashboard.categories._index.tsx b/app/routes/_admin.lg-admin._dashboard.categories._index.tsx new file mode 100644 index 0000000..e2b970e --- /dev/null +++ b/app/routes/_admin.lg-admin._dashboard.categories._index.tsx @@ -0,0 +1,15 @@ +import { getCategories } from '~/apis/common/get-categories' +import { handleCookie } from '~/libs/cookies' +import { CategoriesPage } from '~/pages/dashboard-categories' + +import type { Route } from './+types/_admin.lg-admin._dashboard.categories._index' + +export const loader = async ({ request }: Route.LoaderArgs) => { + const { staffToken } = await handleCookie(request) + const { data: dataCategories } = await getCategories({ + accessToken: staffToken, + }) + return { dataCategories } +} +const DashboardCategoriesLayout = () => +export default DashboardCategoriesLayout