feat: update dashboard to render author details and improve row numbering

This commit is contained in:
fredy.siswanto 2025-03-06 23:49:12 +07:00
parent 529ac6b590
commit 661437a2d3

View File

@ -18,14 +18,19 @@ export const ContentsPage = () => {
DataTable.use(DT) DataTable.use(DT)
const dataTable = newsData const dataTable = newsData
const dataColumns = [ const dataColumns = [
{ title: 'No', data: 'id' }, {
title: 'No',
data: undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
render: function (data: any, type: any, row: any, meta: any) {
return meta.row + 1
},
},
{ title: 'Tanggal Konten', data: 'live_at' }, { title: 'Tanggal Konten', data: 'live_at' },
{ {
title: 'Nama Penulis', title: 'Nama Penulis',
//ignore the error below
// eslint-disable-next-line @typescript-eslint/no-explicit-any data: 'author',
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' },
@ -47,7 +52,9 @@ export const ContentsPage = () => {
1: (value: string) => { 1: (value: string) => {
return formatDate(value) return formatDate(value)
}, },
// 2: (value: TAuthor) => `${value}`, // eslint-disable-next-line @typescript-eslint/no-explicit-any
2: (value: any, type: any, data: any) =>
`<span>${value.name}</span> <br> <span class="text-sm text-[#7C7C7C]">ID: ${data.id.slice(0, 12)}</span>`,
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}`