import { useMemo } from 'react';

import { type PolicyTypes } from 'src/types/vacations';
import { useLokaliseTranslation } from 'src/utils/i18n';
import { getMaxSellableBalanceDays } from 'src/utils/vacations';

import SellingBalanceShell from './SellingBalanceShell';

type Props = {
  amountInTime: number;
  policyType: PolicyTypes;
};

const SellingBalanceColombia = ({ amountInTime, policyType }: Props) => {
  const { t } = useLokaliseTranslation('time_off');

  const allowedToSell = useMemo(
    () =>
      getMaxSellableBalanceDays({
        currentBalance: policyType.currentBalance,
        amountInTime,
        minimumBalance: policyType.minimumBalance,
        regime: 'colombia',
      }),
    [amountInTime, policyType.currentBalance, policyType.minimumBalance],
  );

  return (
    <SellingBalanceShell
      allowedToSell={allowedToSell}
      switcherTitle={t('make_request_in_money')}
      switcherDescription={t('request_in_money_description')}
    />
  );
};

export default SellingBalanceColombia;
