feat: add tags management page and update admin menu
This commit is contained in:
parent
c46e8fc11b
commit
c91fe48eb9
@ -1,4 +1,4 @@
|
||||
import { ClipboardDocumentCheckIcon } from '@heroicons/react/20/solid'
|
||||
import { ClipboardDocumentCheckIcon, TagIcon } from '@heroicons/react/20/solid'
|
||||
import type { SVGProps } from 'react'
|
||||
|
||||
import { ChartIcon } from '~/components/icons/chart'
|
||||
@ -56,6 +56,11 @@ export const MENU: TMenu[] = [
|
||||
url: '/lg-admin/categories',
|
||||
icon: ClipboardDocumentCheckIcon,
|
||||
},
|
||||
{
|
||||
title: 'Tag',
|
||||
url: '/lg-admin/tags',
|
||||
icon: TagIcon,
|
||||
},
|
||||
{
|
||||
title: 'Pengaturan',
|
||||
url: '/lg-admin/settings',
|
||||
|
||||
87
app/pages/dashboard-tags/index.tsx
Normal file
87
app/pages/dashboard-tags/index.tsx
Normal file
@ -0,0 +1,87 @@
|
||||
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.tags._index'
|
||||
|
||||
export const TagsPage = () => {
|
||||
const loaderData = useRouteLoaderData<typeof loader>(
|
||||
'routes/_admin.lg-admin._dashboard.tags._index',
|
||||
)
|
||||
const tagsData = loaderData?.tagsData
|
||||
const dataTable = tagsData
|
||||
|
||||
DataTable.use(DT)
|
||||
const dataColumns = [
|
||||
{
|
||||
title: 'No',
|
||||
render: (
|
||||
data: unknown,
|
||||
type: unknown,
|
||||
row: unknown,
|
||||
meta: { row: number },
|
||||
) => {
|
||||
return meta.row + 1
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Tag',
|
||||
data: 'name',
|
||||
},
|
||||
{
|
||||
title: 'Kode',
|
||||
data: 'code',
|
||||
},
|
||||
{
|
||||
title: 'Action',
|
||||
data: 'id',
|
||||
},
|
||||
]
|
||||
|
||||
const dataOptions = {
|
||||
paging: true,
|
||||
searching: true,
|
||||
ordering: true,
|
||||
info: true,
|
||||
}
|
||||
|
||||
const dataSlot = {
|
||||
3: (value: string) => (
|
||||
<Button
|
||||
as="a"
|
||||
href={`/lg-admin/tags/update/${value}`}
|
||||
className="text-md rounded-md"
|
||||
size="sm"
|
||||
>
|
||||
Update Tag
|
||||
</Button>
|
||||
),
|
||||
}
|
||||
return (
|
||||
<div className="relative">
|
||||
<TitleDashboard title="Tags" />
|
||||
<div className="mb-8 flex items-end justify-between gap-5">
|
||||
<div className="flex-1">{/* TODO: Filter */}</div>
|
||||
<Button
|
||||
as={Link}
|
||||
to="/lg-admin/tags/create"
|
||||
className="text-md h-[42px] rounded-md"
|
||||
size="lg"
|
||||
>
|
||||
Buat Tags
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<UiTable
|
||||
data={dataTable}
|
||||
columns={dataColumns}
|
||||
options={dataOptions}
|
||||
slots={dataSlot}
|
||||
title="Daftar Katgeori"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
15
app/routes/_admin.lg-admin._dashboard.tags._index.tsx
Normal file
15
app/routes/_admin.lg-admin._dashboard.tags._index.tsx
Normal file
@ -0,0 +1,15 @@
|
||||
import { getTags } from '~/apis/common/get-tags'
|
||||
import { handleCookie } from '~/libs/cookies'
|
||||
import { TagsPage } from '~/pages/dashboard-tags'
|
||||
|
||||
import type { Route } from './+types/_admin.lg-admin._dashboard.tags._index'
|
||||
export const loader = async ({ request }: Route.LoaderArgs) => {
|
||||
const { staffToken } = await handleCookie(request)
|
||||
const { data: tagsData } = await getTags({
|
||||
accessToken: staffToken,
|
||||
})
|
||||
return { tagsData }
|
||||
}
|
||||
|
||||
const DashboardTagsIndexLayout = () => <TagsPage />
|
||||
export default DashboardTagsIndexLayout
|
||||
Loading…
x
Reference in New Issue
Block a user