Merge branch 'hotfix/change-home-page-protection' into 'main'

hotfix/change-home-page-protection

See merge request witapp/aura-webapp!503
This commit is contained in:
Daniil Chemerkin 2024-12-26 22:06:18 +00:00
commit 59462be48b
3 changed files with 3 additions and 31 deletions

View File

@ -1275,7 +1275,7 @@ export function PrivateOutlet(): JSX.Element {
function PrivateSubscriptionOutlet(): JSX.Element { function PrivateSubscriptionOutlet(): JSX.Element {
const isProduction = import.meta.env.MODE === "production"; const isProduction = import.meta.env.MODE === "production";
const status = useSelector(selectors.selectStatus); const status = useSelector(selectors.selectStatus);
return status === "subscribed" || !isProduction ? ( return status === "subscribed" || !isProduction || true ? (
<Outlet /> <Outlet />
) : ( ) : (
<Navigate to={getRouteBy(status)} replace={true} /> <Navigate to={getRouteBy(status)} replace={true} />

View File

@ -5,21 +5,13 @@ import { actions, selectors } from "@/store";
import { getFormattedPrice } from "@/utils/price.utils"; import { getFormattedPrice } from "@/utils/price.utils";
import Guarantees from "../../components/Guarantees"; import Guarantees from "../../components/Guarantees";
import Button from "../../components/Button"; 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 { addCurrency, ELocalesPlacement } from "@/locales";
import { useTranslations } from "@/hooks/translations"; import { useTranslations } from "@/hooks/translations";
import Stars from "../../components/Stars"; import Stars from "../../components/Stars";
import metricService, {
EGoals,
EMetrics,
} from "@/services/metric/metricService";
function Payment() { function Payment() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { translate } = useTranslations(ELocalesPlacement.PalmistryV1); const { translate } = useTranslations(ELocalesPlacement.PalmistryV1);
const navigate = useNavigate();
const activeProductFromStore = useSelector(selectors.selectActiveProduct); const activeProductFromStore = useSelector(selectors.selectActiveProduct);
const currency = useSelector(selectors.selectCurrency); const currency = useSelector(selectors.selectCurrency);
const trialPrice = activeProductFromStore?.trialPrice || 0; const trialPrice = activeProductFromStore?.trialPrice || 0;
@ -27,32 +19,11 @@ function Payment() {
const isShowPaymentModal = useSelector( const isShowPaymentModal = useSelector(
selectors.selectPalmistryIsShowPaymentModalV1 selectors.selectPalmistryIsShowPaymentModalV1
); );
const [searchParams] = useSearchParams();
const subscriptionStatus =
searchParams.get("redirect_status") === "succeeded" ? "subscribed" : "lead";
const showModal = () => { const showModal = () => {
dispatch(actions.palmistry.setIsShowPaymentModalV1(true)); 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 ( return (
<> <>
<div className={styles["app-number-one"]}> <div className={styles["app-number-one"]}>
@ -91,7 +62,7 @@ function Payment() {
})} })}
</div> </div>
<Guarantees /> <Guarantees />
{!isShowPaymentModal && subscriptionStatus !== "subscribed" && ( {!isShowPaymentModal && (
<Button className={styles.button} onClick={showModal}> <Button className={styles.button} onClick={showModal}>
{translate("/payment.get_personal_prediction")} {translate("/payment.get_personal_prediction")}
</Button> </Button>

View File

@ -17,6 +17,7 @@ function CheckSubscriptionOutlet({
const { user } = useAuth(); const { user } = useAuth();
if (user && status === "subscribed") { if (user && status === "subscribed") {
return <Outlet />;
return <Navigate to={subscribedReturnUrl} replace={true} />; return <Navigate to={subscribedReturnUrl} replace={true} />;
} }
if (unsubscribedReturnUrl?.length) { if (unsubscribedReturnUrl?.length) {