From 8686e0d602ade95d335891a01598aa487016a1ec Mon Sep 17 00:00:00 2001 From: greghub Date: Thu, 21 Sep 2023 22:55:33 +0200 Subject: [PATCH] feat: display onboarding wizard if no cloud account was connected --- .../hooks/useCloudAccounts/useCloudAccount.ts | 6 ++++++ dashboard/services/settingsService.ts | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/dashboard/components/cloud-account/hooks/useCloudAccounts/useCloudAccount.ts b/dashboard/components/cloud-account/hooks/useCloudAccounts/useCloudAccount.ts index defa9b6b4..e3b939ad2 100644 --- a/dashboard/components/cloud-account/hooks/useCloudAccounts/useCloudAccount.ts +++ b/dashboard/components/cloud-account/hooks/useCloudAccounts/useCloudAccount.ts @@ -31,6 +31,12 @@ function useCloudAccount() { const [error, setError] = useState(false); useEffect(() => { + settingsService.getOnboardingStatus().then(res => { + if (res === Error || res.onboarded === false) { + router.push('/onboarding/choose-cloud'); + } + }); + settingsService.getCloudAccounts().then(res => { if (!loading) { setLoading(true); diff --git a/dashboard/services/settingsService.ts b/dashboard/services/settingsService.ts index 8ebd2d28d..bde278fb1 100644 --- a/dashboard/services/settingsService.ts +++ b/dashboard/services/settingsService.ts @@ -408,6 +408,16 @@ const settingsService = { } catch (error) { return Error; } + }, + + async getOnboardingStatus() { + try { + const res = await fetch(`${BASE_URL}/is_onboarded`, settings('GET')); + const data = await res.json(); + return data; + } catch (error) { + return Error; + } } };