From 0920d848433bd414930d46bed4e52f6170ceb971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D0=B0=D1=82=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Thu, 25 Apr 2024 14:35:22 +0000 Subject: [PATCH] AW-47-duplicateSubscriptionPlans --- .../step-subscription-plan.tsx | 76 ++++++++++++++----- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx b/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx index b8c99c1..d1f4de5 100644 --- a/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx +++ b/src/components/palmistry/step-subscription-plan/step-subscription-plan.tsx @@ -1,21 +1,21 @@ -import React from 'react'; +import React, { useMemo } from "react"; import { useDispatch } from "react-redux"; import { useTranslation } from "react-i18next"; import { useSelector } from "react-redux"; import { selectors } from "@/store"; -import useSteps, { Step } from '@/hooks/palmistry/use-steps'; -import Button from '@/components/palmistry/button/button'; -import EmailHeader from '@/components/palmistry/email-header/email-header'; +import useSteps, { Step } from "@/hooks/palmistry/use-steps"; +import Button from "@/components/palmistry/button/button"; +import EmailHeader from "@/components/palmistry/email-header/email-header"; import { ISubscriptionPlan } from "@/api/resources/SubscriptionPlans"; import { actions } from "@/store"; import { useApi } from "@/api"; -const bestPlanId = 'stripe.15'; +const bestPlanId = "stripe.15"; const getFormattedPrice = (plan: ISubscriptionPlan) => { return (plan.trial!.price_cents / 100).toFixed(2); -} +}; export default function StepSubscriptionPlan() { const steps = useSteps(); @@ -23,11 +23,14 @@ export default function StepSubscriptionPlan() { const api = useApi(); const { i18n } = useTranslation(); const activeSubPlanFromStore = useSelector(selectors.selectActiveSubPlan); + const allowedPlans = useMemo(() => ["stripe.37"], []); const storedEmail = steps.getStoredValue(Step.Email); - const [subscriptionPlan, setSubscriptionPlan] = React.useState(''); - const [subscriptionPlans, setSubscriptionPlans] = React.useState([]); + const [subscriptionPlan, setSubscriptionPlan] = React.useState(""); + const [subscriptionPlans, setSubscriptionPlans] = React.useState< + ISubscriptionPlan[] + >([]); const [email, setEmail] = React.useState(steps.getStoredValue(Step.Email)); const locale = i18n.language; @@ -42,7 +45,10 @@ export default function StepSubscriptionPlan() { (async () => { const { sub_plans } = await api.getSubscriptionPlans({ locale }); const plans = sub_plans - .filter((plan: ISubscriptionPlan) => plan.provider === "stripe") + .filter( + (plan: ISubscriptionPlan) => + plan.provider === "stripe" && !plan.name.includes("(test)") + ) .sort((a, b) => { if (!a.trial || !b.trial) { return 0; @@ -55,13 +61,19 @@ export default function StepSubscriptionPlan() { } return 0; }); - setSubscriptionPlans(plans.filter((plan) => plan.trial?.price_cents)); + setSubscriptionPlans( + plans.filter( + (plan) => plan.trial?.price_cents || allowedPlans.includes(plan.id) + ) + ); })(); - }, [api, locale]); + }, [allowedPlans, api, locale]); React.useEffect(() => { if (subscriptionPlan) { - const targetSubPlan = subscriptionPlans.find((sub_plan) => sub_plan.id === subscriptionPlan); + const targetSubPlan = subscriptionPlans.find( + (sub_plan) => sub_plan.id === subscriptionPlan + ); if (targetSubPlan) { dispatch(actions.payment.update({ activeSubPlan: targetSubPlan })); @@ -70,7 +82,7 @@ export default function StepSubscriptionPlan() { }, [subscriptionPlan]); React.useEffect(() => { - setEmail(storedEmail || ''); + setEmail(storedEmail || ""); }, [storedEmail]); const onNext = () => { @@ -80,15 +92,21 @@ export default function StepSubscriptionPlan() { return ( <> - +
- We've helped millions of people to reveal the destiny of their love life and what the future holds for them and - their families. + We've helped millions of people to reveal the destiny of their love life + and what the future holds for them and their families.
- + (
setSubscriptionPlan(plan.id)} >

${getFormattedPrice(plan)}

@@ -139,11 +161,23 @@ export default function StepSubscriptionPlan() { ))}
- - It costs us $13.21 to compensate our AURA employees for the trial, but please choose the amount you are comfortable with. + + It costs us $13.21 to compensate our AURA employees for the trial, but + please choose the amount you are comfortable with. -