import { m } from '@/paraglide/messages';
import z from 'zod';

export const baseBox = z.object({
  id: z.string().nonempty(m.boxes_page_message_box_not_found()),
});

export const boxListSchema = z.object({
  page: z.coerce.number().min(1).default(1),
  limit: z.coerce.number().min(10).max(100).default(10),
  keyword: z.string().optional(),
});

export const createBoxSchema = z.object({
  name: z
    .string()
    .nonempty(m.common_is_required({ field: m.boxes_page_form_name() })),
  description: z
    .string()
    .nonempty(m.common_is_required({ field: m.boxes_page_form_description() })),
  color: z
    .string()
    .nonempty(m.common_is_required({ field: m.boxes_page_form_color() })),
  houseId: z.string().nonempty(m.houses_page_message_house_not_found()),
  tags: z.array(z.string()),
});

export const updateBoxSchema = baseBox.and(
  createBoxSchema.omit({ houseId: true }),
);

export type updateBoxSchemaType = z.input<typeof updateBoxSchema>;
