import { z } from "zod";

const IpLookupSchema = z
  .object({
    country: z.string(),
    region: z.string(),
    eu: z.string(),
    timezone: z.string(),
    city: z.string(),
  })
  .optional();

const ProfileSchema = z.object({
  birthplace: z
    .object({
      address: z.string(),
    })
    .optional(),
  name: z.string().optional(),
  birthdate: z.string(),
  gender: z.string(),
  age: z.number(),
  sign: z.string(),
});

const PartnerSchema = z
  .object({
    birthplace: z
      .object({
        address: z.string(),
      })
      .optional(),
    birthdate: z.string().optional(),
    gender: z.string().optional(),
    age: z.number().optional(),
    sign: z.string().optional(),
  })
  .optional();

export const UserSchema = z.object({
  ipLookup: IpLookupSchema,
  profile: ProfileSchema.optional(),
  partner: PartnerSchema,
  _id: z.string(),
  initialIp: z.string().optional(),
  sessionId: z.string().optional(),
  email: z.string(),
  locale: z.string(),
  timezone: z.string(),
  source: z.string(),
  sign: z.boolean(),
  signDate: z.string().nullable().optional(),
  password: z.string(),
  externalId: z.string().optional(),
  klaviyoId: z.string().nullable(),
  assistants: z.array(z.string()),
  createdAt: z.string().optional(),
  updatedAt: z.string(),
});

export const MeResponseSchema = z.object({
  user: UserSchema,
});

export type IUser = z.infer<typeof UserSchema>;
export type IMeResponse = z.infer<typeof MeResponseSchema>;
