feat: enhance news API schema with author and categories details,
desc: update dashboard to display author names, and improve pagination button styles
This commit is contained in:
@@ -2,11 +2,11 @@ import DT from 'datatables.net-dt'
|
||||
import DataTable from 'datatables.net-react'
|
||||
import { Link, useRouteLoaderData } from 'react-router'
|
||||
|
||||
import type { TAuthor, 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 type { TCategory } from '~/types/news'
|
||||
import { formatDate } from '~/utils/formatter'
|
||||
|
||||
export const ContentsPage = () => {
|
||||
@@ -19,8 +19,8 @@ export const ContentsPage = () => {
|
||||
const dataTable = newsData
|
||||
const dataColumns = [
|
||||
{ title: 'No', data: 'id' },
|
||||
{ title: 'Tanggal Konten', data: 'created_at' },
|
||||
{ title: 'Nama Penulis', data: 'author_id' },
|
||||
{ title: 'Tanggal Konten', data: 'live_at' },
|
||||
{ title: 'Nama Penulis', data: 'author' },
|
||||
{ title: 'Judul', data: 'title' },
|
||||
{ title: 'Kategori', data: 'categories' },
|
||||
{
|
||||
@@ -34,18 +34,17 @@ export const ContentsPage = () => {
|
||||
},
|
||||
{
|
||||
title: 'Action',
|
||||
data: 'id',
|
||||
data: 'slug',
|
||||
},
|
||||
]
|
||||
const dataSlot = {
|
||||
1: (value: string) => {
|
||||
return formatDate(value)
|
||||
},
|
||||
|
||||
4: (value: TCategory[]) => {
|
||||
return value.map((item: { name: string }) => {
|
||||
return `${item.name}`
|
||||
})
|
||||
2: (value: TAuthor) => `${value.name}`,
|
||||
4: (value: TCategories) => {
|
||||
const categories = value.map((item) => item.name).join(', ')
|
||||
return `${categories}`
|
||||
},
|
||||
6: (value: string | number) => {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user