From 23f77dc21ddece6a975d2dfb784007129aa8da6a Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 21 Jan 2023 07:55:53 +0100 Subject: [PATCH] progress --- .../workspace_settings/checkout/+page.svelte | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/frontend/src/routes/(root)/(logged)/workspace_settings/checkout/+page.svelte b/frontend/src/routes/(root)/(logged)/workspace_settings/checkout/+page.svelte index 23083b1a59..4f35242834 100644 --- a/frontend/src/routes/(root)/(logged)/workspace_settings/checkout/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/workspace_settings/checkout/+page.svelte @@ -4,25 +4,43 @@ import CenteredModal from '$lib/components/CenteredModal.svelte' import { Alert } from '$lib/components/common' import { WindmillIcon } from '$lib/components/icons' + import { WorkspaceService } from '$lib/gen' + import { workspaceStore } from '$lib/stores' + import { sendUserToast } from '$lib/utils' let success = $page.url.searchParams.get('success') === 'true' + let attempt = 0 if (!success) { setTimeout(() => { - goto('/workspace_settings?tab=plan') + goto('/workspace_settings?tab=premium') + }, 5000) + } else { + setInterval(async () => { + attempt += 1 + if ((await WorkspaceService.getSettings({ workspace: $workspaceStore! })).customer_id) { + goto('/workspace_settings?tab=premium') + } else if (attempt > 10) { + sendUserToast('Subscription upgrade failed. Contact contact@windmill.dev', true) + goto('/workspace_settings?tab=premium') + } }, 5000) } - -
-
- + + {#if !success} +
+ The checkout failed, your subscription has not been updated. -

You will be redirected to the workspace settings page in 5 seconds...

-
+ {/if} +

+ You will be redirected to the workspace settings page in 5 seconds... +

+
+