import { z } from "zod"

export const createItemSchema = z.object({
  name: z.string().min(1, { message: "Name is required" }),
  categoryId: z.string().min(1, { message: "Category is required" }),
  stock: z.coerce
    .number()
    .int()
    .nonnegative()
    .min(0, { message: "Stock is required" }),
})

export type CreateItemFormType = z.infer<typeof createItemSchema>

export const updateItemSchema = createItemSchema.extend({
  id: z.string().min(1, { message: "Item is required" }),
})

export type UpdateItemFormType = z.infer<typeof updateItemSchema>

export const getItemByIdSchema = z.object({
  id: z.string().min(1, { message: "Item is required" }),
})

export type GetItemByIdFormType = z.infer<typeof getItemByIdSchema>
