diff --git a/frontend/src/hooks/useExceptionHandler.jsx b/frontend/src/hooks/useExceptionHandler.jsx index e11f8f5e8..b0525bb78 100644 --- a/frontend/src/hooks/useExceptionHandler.jsx +++ b/frontend/src/hooks/useExceptionHandler.jsx @@ -1,8 +1,9 @@ -import { useNavigate } from "react-router-dom"; +import { useNavigate, useLocation } from "react-router-dom"; import PropTypes from "prop-types"; const useExceptionHandler = () => { const navigate = useNavigate(); + const location = useLocation(); const handleException = ( err, errMessage = "Something went wrong", @@ -36,6 +37,9 @@ const useExceptionHandler = () => { } break; case "subscription_error": + if (location?.pathname === "/plans") { + return; + } navigate("/trial-expired"); return { title: title, diff --git a/frontend/src/hooks/useUserSession.js b/frontend/src/hooks/useUserSession.js index 4b1d8509f..72ff999da 100644 --- a/frontend/src/hooks/useUserSession.js +++ b/frontend/src/hooks/useUserSession.js @@ -1,14 +1,17 @@ import axios from "axios"; -import { useNavigate } from "react-router-dom"; +import { useNavigate, useLocation } from "react-router-dom"; import { useExceptionHandler } from "../hooks/useExceptionHandler.jsx"; import { useAlertStore } from "../store/alert-store"; + const useUserSession = () => { const navigate = useNavigate(); const handleException = useExceptionHandler(); const { setAlertDetails } = useAlertStore(); const fallbackErrorMessage = "Error while getting session"; + const location = useLocation(); + return async () => { try { const requestOptions = { @@ -23,6 +26,10 @@ const useUserSession = () => { } if (error?.response?.data?.type === "subscription_error") { + if (location?.pathname === "/plans") { + return; + } + navigate("/trial-expired"); return; } diff --git a/frontend/src/routes/Router.jsx b/frontend/src/routes/Router.jsx index b7ad85c4b..cafcb8eed 100644 --- a/frontend/src/routes/Router.jsx +++ b/frontend/src/routes/Router.jsx @@ -30,6 +30,7 @@ import { UsersPage } from "../pages/UsersPage.jsx"; import { WorkflowsPage } from "../pages/WorkflowsPage.jsx"; let TrialRoutes; +let PaidPlans; let RequirePlatformAdmin; let PlatformAdminPage; let AppDeployments; @@ -43,6 +44,10 @@ let ManualReviewSettings; try { TrialRoutes = require("../plugins/subscription/trial-page/TrialEndPage.jsx").TrialEndPage; + + PaidPlans = + require("../plugins/subscription/paid-plans/PaidPlans.jsx").PaidPlans; + RequirePlatformAdmin = require("../plugins/frictionless-onboard/RequirePlatformAdmin.jsx").RequirePlatformAdmin; PlatformAdminPage = @@ -235,6 +240,7 @@ function Router() { {TrialRoutes && ( } /> )} + {PaidPlans && } />} } /> } />