Merge remote-tracking branch 'origin/master' into feature/slicing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
import { HttpServer } from '~/libs/http-server'
|
||||
import type { TCategorySchema } from '~/pages/dashboard-category-create'
|
||||
import type { TCategorySchema } from '~/pages/form-category'
|
||||
|
||||
const categoryResponseSchema = z.object({
|
||||
data: z.object({
|
||||
@@ -17,14 +17,9 @@ type TParameters = {
|
||||
export const createCategoryRequest = async (parameters: TParameters) => {
|
||||
const { accessToken, payload } = parameters
|
||||
try {
|
||||
const { ...restPayload } = payload
|
||||
const transformedPayload = {
|
||||
...restPayload,
|
||||
}
|
||||
|
||||
const { data } = await HttpServer({ accessToken }).post(
|
||||
'/api/category/create',
|
||||
transformedPayload,
|
||||
payload,
|
||||
)
|
||||
return categoryResponseSchema.parse(data)
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
import { HttpServer } from '~/libs/http-server'
|
||||
import type { TContentSchema } from '~/pages/contents-form'
|
||||
import type { TContentSchema } from '~/pages/form-contents'
|
||||
|
||||
const newsResponseSchema = z.object({
|
||||
data: z.object({
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
import { HttpServer } from '~/libs/http-server'
|
||||
import type { TCategorySchema } from '~/pages/form-category'
|
||||
|
||||
const categoryResponseSchema = z.object({
|
||||
data: z.object({
|
||||
Message: z.string(),
|
||||
}),
|
||||
})
|
||||
|
||||
type TParameters = {
|
||||
accessToken: string
|
||||
payload: TCategorySchema
|
||||
}
|
||||
|
||||
export const updateCategoryRequest = async (parameters: TParameters) => {
|
||||
const { accessToken, payload } = parameters
|
||||
try {
|
||||
const { id, ...restPayload } = payload
|
||||
const { data } = await HttpServer({ accessToken }).put(
|
||||
`/api/category/${id}/update`,
|
||||
restPayload,
|
||||
)
|
||||
return categoryResponseSchema.parse(data)
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
||||
return Promise.reject(error)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
import { HttpServer } from '~/libs/http-server'
|
||||
import type { TContentSchema } from '~/pages/contents-form'
|
||||
import type { TContentSchema } from '~/pages/form-contents'
|
||||
|
||||
const newsResponseSchema = z.object({
|
||||
data: z.object({
|
||||
|
||||
@@ -6,6 +6,8 @@ export const categoryResponseSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
code: z.string(),
|
||||
sequence: z.number().nullable(),
|
||||
description: z.string().nullable(),
|
||||
})
|
||||
const categoriesResponseSchema = z.object({
|
||||
data: z.array(categoryResponseSchema),
|
||||
|
||||
Reference in New Issue
Block a user