import { z } from "zod";

export const tenantGuardianSchema = z.object({
  id: z.number(),
  tenantId: z.number(),
  fatherName: z.string(),
  fatherMobile: z.string()
  .regex(/^\d{10}$/, "Mobile number must be 10 digits")
  .or(z.literal(""))
  .optional(),
  fatherEmail: z.string().email().nullable(),
  fatherOccupation: z.string(),
  fatherAnnualIncome: z.number(),
  motherName: z.string(),
  motherMobile: z.string()
  .regex(/^\d{10}$/, "Mobile number must be 10 digits")
  .or(z.literal(""))
  .optional(),
  motherEmail: z.string().email().nullable(),
  localGuardianName: z.string(),
  localGuardianMobile: z.string()
  .regex(/^\d{10}$/, "Mobile number must be 10 digits")
  .or(z.literal(""))
  .optional(),
  localGuardianEmail: z.string().email().nullable(),
  localGuardianRelation: z.number(),
  createdAt: z.string().datetime(),
  updatedAt: z.string().datetime(),
});

type tenantGuardianTypes = z.infer<typeof tenantGuardianSchema>;

export const addTenantGuardianSchema = z.object({
  fatherName: tenantGuardianSchema.shape.fatherName.optional(),
  fatherMobile: tenantGuardianSchema.shape.fatherMobile.optional(),
  fatherOccupation: tenantGuardianSchema.shape.fatherOccupation.optional(),
  fatherAnnualIncome: tenantGuardianSchema.shape.fatherAnnualIncome.optional(),
  motherName: tenantGuardianSchema.shape.motherName.optional(),
  motherMobile: tenantGuardianSchema.shape.motherMobile.optional(),
  localGuardianName: tenantGuardianSchema.shape.localGuardianName.optional(),
  localGuardianMobile: tenantGuardianSchema.shape.localGuardianMobile.optional(),
  localGuardianRelation: tenantGuardianSchema.shape.localGuardianRelation.optional(),
});

export default tenantGuardianTypes;