import { useTranslations } from "@/hooks/translations"; import styles from "./styles.module.scss"; import { addCurrency, ELocalesPlacement } from "@/locales"; import { useSelector } from "react-redux"; import { selectors } from "@/store"; import Loader from "@/components/Loader"; import Title from "@/components/Title"; import { EPlacementKeys, IPaywallProduct } from "@/api/resources/Paywall"; import CheckoutForm from "../CheckoutForm"; import PaymentMethodsChoice from "../../PaymentMethodsChoice"; import { EPaymentMethod } from "@/data/paymentMethods"; const getPrice = (product: IPaywallProduct | null) => { if (!product) { return 0; } return (product.trialPrice || 0) / 100; } interface IPaymentFormProps { isSinglePayment?: boolean; className?: string; placementKey: EPlacementKeys; onPaymentError?: (error?: string) => void; onPaymentSuccess?: () => void; onModalClosed?: () => void; } function PaymentForm({ isSinglePayment = false, className, placementKey, onPaymentError, onPaymentSuccess, onModalClosed }: IPaymentFormProps) { const { translate } = useTranslations(ELocalesPlacement.V1); const currency = useSelector(selectors.selectCurrency); const activeProduct = useSelector(selectors.selectActiveProduct); const isLoading = false; const paymentMethodsButtons = [ { id: EPaymentMethod.CREDIT_CARD, icon: "/payment-form/credit-card.svg", title: translate("payment_modal.credit_card") } ] return ( <> {isLoading && (
{translate("payment_modal.description", { priceForDays: ( {translate("payment_modal.price_for_days", { trialPrice: addCurrency( getPrice(activeProduct), currency ), trialDuration: activeProduct?.trialDuration, })} ), emailReminder: ( {translate("payment_modal.email_reminder")} ), })}
{translate("payment_modal.address")}