From 7669bfcc885d99ae231d028445538bfe13be0ad7 Mon Sep 17 00:00:00 2001 From: johnyrahul Date: Thu, 8 Aug 2024 23:23:06 +0530 Subject: [PATCH 1/2] changes to introduce paid plan routes --- backend/backend/celery_task.py | 5 +++++ backend/backend/public_urls.py | 13 +++++++++++++ frontend/src/hooks/useExceptionHandler.jsx | 6 +++++- frontend/src/hooks/useUserSession.js | 9 ++++++++- frontend/src/routes/Router.jsx | 6 ++++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/backend/backend/celery_task.py b/backend/backend/celery_task.py index bc3b709e3..ab256f729 100644 --- a/backend/backend/celery_task.py +++ b/backend/backend/celery_task.py @@ -32,3 +32,8 @@ def log_consumer(**kwargs: Any) -> None: f"[{os.getpid()}] Log message received: {log_message} for the room {room}" ) handle_user_logs(room=room, event=event, message=log_message) + + @shared_task(name="hellowold111111") + def my_periodic_task(): + print("This task runs periodically!------------") + return diff --git a/backend/backend/public_urls.py b/backend/backend/public_urls.py index 7b40d2655..69fb2e5fa 100644 --- a/backend/backend/public_urls.py +++ b/backend/backend/public_urls.py @@ -108,3 +108,16 @@ ] except ImportError: pass + + +try: + import pluggable_apps.subscription.public_urls # noqa # pylint: disable=unused-import + + urlpatterns += [ + path( + f"{path_prefix}/subscription/", + include("pluggable_apps.subscription.public_urls"), + ), + ] +except ImportError: + pass diff --git a/frontend/src/hooks/useExceptionHandler.jsx b/frontend/src/hooks/useExceptionHandler.jsx index 4f7835e54..aa31e1a8c 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 && } />} } /> } /> From 055d2091e49d0a3ff765041e471d5e55928e9d8f Mon Sep 17 00:00:00 2001 From: johnyrahul Date: Tue, 13 Aug 2024 14:07:56 +0530 Subject: [PATCH 2/2] removing poc code --- backend/backend/celery_task.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/backend/backend/celery_task.py b/backend/backend/celery_task.py index ab256f729..bc3b709e3 100644 --- a/backend/backend/celery_task.py +++ b/backend/backend/celery_task.py @@ -32,8 +32,3 @@ def log_consumer(**kwargs: Any) -> None: f"[{os.getpid()}] Log message received: {log_message} for the room {room}" ) handle_user_logs(room=room, event=event, message=log_message) - - @shared_task(name="hellowold111111") - def my_periodic_task(): - print("This task runs periodically!------------") - return