import { z } from "zod";

export const flatSchema = z.object({
  id: z.number(),
  name: z.string(),
  clientId: z.number(),
  propId: z.number(),
  floor: z.string(),
  status: z.number(),
  gender: z.number(),
  wifiPassword: z.string(),
  createdAt: z.string().datetime(),
  updatedAt: z.string().datetime(),
});

type flatTypes = z.infer<typeof flatSchema>;

export const AddFlatsSchema = z.object({
  propId: z.number().gt(0, { message: "Property Id must be greater than 0" }),
  flats: z.array(
    z.object({
      count: z.number().gt(0, { message: "Flat Count must be greater than 0" }),
      floorNumber: flatSchema.shape.floor,
    })
  ),
});

export const EditNameSchema = z.object({
  flatId: z.number().gt(0, { message: "Flat Id must be greater than 0" }),
  newName: z.string(),
});

export const ActivateSchema = z.object({
  flatId: z.number().gt(0),
});

export const DeactivateSchema = z.object({
  flatId: z.number().gt(0),
});

export const AddFlatSchema = z.object({
  propId: z.number().gt(0, { message: "Property Id must be greater than 0" }),
  flatName: z.string(),
});

export default flatTypes;
