Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to introduce paid plan routes #569

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
6 changes: 5 additions & 1 deletion frontend/src/hooks/useExceptionHandler.jsx
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -36,6 +37,9 @@ const useExceptionHandler = () => {
}
break;
case "subscription_error":
if (location?.pathname === "/plans") {
return;
}
navigate("/trial-expired");
return {
title: title,
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/hooks/useUserSession.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -23,6 +26,10 @@ const useUserSession = () => {
}

if (error?.response?.data?.type === "subscription_error") {
if (location?.pathname === "/plans") {
return;
}

navigate("/trial-expired");
return;
}
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/routes/Router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 =
Expand Down Expand Up @@ -235,6 +240,7 @@ function Router() {
{TrialRoutes && (
<Route path="/trial-expired" element={<TrialRoutes />} />
)}
{PaidPlans && <Route path="/plans" element={<PaidPlans />} />}
<Route path="*" element={<NotFound />} />
</Route>
<Route path="oauth-status" element={<OAuthStatus />} />
Expand Down