import DT from 'datatables.net-dt' import DataTable from 'datatables.net-react' import { Link, useRouteLoaderData } from 'react-router' import type { TCategories } from '~/apis/admin/get-news' 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', data: 'id' }, { title: 'Tanggal Konten', data: 'live_at' }, { title: 'Nama Penulis', //ignore the error below // eslint-disable-next-line @typescript-eslint/no-explicit-any render: (data: any, type: any, row: any) => `${row.author.name}
ID: ${row.id.slice(0, 12)}`, }, { title: 'Judul', data: 'title' }, { title: 'Kategori', data: 'categories' }, { title: 'Tags', data: 'is_premium', render: (value: string) => { return value ? `Premium` : `Normal` }, }, { title: 'Action', data: 'slug', }, ] const dataSlot = { 1: (value: string) => { return formatDate(value) }, // 2: (value: TAuthor) => `${value}`, 4: (value: TCategories) => { const categories = value.map((item) => item.name).join(', ') return `${categories}` }, 6: (value: string | number) => { return ( ) }, } const dataOptions = { paging: true, searching: true, ordering: true, info: true, } return (
{/* TODO: Filter */}
) }