import { z } from "zod";

export const customerSchema = z.object({
  name: z.string().trim().min(2, "En az 2 karakter").max(255),
  email: z
    .union([z.string().email("Geçerli bir email girin."), z.literal("")])
    .optional()
    .transform((v) => v || undefined),
  phone: z
    .string()
    .trim()
    .max(30)
    .optional()
    .transform((v) => v || undefined),
  type: z.enum(["alici", "kiraci", "yatirimci"]),
  stage: z
    .enum(["ilk_temas", "aktif_arama", "teklif", "sozlesme", "kapandi"])
    .default("ilk_temas"),
  source: z
    .enum(["referans", "ilan", "instagram", "sahibinden", "diger"])
    .optional()
    .or(z.literal(""))
    .transform((v) => v || undefined),
  nextFollowUpDate: z
    .string()
    .optional()
    .transform((v) => v || undefined),
  assigneeId: z
    .string()
    .max(36)
    .optional()
    .transform((v) => v || undefined),
  notes: z
    .string()
    .trim()
    .max(2000)
    .optional()
    .transform((v) => v || undefined),
});

export type CustomerFormValues = z.infer<typeof customerSchema>;
