import { user } from '@/feactures/auth/schemas/register'; import { all } from 'axios'; import { z } from 'zod'; export type InventoryTable = z.infer; export type EditInventory = z.infer; //output export type formDataInput = z.input; export type ProductApiResponseSchema = z.infer; export type allProducts = z.infer; export const product = z.object({ id: z.number().optional(), title: z.string(), description: z.string(), address: z.string(), // category: z.string(), stock: z.number(), price: z.string(), urlImg: z.string(), status: z.string(), userId: z.number().optional() }) export const productDetails = product.extend({ fullname: z.string(), phone: z.string().nullable(), email: z.string().email().nullable() }) 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)).pipe(z.number( { invalid_type_error: 'El stock debe ser un número' }).min(0, { message: "El stock debe ser mayor a 0" }) ), address: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }), price: z.string(), urlImg: z.string(), status: z.string().min(1, { message: "Debe de seleccionar un valor" }), userId: z.number().optional(), }) // export const productDetails = z.object({ // id: z.number().optional(), // title: z.string().min(5), // description: z.string().min(10), // stock: z.number(), // price: z.string(), // address: z.string(), // urlImg: z.string(), // userId: z.number(), // }) 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 productApiResponseSchema = z.object({ message: z.string(), data: z.array(productDetails), 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, }) export const getProduct = z.object({ message: z.string(), data: productDetails, })