import { z } from 'zod';

export const createProductSchema = z.object({
    name: z.string().min(1, 'Name is required').max(255, 'Name must be less than 255 characters'),
    description: z.string().max(1000, 'Description must be less than 1000 characters').optional(),
    category_id: z.coerce.number().min(1, 'Category is required'),
    collection_id: z.coerce.number().min(1, 'Collection is required'),
    colour_id: z.coerce.number().min(1, 'Colour is required'),
    size_id: z.coerce.number().min(1, 'Size is required'),
    price: z.coerce.number().min(100, 'Price must be greater than 100'),
    hpp: z.coerce.number().min(100, 'HPP must be greater than 100'),
    unit_of_measure: z.string().min(1, 'Unit of measure is required').max(20, 'Unit of measure must be less than 20 characters'),
    is_raw_material: z.boolean().optional(),
    is_finished_good: z.boolean().optional(),
});

export type CreateProductFormValues = z.infer<typeof createProductSchema>;

export const updateProductSchema = z.object({
    name: z.string().min(1, 'Name is required').max(255, 'Name must be less than 255 characters'),
    description: z.string().max(1000, 'Description must be less than 1000 characters').optional(),
    category_id: z.coerce.number().min(1, 'Category is required'),
    collection_id: z.coerce.number().min(1, 'Collection is required'),
    colour_id: z.coerce.number().min(1, 'Colour is required'),
    size_id: z.coerce.number().min(1, 'Size is required'),
    price: z.coerce.number().min(100, 'Price must be greater than 100'),
    hpp: z.coerce.number().min(100, 'HPP must be greater than 100'),
    unit_of_measure: z.string().min(1, 'Unit of measure is required').max(20, 'Unit of measure must be less than 20 characters'),
    is_raw_material: z.boolean().optional(),
    is_finished_good: z.boolean().optional(),
});

export type UpdateProductFormValues = z.infer<typeof updateProductSchema>;
