Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

show warning/success message on plan change page (remove localStorage and upgraded parameter in url)

ali-inkco8d2b2ac307e0
diff --git a/packages/app/src/react/features/data-space/dialogs/addNamespace.tsx b/packages/app/src/react/features/data-space/dialogs/addNamespace.tsx
index 961b1031..5446ca26 100644
--- a/packages/app/src/react/features/data-space/dialogs/addNamespace.tsx
+++ b/packages/app/src/react/features/data-space/dialogs/addNamespace.tsx
@@ -98,23 +98,23 @@ export default function AddNamespaceDialog({
isUserAcknowledged: true,
}),
});
+
const responseData = await res.json();
try {
let parsedMessage = JSON.parse(responseData?.message);
-
if (parsedMessage && parsedMessage.warnings && Array.isArray(parsedMessage.warnings)) {
- localStorage.setItem(
- 'subscription_warnings',
- JSON.stringify({ data: Date.now(), warnings: parsedMessage.warnings }),
- );
+ toast.warning(parsedMessage.warnings.join('\n'));
+ } else {
+ toast.success('Your subscription has been updated.');
}
} catch {
// do nothing
+ toast.success('Your subscription has been updated.');
}
-
+ await new Promise((resolve) => setTimeout(resolve, 2000));
await refreshUserData();
- window.location.href = '/my-plan?upgraded=true';
+ setTimeout(() => navigateTo('/my-plan', false), 500);
} catch (error) {
const errorMessage = extractError(error);
toast.error(errorMessage || 'Something went wrong. Please try again.');
diff --git a/packages/app/src/react/features/subscriptions/pages/EnterpriseTierFrameV4.tsx b/packages/app/src/react/features/subscriptions/pages/EnterpriseTierFrameV4.tsx
index 7f26b4c3..15325f4b 100644
--- a/packages/app/src/react/features/subscriptions/pages/EnterpriseTierFrameV4.tsx
+++ b/packages/app/src/react/features/subscriptions/pages/EnterpriseTierFrameV4.tsx
@@ -236,20 +236,18 @@ export const EnterpriseTierFrameV4: FC<Props> = ({ tierIndex }) => {
try {
let parsedMessage = JSON.parse(responseData?.message);
-
if (parsedMessage && parsedMessage.warnings && Array.isArray(parsedMessage.warnings)) {
- localStorage.setItem(
- 'subscription_warnings',
- JSON.stringify({ data: Date.now(), warnings: parsedMessage.warnings }),
- );
+ toast.warning(parsedMessage.warnings.join('\n'));
+ } else {
+ toast.success('Your subscription has been updated.');
}
} catch {
// do nothing
+ toast.success('Your subscription has been updated.');
}
-
+ await new Promise((resolve) => setTimeout(resolve, 2000));
await refreshUserData();
-
- window.location.href = '/my-plan?upgraded=true';
+ setTimeout(() => navigateTo('/my-plan', false), 500);
setShowConfirmationDialog(false);
} catch (error) {
const errorMessage = extractError(error);
diff --git a/packages/app/src/react/features/subscriptions/pages/MyPlanPage.tsx b/packages/app/src/react/features/subscriptions/pages/MyPlanPage.tsx
index 74e4afe2..52a4f4c8 100644
--- a/packages/app/src/react/features/subscriptions/pages/MyPlanPage.tsx
+++ b/packages/app/src/react/features/subscriptions/pages/MyPlanPage.tsx
@@ -9,7 +9,6 @@ import { extractError } from '@src/react/shared/utils/errors';
import { convertToGB, formatNumber } from '@src/react/shared/utils/format';
import { Analytics } from '@src/shared/posthog/services/analytics';
import { useEffect, useMemo, useState } from 'react';
-import { useLocation, useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';
/**
@@ -56,9 +55,6 @@ const MyPlanPage = () => {
const [loadingUpgrade, setLoadingUpgrade] = useState<boolean>(false);
const [dataPoolProgress, setDataPoolProgress] = useState<number>(0);
- const location = useLocation();
- const navigate = useNavigate();
-
useEffect(() => {
if (userSubs) {
Analytics.track('my_plan_page_visited', { planName: userSubs?.plan?.name });
@@ -106,26 +102,6 @@ const MyPlanPage = () => {
}
}, [user?.id, userSubs]);
- useEffect(() => {
- const params = new URLSearchParams(location.search);
- const subscriptionWarnings = localStorage.getItem('subscription_warnings');
- let isWarningsShown = false;
- if (subscriptionWarnings) {
- const parsedWarnings = JSON.parse(subscriptionWarnings);
- if (parsedWarnings.data > Date.now() - 1000 * 60 * 2) {
- toast.warning(parsedWarnings.warnings.join('\n'));
- isWarningsShown = true;
- }
- localStorage.removeItem('subscription_warnings');
- }
- if (params.get('upgraded') === 'true' && !isWarningsShown) {
- toast.success('Your subscription has been updated.');
- // Remove the query parameter from the URL
- params.delete('upgraded');
- navigate({ search: params.toString() }, { replace: true });
- }
- }, [location, navigate]);
-
const handleUnsubscribe = async (type: 'cancel' | 'restart') => {
if (isReadOnlyAccess) return;
diff --git a/packages/app/src/react/features/subscriptions/pages/PlansPricingPage.tsx b/packages/app/src/react/features/subscriptions/pages/PlansPricingPage.tsx
index 22667741..a0d9bcfb 100644
--- a/packages/app/src/react/features/subscriptions/pages/PlansPricingPage.tsx
+++ b/packages/app/src/react/features/subscriptions/pages/PlansPricingPage.tsx
@@ -109,18 +109,18 @@ const PricingTierItem: FC<PricingTier> = ({
try {
let parsedMessage = JSON.parse(responseData?.message);
-
if (parsedMessage && parsedMessage.warnings && Array.isArray(parsedMessage.warnings)) {
- localStorage.setItem(
- 'subscription_warnings',
- JSON.stringify({ data: Date.now(), warnings: parsedMessage.warnings }),
- );
+ toast.warning(parsedMessage.warnings.join('\n'));
+ } else {
+ toast.success('Your subscription has been updated.');
}
} catch {
// do nothing
+ toast.success('Your subscription has been updated.');
}
+ await new Promise((resolve) => setTimeout(resolve, 2000));
await refreshUserData();
- window.location.href = '/my-plan?upgraded=true';
+ setTimeout(() => navigateTo('/my-plan', false), 500);
setShowConfirmationDialog(false);
} catch (error) {
const errorMessage = extractError(error);