Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: navigate to /notes on subscription update in checkout view

Abdullah Attaea9aa2a13607
diff --git a/apps/web/src/navigation/hash-routes.tsx b/apps/web/src/navigation/hash-routes.tsx
index ed861e5c6..9b450275b 100644
--- a/apps/web/src/navigation/hash-routes.tsx
+++ b/apps/web/src/navigation/hash-routes.tsx
@@ -61,7 +61,7 @@ const hashroutes = defineHashRoutes({
BuyDialog.show({ couponCode: code }).then(afterAction);
},
"/welcome": () => {
- OnboardingDialog.show({ type: "new" })?.then(afterAction);
+ OnboardingDialog.show({})?.then(afterAction);
},
"/confirmed": () => {
FeatureDialog.show({ featureName: "confirmed" }).then(afterAction);
diff --git a/apps/web/src/views/checkout.tsx b/apps/web/src/views/checkout.tsx
index 17f526208..d6c29afd2 100644
--- a/apps/web/src/views/checkout.tsx
+++ b/apps/web/src/views/checkout.tsx
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import "../app.css";
import { useEffect, useState } from "react";
import { Box, Button, Flex, Text } from "@theme-ui/components";
-import { hardNavigate, useQueryParams } from "../navigation";
+import { hardNavigate, hashNavigate, useQueryParams } from "../navigation";
import { Support } from "../components/icons";
import { HeadlessAuth } from "./auth";
import {
@@ -39,6 +39,7 @@ import { isUserSubscribed } from "../hooks/use-is-user-premium";
import { PLAN_METADATA } from "../dialogs/buy-dialog/plans";
import { planToAvailability } from "@notesnook/common";
import { FeatureCaption } from "../dialogs/buy-dialog/feature-caption";
+import { EV, EVENTS } from "@notesnook/core";
export type Plan = z.infer<typeof PlanSchema>;
@@ -116,6 +117,17 @@ function Checkout() {
}
}, [plan]);
+ useEffect(() => {
+ if (currentStep === 2) {
+ var event = EV.subscribe(EVENTS.userSubscriptionUpdated, () => {
+ hardNavigate("/notes#/welcome");
+ });
+ return () => {
+ event.unsubscribe();
+ };
+ }
+ }, [currentStep]);
+
if (!plan) {
hardNavigate("/");
return null;