feat: implement getTags API and integrate with content creation form

This commit is contained in:
Ardeman
2025-03-05 17:57:52 +08:00
parent aca894729e
commit 1a1d8cc209
8 changed files with 203 additions and 40 deletions
+25
View File
@@ -0,0 +1,25 @@
import { z } from 'zod'
import { HttpServer, type THttpServer } from '~/libs/http-server'
const tagSchema = z.object({
data: z.array(
z.object({
id: z.string(),
code: z.string(),
name: z.string(),
}),
),
})
export type TTagSchema = z.infer<typeof tagSchema>
export const getTags = async (parameters?: THttpServer) => {
try {
const { data } = await HttpServer(parameters).get(`/api/tag`)
return tagSchema.parse(data)
} catch (error) {
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
return Promise.reject(error)
}
}