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:
+18
-12
@@ -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`)
|
||||
|
||||
Reference in New Issue
Block a user