import DT from 'datatables.net-dt' import DataTable from 'datatables.net-react' import { Link, useRouteLoaderData } from 'react-router' import type { TNewsSchema } from '~/apis/admin/get-news' import type { TCategorySchema } from '~/apis/common/get-categories' import type { TTagSchema } from '~/apis/common/get-tags' 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.contents' import { formatDate } from '~/utils/formatter' export const ContentsPage = () => { const loaderData = useRouteLoaderData( 'routes/_admin.lg-admin._dashboard.contents', ) const newsData = loaderData?.newsData DataTable.use(DT) const dataTable = newsData const dataColumns = [ { title: 'No', render: ( data: unknown, type: unknown, row: unknown, meta: { row: number }, ) => { return meta.row + 1 }, }, { title: 'Tanggal Konten', data: 'live_at', }, { title: 'Nama Penulis', }, { title: 'Judul', data: 'title' }, { title: 'Kategori', data: 'categories', }, { title: 'Tag', data: 'tags' }, { title: 'Premium', data: 'is_premium', }, { title: 'Action', data: 'slug', }, ] const dataSlot = { 1: (value: string) => formatDate(value), 2: (_value: unknown, _type: unknown, data: TNewsSchema) => (
{data.author.name}
ID: {data.id.slice(0, 8)}
), 4: (value: TCategorySchema[]) => value.map((item) => item.name).join(', '), 5: (value: TTagSchema[]) => value.map((item) => item.name).join(', '), 6: (value: string) => value ? (
Premium
) : (
Normal
), 7: (value: string) => ( ), } const dataOptions = { paging: true, searching: true, ordering: true, info: true, } return (
{/* TODO: Filter */}
) }