import * as yup from 'yup';

export type ExpensesFilterType = {
  transaction_date: string | null;
  realization_date: string | null;
  location: { value: number; label: string } | null;
  vendor: { value: number; label: string } | null;
  category: { value: string; label: string } | null;
  approval_status: { value: string; label: string } | null;
  realization_status: { value: string; label: string } | null;
  project_flock: { value: number; label: string } | null;
  project_flock_kandang: { value: number; label: string } | null;
};

export const ExpensesFilterSchema = yup.object({
  transaction_date: yup.string().nullable(),
  realization_date: yup.string().nullable(),
  location: yup
    .object({
      value: yup.number().required(),
      label: yup.string().required(),
    })
    .nullable(),
  vendor: yup
    .object({
      value: yup.number().required(),
      label: yup.string().required(),
    })
    .nullable(),
  category: yup
    .object({
      value: yup.string().required(),
      label: yup.string().required(),
    })
    .nullable(),
  approval_status: yup
    .object({
      value: yup.string().required(),
      label: yup.string().required(),
    })
    .nullable(),
  realization_status: yup
    .object({
      value: yup.string().required(),
      label: yup.string().required(),
    })
    .nullable(),
  project_flock: yup
    .object({
      value: yup.number().required(),
      label: yup.string().required(),
    })
    .nullable(),
  project_flock_kandang: yup
    .object({
      value: yup.number().required(),
      label: yup.string().required(),
    })
    .nullable(),
});

export type ExpensesFilterValues = yup.InferType<typeof ExpensesFilterSchema>;
