Compare commits
No commits in common. "72e2dac328563cff62f100fe851f8c3b7237aabe" and "aa660f4f5fd8cb909044b97c45b8b51d0381bb52" have entirely different histories.
72e2dac328
...
aa660f4f5f
@ -1,7 +1,7 @@
|
|||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { HttpServer } from '~/libs/http-server'
|
import { HttpServer } from '~/libs/http-server'
|
||||||
import type { TCategorySchema } from '~/pages/dashboard-category-create'
|
import type { TCategorySchema } from '~/pages/category-create'
|
||||||
|
|
||||||
const categoryResponseSchema = z.object({
|
const categoryResponseSchema = z.object({
|
||||||
data: z.object({
|
data: z.object({
|
||||||
|
|||||||
@ -1,85 +0,0 @@
|
|||||||
import DT from 'datatables.net-dt'
|
|
||||||
import DataTable 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<typeof loader>(
|
|
||||||
'routes/_admin.lg-admin._dashboard.categories._index',
|
|
||||||
)
|
|
||||||
const categoriesData = loaderData?.dataCategories
|
|
||||||
|
|
||||||
DataTable.use(DT)
|
|
||||||
const dataTable = categoriesData
|
|
||||||
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',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Action',
|
|
||||||
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,
|
|
||||||
ordering: true,
|
|
||||||
info: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="relative">
|
|
||||||
<TitleDashboard title="Kategori" />
|
|
||||||
<div className="mb-8 flex items-end justify-between gap-5">
|
|
||||||
<div className="flex-1">{/* TODO: Filter */}</div>
|
|
||||||
<Button
|
|
||||||
as={Link}
|
|
||||||
to="/lg-admin/categories/create"
|
|
||||||
className="text-md h-[42px] rounded-md"
|
|
||||||
size="lg"
|
|
||||||
>
|
|
||||||
Buat Kategori
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<UiTable
|
|
||||||
data={dataTable}
|
|
||||||
columns={dataColumns}
|
|
||||||
options={dataOptions}
|
|
||||||
slots={dataSlot}
|
|
||||||
title="Daftar Katgeori"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
|
|
||||||
export const UpdateCategoryPage = () => {
|
|
||||||
return <div>UpdateCategoryPage</div>
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
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 DashboardCategoriesIndexLayout = () => <CategoriesPage />
|
|
||||||
export default DashboardCategoriesIndexLayout
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
import { CreateCategoryPage } from '~/pages/dashboard-category-create'
|
|
||||||
|
|
||||||
const DashboardCategoriesCreateLayout = () => <CreateCategoryPage />
|
|
||||||
export default DashboardCategoriesCreateLayout
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
import { UpdateCategoryPage } from '~/pages/dashboard-category-update'
|
|
||||||
|
|
||||||
const DashboardCategoriesUpdateLayout = () => <UpdateCategoryPage />
|
|
||||||
export default DashboardCategoriesUpdateLayout
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
import { CreateCategoryPage } from '~/pages/category-create'
|
||||||
|
|
||||||
|
const DashboardCategoryLayout = () => <CreateCategoryPage />
|
||||||
|
export default DashboardCategoryLayout
|
||||||
@ -1,34 +1,2 @@
|
|||||||
import { Button } from '~/components/ui/button'
|
const DashboardSettingsLayout = () => <div>Settings Page</div>
|
||||||
|
|
||||||
const DashboardSettingsLayout = () => (
|
|
||||||
<div>
|
|
||||||
{/* action sementara kategory */}
|
|
||||||
<div className="flex space-x-2">
|
|
||||||
<Button
|
|
||||||
as="a"
|
|
||||||
href={`/lg-admin/categories`}
|
|
||||||
className="text-md rounded-md"
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
List Kategory
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
as="a"
|
|
||||||
href={`/lg-admin/category/create`}
|
|
||||||
className="text-md rounded-md"
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
Create Category
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
as="a"
|
|
||||||
href={`/lg-admin/category/update/1`}
|
|
||||||
className="text-md rounded-md"
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
Update Category
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
export default DashboardSettingsLayout
|
export default DashboardSettingsLayout
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { handleCookie } from '~/libs/cookies'
|
|||||||
import {
|
import {
|
||||||
createCategorySchema,
|
createCategorySchema,
|
||||||
type TCategorySchema,
|
type TCategorySchema,
|
||||||
} from '~/pages/dashboard-category-create'
|
} from '~/pages/category-create'
|
||||||
|
|
||||||
import type { Route } from './+types/actions.register'
|
import type { Route } from './+types/actions.register'
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user