import { useAppSelector } from '@akinon/next/redux/hooks'; import { RootState } from '@theme/redux/store'; import { useSetInstallmentOptionMutation } from '@akinon/next/data/client/checkout'; import { Radio, Price } from '@theme/components'; import { useLocalization } from '@akinon/next/hooks'; const CreditCardInstallments = ({ error }) => { const { t } = useLocalization(); const { preOrder, cardType, installmentOptions } = useAppSelector( (state: RootState) => state.checkout ); const [setInstallmentOption] = useSetInstallmentOptionMutation(); const errorMessage = (
{error?.message}
); if (installmentOptions.length === 0) { return ( <>
{t('checkout.payment.installment_options.description')}
); } return ( <>
{t('checkout.payment.installment_options.installment')}:{' '} {cardType?.name ?? 'Other'}
{installmentOptions.map((option) => ( ))}
{t('checkout.payment.installment_options.payments')} {t('checkout.payment.installment_options.per_month')} {t('checkout.payment.installment_options.total')}
{ setInstallmentOption(option.pk); }} data-testid={`checkout-credit-card-installment-${option.pk}`} > {option.label}
{error && errorMessage}
); }; export default CreditCardInstallments;