Merge remote-tracking branch 'origin/master' into feature/slicing

This commit is contained in:
fredy.siswanto
2025-03-07 13:19:50 +07:00
5 changed files with 61 additions and 15 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ const authorSchema = z.object({
name: z.string(),
profile_picture: z.string(),
})
const newsResponseSchema = z.object({
export const newsResponseSchema = z.object({
id: z.string(),
title: z.string(),
content: z.string(),
+23
View File
@@ -0,0 +1,23 @@
import { z } from 'zod'
import { newsResponseSchema } from '~/apis/admin/get-news'
import { HttpServer, type THttpServer } from '~/libs/http-server'
const dataResponseSchema = z.object({
data: z.object(newsResponseSchema.shape),
})
type TParameters = {
slug: string
} & THttpServer
export const getNewsBySlug = async (parameters: TParameters) => {
const { slug, accessToken } = parameters
try {
const { data } = await HttpServer({ accessToken }).get(`/api/news/${slug}`)
return dataResponseSchema.parse(data)
} catch (error) {
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
return Promise.reject(error)
}
}