import { z } from "zod";

const agentBankAccountSchema = z.object({
  bank_id: z.string().trim().min(1, "Bank wajib dipilih"),
  account_number: z.string().trim().min(1, "Nomor rekening wajib diisi").max(100)
});

export const agentInputSchema = z.object({
  code: z.string().trim().max(20).optional().or(z.literal("")),
  name: z.string().trim().min(1, "Nama agent wajib diisi").max(150),
  identity_type: z.enum(["KTP", "SIM", "PASSPORT"]),
  identity_number: z.string().trim().min(1, "Nomor identitas wajib diisi").max(100),
  mobile_phone: z.string().trim().max(50).optional().or(z.literal("")),
  email: z.string().trim().email("Format email tidak valid").max(150).optional().or(z.literal("")),
  address: z.string().trim().max(2000).optional().or(z.literal("")),
  notes: z.string().trim().max(2000).optional().or(z.literal("")),
  join_date: z.string().trim().min(1, "Join date wajib diisi"),
  profit_share_scheme_id: z.string().trim().min(1, "Skema bagi hasil wajib dipilih"),
  profit_share_balance: z.coerce.number().min(0, "Saldo bagi hasil tidak boleh negatif"),
  capital_balance: z.coerce.number().min(0, "Saldo modal tidak boleh negatif"),
  bank_accounts: z.array(agentBankAccountSchema).min(1, "Minimal satu rekening bank wajib diisi")
});
