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:
fredy.siswanto
2025-03-06 22:49:56 +07:00
parent b61235a3b5
commit d3dc3b5016
9 changed files with 70 additions and 171 deletions
+18 -12
View File
@@ -2,19 +2,26 @@ import { z } from 'zod'
import { HttpServer, type THttpServer } from '~/libs/http-server'
const authorSchema = z.object({
id: z.string(),
name: z.string(),
profile_picture: z.string(),
})
const categoriesCodeSchema = z.array(
z.object({
id: z.string(),
name: z.string(),
code: z.string(),
}),
)
const newsSchema = z.object({
data: z.array(
z.object({
id: z.string(),
title: z.string(),
content: z.string(),
categories: z.array(
z.object({
id: z.string(),
name: z.string(),
code: z.string(),
}),
),
categories: categoriesCodeSchema,
tags: z.array(
z.object({
id: z.string(),
@@ -29,15 +36,14 @@ const newsSchema = z.object({
live_at: z.string(),
created_at: z.string(),
updated_at: z.string(),
author: z.object({
id: z.string(),
name: z.string(),
profile_picture: z.string(),
}),
author: authorSchema,
}),
),
})
export type TAuthor = z.infer<typeof authorSchema>
export type TCategories = z.infer<typeof categoriesCodeSchema>
export const getNews = async (parameters: THttpServer) => {
try {
const { data } = await HttpServer(parameters).get(`/api/news`)