feat: update dashboard contents to render author details with improved formatting

This commit is contained in:
fredy.siswanto 2025-03-06 23:32:15 +07:00
parent d3dc3b5016
commit 529ac6b590

View File

@ -2,7 +2,7 @@ import DT from 'datatables.net-dt'
import DataTable from 'datatables.net-react' import DataTable from 'datatables.net-react'
import { Link, useRouteLoaderData } from 'react-router' import { Link, useRouteLoaderData } from 'react-router'
import type { TAuthor, TCategories } from '~/apis/admin/get-news' import type { TCategories } from '~/apis/admin/get-news'
import { Button } from '~/components/ui/button' import { Button } from '~/components/ui/button'
import { UiTable } from '~/components/ui/table' import { UiTable } from '~/components/ui/table'
import { TitleDashboard } from '~/components/ui/title-dashboard' import { TitleDashboard } from '~/components/ui/title-dashboard'
@ -20,7 +20,13 @@ export const ContentsPage = () => {
const dataColumns = [ const dataColumns = [
{ title: 'No', data: 'id' }, { title: 'No', data: 'id' },
{ title: 'Tanggal Konten', data: 'live_at' }, { title: 'Tanggal Konten', data: 'live_at' },
{ title: 'Nama Penulis', data: 'author' }, {
title: 'Nama Penulis',
//ignore the error below
// eslint-disable-next-line @typescript-eslint/no-explicit-any
render: (data: any, type: any, row: any) =>
`<span>${row.author.name}</span> <br> <span class="text-sm text-[#7C7C7C]">ID: ${row.id.slice(0, 12)}</span>`,
},
{ title: 'Judul', data: 'title' }, { title: 'Judul', data: 'title' },
{ title: 'Kategori', data: 'categories' }, { title: 'Kategori', data: 'categories' },
{ {
@ -41,7 +47,7 @@ export const ContentsPage = () => {
1: (value: string) => { 1: (value: string) => {
return formatDate(value) return formatDate(value)
}, },
2: (value: TAuthor) => `${value.name}`, // 2: (value: TAuthor) => `${value}`,
4: (value: TCategories) => { 4: (value: TCategories) => {
const categories = value.map((item) => item.name).join(', ') const categories = value.map((item) => item.name).join(', ')
return `${categories}` return `${categories}`