import * as Yup from 'yup';
import { OptionType } from '@/components/input/SelectInput';

// Type for form values (includes option objects for SelectInput)
export type InitialBalanceFormValues = {
  party_type_option: OptionType | null;
  party_id_option: OptionType | null;
  bank_id_option: OptionType | null;
  reference_number: string;
  initial_balance_type_option: OptionType | null;
  nominal: string;
  note: string;
};

export const InitialBalanceFormSchema = Yup.object().shape({
  party_type_option: Yup.mixed()
    .nullable()
    .test(
      'is-valid-option',
      'Jenis pihak wajib diisi',
      (value) => value !== null && value !== undefined
    ),
  party_id_option: Yup.mixed()
    .nullable()
    .test(
      'is-valid-option',
      'Pihak wajib diisi',
      (value) => value !== null && value !== undefined
    ),
  bank_id_option: Yup.mixed().nullable(),
  reference_number: Yup.string().required('Nomor referensi wajib diisi'),
  initial_balance_type_option: Yup.mixed()
    .nullable()
    .test(
      'is-valid-option',
      'Tipe saldo awal wajib diisi',
      (value) => value !== null && value !== undefined
    ),
  nominal: Yup.string().required('Nominal wajib diisi'),
  note: Yup.string().required('Catatan wajib diisi'),
});

export const UpdateInitialBalanceFormSchema = InitialBalanceFormSchema;
