46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
export type InventoryTable = z.infer<typeof product>;
|
|
export type EditInventory = z.infer<typeof editInventory>;
|
|
|
|
export const product = z.object({
|
|
id: z.number().optional(),
|
|
title: z.string(),
|
|
description: z.string(),
|
|
// category: z.string(),
|
|
stock: z.number(),
|
|
price: z.string(),
|
|
urlImg: z.string(),
|
|
userId: z.number().optional(),
|
|
});
|
|
|
|
export const editInventory = z.object({
|
|
id: z.number().optional(),
|
|
title: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }),
|
|
description: z.string().min(10, { message: "Debe de tener 10 o más caracteres" }),
|
|
stock: z.string().transform(val => Number(val)),
|
|
price: z.string(),
|
|
urlImg: z.string(),
|
|
userId: z.number().optional(),
|
|
})
|
|
|
|
|
|
export const ApiResponseSchema = z.object({
|
|
message: z.string(),
|
|
data: z.array(product),
|
|
meta: z.object({
|
|
page: z.number(),
|
|
limit: z.number(),
|
|
totalCount: z.number(),
|
|
totalPages: z.number(),
|
|
hasNextPage: z.boolean(),
|
|
hasPreviousPage: z.boolean(),
|
|
nextPage: z.number().nullable(),
|
|
previousPage: z.number().nullable(),
|
|
}),
|
|
})
|
|
|
|
export const productMutate = z.object({
|
|
message: z.string(),
|
|
data: product,
|
|
}) |