import React, { useState } from "react"; import { useSelector } from "react-redux"; import "./payment-screen.css"; import useSteps, { Step } from "@/hooks/palmistry/use-steps"; import useTimer from "@/hooks/palmistry/use-timer"; import HeaderLogo from "@/components/palmistry/header-logo/header-logo"; import { selectors } from "@/store"; import { EPlacementKeys } from "@/api/resources/Paywall"; import { useNavigate, useSearchParams } from "react-router-dom"; import PaymentModalNew from "@/components/PaymentModalNew"; import { addCurrency, ELocalesPlacement } from "@/locales"; import { getPriceCentsToDollars } from "@/services/price"; import routes from "@/routes"; import { useTranslations } from "@/hooks/translations"; import metricService, { EGoals, EMetrics } from "@/services/metric/metricService"; export default function PaymentScreen() { const { translate } = useTranslations(ELocalesPlacement.PalmistryV0); const navigate = useNavigate(); const time = useTimer(); const activeProductFromStore = useSelector(selectors.selectActiveProduct); const [searchParams] = useSearchParams(); const subscriptionStatus = searchParams.get("redirect_status") === "succeeded" ? "subscribed" : "lead"; const [height, setHeight] = useState( subscriptionStatus === "subscribed" ? 246 : 146 ); const steps = useSteps(); React.useEffect(() => { if (subscriptionStatus === "subscribed") { metricService.reachGoal(EGoals.PAYMENT_SUCCESS, [EMetrics.YANDEX, EMetrics.KLAVIYO]); metricService.reachGoal(EGoals.PAYMENT_SUCCESS_PALMISTRY, [ EMetrics.YANDEX, ]); // if (activeProductFromStore) { // metricService.reachGoal(EGoals.PURCHASE, [EMetrics.FACEBOOK], { // currency: "USD", // value: ((activeProductFromStore.trialPrice || 100) / 100).toFixed(2), // }); // } setTimeout(() => { // steps.goNext(); navigate(routes.client.skipTrial()); }, 1500); } }, [activeProductFromStore, navigate, subscriptionStatus]); React.useEffect(() => { if (!activeProductFromStore) { steps.setFirstUnpassedStep(Step.SubscriptionPlan); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [activeProductFromStore]); const trialPrice = activeProductFromStore?.trialPrice || 0; const fullPrice = activeProductFromStore?.price || 0; const currency = useSelector(selectors.selectCurrency); const [minutes, seconds] = time.split(":"); const returnUrl = window.location.origin + "/palmistry/payment"; return (
{translate("/payment.app_number_one", { color: ( {translate("/payment.app_number_one_color")} ), })}
{translate("/payment.payment_information.personalized_offer")}
{minutes[0]} {minutes[1]}:{seconds[0]} {seconds[1]}

{translate("/payment.payment_information.title", { trialDuration: activeProductFromStore?.trialDuration, })}

{translate("/payment.payment_information.total_today")} {addCurrency(getPriceCentsToDollars(trialPrice), currency)}
{translate("/payment.payment_information.code_applied", { bold: ( {translate("/payment.payment_information.code_applied_bold")} ), })}
{translate("/payment.will_be_charged", { trialInfo: ( {translate("/payment.will_be_charged_trial_info", { trialPrice: addCurrency( getPriceCentsToDollars(trialPrice), currency ), trialDuration: activeProductFromStore?.trialDuration, })} ), fullPrice: ( {addCurrency(getPriceCentsToDollars(fullPrice), currency)} ), trialPrice: addCurrency( getPriceCentsToDollars(trialPrice), currency ), save: addCurrency( getPriceCentsToDollars(fullPrice - trialPrice), currency ), emailReminder: ( {translate("/payment.will_be_charged_email_reminder")} ), })}
{translate("/payment.guarantees.no_commitment")}
{translate("/payment.guarantees.30_day_money_back")}
{activeProductFromStore && (
{subscriptionStatus !== "subscribed" && ( )} {subscriptionStatus === "subscribed" && (
{translate("/payment.payment_success")}
)}
)}
); }