import { z } from "zod";
import { otpsSchema } from "./otp.schema";
import { tenantsSchema } from "./tenant.schema";
import { moveOutSchema } from "./moveOut.schema";
import { occupanciesSchema } from "./occupancy.schema";

export const clientsSchema = z.object({
  id: z.number(),
  gId: z.number(),
  parentId: z.number().nullable(),
  name: z
    .string()
    .min(3, "Name should be atleast 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."),
  propertyCount: z.number(),
  panNumber: z.string(),
  city: z.string(),
  regId: z.string(),
  status: z.number(),
  device: z.number(),
  currentAppVersion: z.number(),
  holdOutBalance: z.number(),
  payuMid: z.string(),
  payuKey: z.string(),
  logo: z.string(),
  businessEmail: z.string(),
  businessName: z.string(),
  businessAddress: z.string(),
  gstNo: z.string(),
  ownershipPercentage: z.number(),
  createdAt: z.string().datetime(),
  updatedAt: z.string().datetime(),
});

type clientsTypes = z.infer<typeof clientsSchema>;

export const loginSchema = z.object({
  mobile: clientsSchema.shape.mobile,
});

export const otpVerificationSchema = z.object({
  otp: otpsSchema.shape.otp,
  mobile: clientsSchema.shape.mobile,
});

export const onBoardingSchema = z.object({
  name: clientsSchema.shape.name,
  city: clientsSchema.shape.city,
  propertyCount: clientsSchema.shape.propertyCount,
});

export const initiateRemoveTenantSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  moveOutDate: z.string().date(),
  isSecurityAdjustment: z.boolean(),
  // adjustmentDuesList: z.array(
  //   z.object({ id: z.number(), isTemp: z.boolean() })
  // ),
});

export const cancelRemoveTenantSchema = z.object({
  tenantId: tenantsSchema.shape.id,
});

export const removeTenantNowSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  electricityReading: moveOutSchema.shape.electricityReading,
});

export const extendStaySchema = z.object({
  tenantId: tenantsSchema.shape.id,
  extendedDays: z.number().gt(0).lt(30),
  duesList: z.array(z.object({ amount: z.number(), type: z.number() })),
});

export const UpdateRegIdSchema = z.object({
  regId: z.string(),
});

export const RenewRentAgreementSchema = z.object({
  occupancyId: occupanciesSchema.shape.id,
  noticePeriod: occupanciesSchema.shape.noticePeriod,
  lockInPeriod: occupanciesSchema.shape.lockInPeriod,
  rent: occupanciesSchema.shape.rent,
  agreementPeriod: occupanciesSchema.shape.agreementPeriod,
  agreementStartDate: occupanciesSchema.shape.agreementStartDate,
});

export const EditRentSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  rent: occupanciesSchema.shape.rent,
});

export const EditTenantNameSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  name: tenantsSchema.shape.name,
});

export const EditSecuritySchema = z.object({
  tenantId: tenantsSchema.shape.id,
  security: occupanciesSchema.shape.security,
});

export const EditMoveInDateSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  moveInDate: occupanciesSchema.shape.agreementStartDate,
});

export const EditMoveOutDateSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  moveOutDate: occupanciesSchema.shape.agreementStartDate,
});

export const EditAgreementPeriodSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  agreementPeriod: occupanciesSchema.shape.agreementPeriod,
});

export const EditFineSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  fine: occupanciesSchema.shape.fine,
});

export const EditGracePeriodSchema = z.object({
  tenantId: tenantsSchema.shape.id,
  gracePeriod: occupanciesSchema.shape.gracePeriod,
});

export default clientsTypes;
