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 subscription warning on past_due

ali-inkco0f25dfa9cc5e
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 ef9d875f..961b1031 100644
--- a/packages/app/src/react/features/data-space/dialogs/addNamespace.tsx
+++ b/packages/app/src/react/features/data-space/dialogs/addNamespace.tsx
@@ -98,11 +98,23 @@ export default function AddNamespaceDialog({
isUserAcknowledged: true,
}),
});
- await res.json();
- await refreshUserData();
+ const responseData = await res.json();
+
+ try {
+ let parsedMessage = JSON.parse(responseData?.message);
- toast.success('Your subscription has been updated.');
- setTimeout(() => navigateTo('/my-plan', false), 500);
+ if (parsedMessage && parsedMessage.warnings && Array.isArray(parsedMessage.warnings)) {
+ localStorage.setItem(
+ 'subscription_warnings',
+ JSON.stringify({ data: Date.now(), warnings: parsedMessage.warnings }),
+ );
+ }
+ } catch {
+ // do nothing
+ }
+
+ await refreshUserData();
+ window.location.href = '/my-plan?upgraded=true';
} 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 a8752a2f..7f26b4c3 100644
--- a/packages/app/src/react/features/subscriptions/pages/EnterpriseTierFrameV4.tsx
+++ b/packages/app/src/react/features/subscriptions/pages/EnterpriseTierFrameV4.tsx
@@ -232,7 +232,21 @@ export const EnterpriseTierFrameV4: FC<Props> = ({ tierIndex }) => {
}),
});
- await res.json();
+ 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 }),
+ );
+ }
+ } catch {
+ // do nothing
+ }
+
await refreshUserData();
window.location.href = '/my-plan?upgraded=true';
diff --git a/packages/app/src/react/features/subscriptions/pages/MyPlanPage.tsx b/packages/app/src/react/features/subscriptions/pages/MyPlanPage.tsx
index 01ebce62..74e4afe2 100644
--- a/packages/app/src/react/features/subscriptions/pages/MyPlanPage.tsx
+++ b/packages/app/src/react/features/subscriptions/pages/MyPlanPage.tsx
@@ -108,7 +108,17 @@ const MyPlanPage = () => {
useEffect(() => {
const params = new URLSearchParams(location.search);
- if (params.get('upgraded') === 'true') {
+ 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');
diff --git a/packages/app/src/react/features/subscriptions/pages/PlansPricingPage.tsx b/packages/app/src/react/features/subscriptions/pages/PlansPricingPage.tsx
index e2e8a16a..22667741 100644
--- a/packages/app/src/react/features/subscriptions/pages/PlansPricingPage.tsx
+++ b/packages/app/src/react/features/subscriptions/pages/PlansPricingPage.tsx
@@ -105,7 +105,20 @@ const PricingTierItem: FC<PricingTier> = ({
...(promoCode.trim() ? { promoCode: promoCode.trim() } : {}),
}),
});
- await res.json();
+ 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 }),
+ );
+ }
+ } catch {
+ // do nothing
+ }
await refreshUserData();
window.location.href = '/my-plan?upgraded=true';
setShowConfirmationDialog(false);