import { useDispatch, useSelector } from "react-redux"; import PaymentInformation from "../../components/PaymentInformation"; import styles from "./styles.module.scss"; import { actions, selectors } from "@/store"; import { getFormattedPrice } from "@/utils/price.utils"; import Guarantees from "../../components/Guarantees"; import Button from "../../components/Button"; import { useEffect } from "react"; import { useNavigate, useSearchParams } from "react-router-dom"; import routes from "@/routes"; import { addCurrency, ELocalesPlacement } from "@/locales"; import { useTranslations } from "@/hooks/translations"; import Stars from "../../components/Stars"; import metricService, { EGoals, EMetrics, } from "@/services/metric/metricService"; function Payment() { const dispatch = useDispatch(); const { translate } = useTranslations(ELocalesPlacement.PalmistryV1); const navigate = useNavigate(); const activeProductFromStore = useSelector(selectors.selectActiveProduct); const currency = useSelector(selectors.selectCurrency); const trialPrice = activeProductFromStore?.trialPrice || 0; const fullPrice = activeProductFromStore?.price || 0; const isShowPaymentModal = useSelector( selectors.selectPalmistryIsShowPaymentModalV1 ); const [searchParams] = useSearchParams(); const subscriptionStatus = searchParams.get("redirect_status") === "succeeded" ? "subscribed" : "lead"; const showModal = () => { dispatch(actions.palmistry.setIsShowPaymentModalV1(true)); }; useEffect(() => { if (subscriptionStatus !== "subscribed") return; metricService.reachGoal(EGoals.PAYMENT_SUCCESS); 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), }); } const timer = setTimeout(() => { navigate(routes.client.skipTrial()); }, 1500); return () => clearTimeout(timer); }, [activeProductFromStore, navigate, subscriptionStatus]); return ( <>
{translate("/payment.app_number_one", { color: {translate("/payment.app_number_one_color")}, })}