/* eslint-disable jsx-a11y/click-events-have-key-events */ import dayjs from "dayjs"; import { useLocale } from "@/hooks/useLocale"; import { PriceManager } from "@/libs/price-manager/price-manager"; /* eslint-disable jsx-a11y/no-static-element-interactions */ export interface InstallmentListProps { value: string; activeMasterpassCidssRules: number; payableDate: string; onChange: (value: string) => void; options: { key: string; selected: boolean; installmentCount: number; additionalInstallmentCount: number; installmentCountText: string; monthlyAmountNow: number; monthlyAmountLater: number; discountRate: string; totalPriceNow: number; totalPriceLater: number; totalPrice: number; providerName: string; originalKey: any; postCost: number; bankCode: string; macroMerchantId: string; }[]; } const InstallmentList = (props: InstallmentListProps) => { const { t } = useLocale(); return (
{t("Number of Installments")}
{props.activeMasterpassCidssRules === 1 ? (
{t("Monthly Amount")}
) : (
{t("Now")}
{`${t( "from {{date}}", { date: dayjs(props.payableDate).format("DD.MM.YYYY") }, )}`}
)}
{t("Total Price")}
{props.options.map((option) => (
props.onChange(option.key)} key={option.key} data-active={props.value === option.key} className="mt-2 flex cursor-pointer rounded-primary border bg-white p-3 text-sm font-medium text-gray-600 data-[active=true]:border-primary-500" >
{option.installmentCountText}
{props.activeMasterpassCidssRules === 1 ? (
{PriceManager({ currency: "TRY", value: option.monthlyAmountNow, })}
) : (
{`${PriceManager({ currency: "TRY", value: option.monthlyAmountNow, })} x ${option.installmentCount}`} {PriceManager({ currency: "TRY", value: option.totalPriceNow, })}
{`${PriceManager({ currency: "TRY", value: option.monthlyAmountLater, })} x ${option.installmentCount} `} {PriceManager({ currency: "TRY", value: option.totalPriceLater, })}
)}
{PriceManager({ currency: "TRY", value: option.totalPrice, })}
))}
); }; export { InstallmentList };