import { z } from "zod";
import { propertiesSchema } from "./property.schema";

export const staffsSchema = z.object({
  id: z.number(),
  clientId: z.number(),
  role: z.number(),
  isSuperAdmin: z.number(),
  name: z
    .string()
    .min(3, "Name should be at least 3 characters")
    .max(150, "Name shouldn't be more than 150 characters"),
  mobile: z
    .string()
    .min(10, "Mobile number should be 10-digit only.")
    .max(10, "Mobile number should be 10-digit only."),
  regId: z.string(),
  gender: z.number(),
  address: z.string(),
  email: z.string(),
  salary: z.number(),
  status: z.number(),
  device: z.number(),
  currentAppVersion: z.number(),
  permissions: z.number(),
  isVerified: z.number(),
  aadharNumber: z.string(),
  fatherName: z.string(),
  verificationId: z.string(),
  referenceId: z.number(),
  dob: z.string().date(),
  reportingLongitude: z.string(),
  reportingLatitude: z.string(),
  commission: z.number(),
  commissionType: z.number(),
  createdAt: z.string().datetime(),
  updatedAt: z.string().datetime(),
});

type staffsTypes = z.infer<typeof staffsSchema>;

export const addStaffSchema = z.object({
  name: staffsSchema.shape.name,
  role: staffsSchema.shape.role,
  mobile: staffsSchema.shape.mobile,
  gender: staffsSchema.shape.gender,
  salary: staffsSchema.shape.salary.optional(),
  properties: z.array(z.number()),
});

export const toggleStaffSchema = z.object({
  toggleValue: z.number(),
  propId: propertiesSchema.shape.id,
  staffId: staffsSchema.shape.id,
});

export const editSchema = z.object({
  staffId: staffsSchema.shape.id,
  name: staffsSchema.shape.name,
  role: staffsSchema.shape.role,
  gender: staffsSchema.shape.gender,
  salary: staffsSchema.shape.salary.optional(),
});

export const toggleStatusSchema = z.object({
  staffId: staffsSchema.shape.id,
});
export const updateRegIdSchem = z.object({
  regId: staffsSchema.shape.regId,
});

export default staffsTypes;
