From 544f26f0199154eb96a22920c7b7828522762c2d Mon Sep 17 00:00:00 2001 From: Evgenij Ponomarev Date: Tue, 12 Mar 2024 02:28:51 +0700 Subject: [PATCH] Redirect to home if subscribed --- src/components/Navbar/index.tsx | 1 + .../palmistry/payment-screen/payment-screen.tsx | 8 +++++--- .../palmistry/step-paywall/step-paywall.tsx | 1 - .../palmistry/steps-manager/steps-manager.tsx | 12 ++++++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index 98bf907..7c6b62f 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -20,6 +20,7 @@ function Navbar({ isOpen, closeMenu }: NavbarProps): JSX.Element { const combinedClassNames = ['navbar', isOpen && 'navbar--open'].filter(Boolean).join(' ') const handleLogout = () => { + localStorage.removeItem('palmistry.firstUnpassedStep'); navigate(routes.client.birthday()) logout() } diff --git a/src/components/palmistry/payment-screen/payment-screen.tsx b/src/components/palmistry/payment-screen/payment-screen.tsx index 69c055b..ac39f88 100644 --- a/src/components/palmistry/payment-screen/payment-screen.tsx +++ b/src/components/palmistry/payment-screen/payment-screen.tsx @@ -223,9 +223,11 @@ export default function PaymentScreen() { -
- -
+ {activeSubPlanFromStore && ( +
+ +
+ )} ); } diff --git a/src/components/palmistry/step-paywall/step-paywall.tsx b/src/components/palmistry/step-paywall/step-paywall.tsx index 4d2dcd3..1439112 100644 --- a/src/components/palmistry/step-paywall/step-paywall.tsx +++ b/src/components/palmistry/step-paywall/step-paywall.tsx @@ -18,7 +18,6 @@ export default function StepPaywall() { }, [storedEmail]); const onNext = () => { - steps.saveToStorage('firstUnpassedStep', Step.Payment); navigate('/palmistry/payment'); }; diff --git a/src/components/palmistry/steps-manager/steps-manager.tsx b/src/components/palmistry/steps-manager/steps-manager.tsx index 2a74278..11b17e8 100644 --- a/src/components/palmistry/steps-manager/steps-manager.tsx +++ b/src/components/palmistry/steps-manager/steps-manager.tsx @@ -1,9 +1,13 @@ import React from 'react'; import { AnimatePresence, motion } from 'framer-motion'; import { useLocation } from 'react-router-dom'; +import { useSelector } from "react-redux"; +import { useNavigate } from 'react-router-dom'; import './steps-manager.css'; +import routes from '@/routes'; +import { selectors } from "@/store"; import Progressbar from '@/components/palmistry/progress-bar/progress-bar'; import PalmistryContainer from '@/components/palmistry/palmistry-container/palmistry-container'; import useSteps, { Step } from '@/hooks/palmistry/use-steps'; @@ -46,6 +50,8 @@ const animationDuration = 0.2; export default function StepsManager() { const steps = useSteps(); const { pathname } = useLocation(); + const subscriptionStatus = useSelector(selectors.selectStatus); + const navigate = useNavigate(); const [modalIsOpen, setModalIsOpen] = React.useState(false); @@ -54,6 +60,12 @@ export default function StepsManager() { steps.goFirstUnpassedStep(); }, [steps.isInited]); + + React.useEffect(() => { + if (subscriptionStatus === "subscribed") { + navigate(routes.client.home()); + } + }, [subscriptionStatus]); const motionDivClassName = [ 'steps-manager__motion-div',