Crear-editar productos, depuracion de archivos users
This commit is contained in:
@@ -1,54 +1,31 @@
|
||||
import { title } from 'process';
|
||||
import { z } from 'zod';
|
||||
|
||||
export type InventoryTable = z.infer<typeof product>;
|
||||
export type CreateUser = z.infer<typeof createUser>;
|
||||
export type UpdateUser = z.infer<typeof updateUser>;
|
||||
export type EditInventory = z.infer<typeof editInventory>;
|
||||
|
||||
export const product = z.object({
|
||||
id: z.number().optional(),
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
// price: z.number(),
|
||||
// quantity: z.number(),
|
||||
// category: z.string(),
|
||||
// image: z.string().optional(),
|
||||
stock: z.number(),
|
||||
price: z.string(),
|
||||
urlImg: z.string(),
|
||||
userId: z.number().optional(),
|
||||
});
|
||||
|
||||
export const createUser = z.object({
|
||||
export const editInventory = z.object({
|
||||
id: z.number().optional(),
|
||||
username: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }),
|
||||
password: z.string().min(8, { message: "Debe de tener 8 o más caracteres" }),
|
||||
email: z.string().email({ message: "Correo no válido" }),
|
||||
fullname: z.string(),
|
||||
phone: z.string(),
|
||||
confirmPassword: z.string(),
|
||||
role: z.number()
|
||||
})
|
||||
.refine((data) => data.password === data.confirmPassword, {
|
||||
message: 'La contraseña no coincide',
|
||||
path: ['confirmPassword'],
|
||||
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 updateUser = z.object({
|
||||
id: z.number(),
|
||||
username: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }).or(z.literal('')),
|
||||
password: z.string().min(6, { message: "Debe de tener 6 o más caracteres" }).or(z.literal('')),
|
||||
email: z.string().email({ message: "Correo no válido" }).or(z.literal('')),
|
||||
fullname: z.string().optional(),
|
||||
phone: z.string().optional(),
|
||||
role: z.number().optional(),
|
||||
isActive: z.boolean().optional(),
|
||||
state: z.number().optional().nullable(),
|
||||
municipality: z.number().optional().nullable(),
|
||||
parish: z.number().optional().nullable(),
|
||||
})
|
||||
|
||||
export const surveysApiResponseSchema = z.object({
|
||||
export const ApiResponseSchema = z.object({
|
||||
message: z.string(),
|
||||
data: z.array(product),
|
||||
meta: z.object({
|
||||
|
||||
Reference in New Issue
Block a user