feat: migrate tag creation and update functionality to new form structure

This commit is contained in:
fredy.siswanto
2025-03-08 06:18:13 +07:00
parent b7f51ea46f
commit fc67298a85
7 changed files with 150 additions and 20 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
import { z } from 'zod'
import { HttpServer } from '~/libs/http-server'
import type { TTagSchema } from '~/pages/dashboard-tags-create'
import type { TTagSchema } from '~/pages/form-tag'
const tagsResponseSchema = z.object({
data: z.object({
+30
View File
@@ -0,0 +1,30 @@
import { z } from 'zod'
import { HttpServer } from '~/libs/http-server'
import type { TTagSchema } from '~/pages/form-tag'
const tagResponseSchema = z.object({
data: z.object({
Message: z.string(),
}),
})
type TParameters = {
accessToken: string
payload: TTagSchema
}
export const updateTagRequest = async (parameters: TParameters) => {
const { accessToken, payload } = parameters
try {
const { id, ...restPayload } = payload
const { data } = await HttpServer({ accessToken }).put(
`/api/tag/${id}/update`,
restPayload,
)
return tagResponseSchema.parse(data)
} catch (error) {
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
return Promise.reject(error)
}
}