import { z } from "zod";
import { booleanFromForm, numberFromForm } from "./common";

export const CreateBankAccountSchema = z.object({
  account_name: z.string().max(255).nullish(),
  bank_name: z.string().max(255).nullish(),
  account_number: z.string().max(255).nullish(),
  iban: z.string().max(255).nullish(),
  bic: z.string().max(255).nullish(),
  currency: z.string().max(255).optional().default("CZK"),
  is_default: booleanFromForm.optional().default(false),
  position: numberFromForm.optional().default(0),
});

export const UpdateBankAccountSchema = z.object({
  account_name: z.string().max(255).nullish(),
  bank_name: z.string().max(255).nullish(),
  account_number: z.string().max(255).nullish(),
  iban: z.string().max(255).nullish(),
  bic: z.string().max(255).nullish(),
  currency: z.string().max(255).optional(),
  is_default: booleanFromForm.optional(),
  position: numberFromForm.optional(),
});

export type CreateBankAccountInput = z.infer<typeof CreateBankAccountSchema>;
export type UpdateBankAccountInput = z.infer<typeof UpdateBankAccountSchema>;
