From 1b0d94372155053977b9d881fd9e6319dc9a6f27 Mon Sep 17 00:00:00 2001 From: Ananya Nayak Date: Mon, 19 Jun 2023 08:58:26 +0000 Subject: [PATCH 01/89] ci: added paths-ignore option --- .github/workflows/tests.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aaac70173..4abdcee24 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,8 +3,18 @@ name: Tests on: push: branches: [main] + paths-ignore: + - "**/*.md" + - ".prettierrc" + - ".npmrc" + - ".gitignore" pull_request: branches: [main] + paths-ignore: + - "**/*.md" + - ".prettierrc" + - ".npmrc" + - ".gitignore" env: VITE_APPWRITE_ENDPOINT: http://appwrite.test/v1 From c53c845641f25c55cc5a78ec8567cd2891948b37 Mon Sep 17 00:00:00 2001 From: Ananya Nayak Date: Sun, 13 Aug 2023 10:41:58 +0530 Subject: [PATCH 02/89] ci: ignore assets during tests workflow --- .github/workflows/tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4abdcee24..76ba7543a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,6 +8,10 @@ on: - ".prettierrc" - ".npmrc" - ".gitignore" + - ".env.example" + - ".eslintrc.cjs" + - ".eslintignore" + - "static/*" pull_request: branches: [main] paths-ignore: @@ -15,6 +19,10 @@ on: - ".prettierrc" - ".npmrc" - ".gitignore" + - ".env.example" + - ".eslintrc.cjs" + - ".eslintignore" + - "static/*" env: VITE_APPWRITE_ENDPOINT: http://appwrite.test/v1 From adbbe45b568c5ed6ec63592281a5e63fbf50679d Mon Sep 17 00:00:00 2001 From: Ananya Nayak Date: Sun, 13 Aug 2023 10:41:58 +0530 Subject: [PATCH 03/89] ci: ignore assets during tests workflow --- .github/workflows/tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4abdcee24..aca5daad5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,6 +8,10 @@ on: - ".prettierrc" - ".npmrc" - ".gitignore" + - ".env.example" + - ".eslintrc.cjs" + - ".eslintignore" + - "static/**/*" pull_request: branches: [main] paths-ignore: @@ -15,6 +19,10 @@ on: - ".prettierrc" - ".npmrc" - ".gitignore" + - ".env.example" + - ".eslintrc.cjs" + - ".eslintignore" + - "static/**/*" env: VITE_APPWRITE_ENDPOINT: http://appwrite.test/v1 From 6c0683f4035fb01efa82bec5899d0536d7867741 Mon Sep 17 00:00:00 2001 From: Amit Gurbani Date: Fri, 20 Oct 2023 20:44:48 +0530 Subject: [PATCH 04/89] Fix: Clear Datetime Attribute --- src/lib/elements/forms/inputDateTime.svelte | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/elements/forms/inputDateTime.svelte b/src/lib/elements/forms/inputDateTime.svelte index cd13a5f65..15eeaf2ae 100644 --- a/src/lib/elements/forms/inputDateTime.svelte +++ b/src/lib/elements/forms/inputDateTime.svelte @@ -6,7 +6,7 @@ export let showLabel = true; export let optionalText: string | undefined = undefined; export let id: string; - export let value = ''; + export let value: string; export let required = false; export let disabled = false; export let readonly = false; @@ -33,6 +33,11 @@ error = element.validationMessage; } + function handleInput(event: Event) { + const { value: currentValue } = event.currentTarget as HTMLInputElement; + value = currentValue || null; + } + $: if (value) { error = null; } @@ -49,12 +54,13 @@ {disabled} {readonly} {required} + {value} step=".001" autocomplete={autocomplete ? 'on' : 'off'} type="datetime-local" class="input-text" - bind:value bind:this={element} + on:input={handleInput} on:invalid={handleInvalid} /> {#if error} From 2ccd44316a57781cf0ea8ed4cc0858377b89289c Mon Sep 17 00:00:00 2001 From: Elad Shechter Date: Thu, 14 Dec 2023 11:59:34 +0700 Subject: [PATCH 05/89] Floating Action Bar - Was using old variable color name and was transparent. Now got the updated color names variables --- src/lib/components/floatingActionBar.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/components/floatingActionBar.svelte b/src/lib/components/floatingActionBar.svelte index 066852314..28b7a8e3b 100644 --- a/src/lib/components/floatingActionBar.svelte +++ b/src/lib/components/floatingActionBar.svelte @@ -26,13 +26,13 @@ } :global(.theme-dark) .floating-action-bar { - border: 1px solid hsl(var(--color-neutral-200)); - background: hsl(var(--color-neutral-300)); + border: 1px solid hsl(var(--color-neutral-85)); + background: hsl(var(--color-neutral-90)); box-shadow: 0px 6px 16px 8px #14141f; } :global(.theme-light) .floating-action-bar { - border: 1px solid hsl(var(--color-neutral-30)); + border: 1px solid hsl(var(--color-neutral-15)); background: hsl(var(--color-neutral-0)); box-shadow: 0px 6px 16px 0px rgba(55, 59, 77, 0.14); } From 9a1fc8a99a90f3930feb7a0ddde91cf830028eb1 Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 15 Dec 2023 22:31:19 +0100 Subject: [PATCH 06/89] fix: 9 months old bug --- .../console/project-[project]/overview/platforms/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/overview/platforms/+page.svelte b/src/routes/console/project-[project]/overview/platforms/+page.svelte index 213f33179..b7f8dfab0 100644 --- a/src/routes/console/project-[project]/overview/platforms/+page.svelte +++ b/src/routes/console/project-[project]/overview/platforms/+page.svelte @@ -155,7 +155,7 @@ addPlatform(Platform.Web)}> Web - Ï + addPlatform(Platform.Flutter)}> Flutter From 0bfd4ab90b50dd2bf3e62ae3c7f16d17e0a6b0c7 Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 15 Dec 2023 23:05:41 +0100 Subject: [PATCH 07/89] fix: align icons right, add column joined --- src/lib/elements/table/cell.svelte | 6 +++++- .../organization-[organization]/members/+page.svelte | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/elements/table/cell.svelte b/src/lib/elements/table/cell.svelte index fb1a80861..ba3f04ea5 100644 --- a/src/lib/elements/table/cell.svelte +++ b/src/lib/elements/table/cell.svelte @@ -6,13 +6,17 @@ let className = ''; export { className as class }; export let style = ''; + export let right = false;
diff --git a/src/routes/console/organization-[organization]/members/+page.svelte b/src/routes/console/organization-[organization]/members/+page.svelte index c769fe3f7..615c6c388 100644 --- a/src/routes/console/organization-[organization]/members/+page.svelte +++ b/src/routes/console/organization-[organization]/members/+page.svelte @@ -22,6 +22,7 @@ import type { Models } from '@appwrite.io/console'; import type { PageData } from './$types'; import Delete from '../deleteMember.svelte'; + import { toLocaleDate } from '$lib/helpers/date'; export let data: PageData; @@ -68,6 +69,7 @@ Name Email + Joined @@ -86,6 +88,9 @@
{member.userEmail} + + {member.joined ? toLocaleDate(member.joined) : ''} + {#if member.invited && !member.joined} {/if} - +

- {#if freeOrgs.length > 1 && options.length} + {#if freeOrgs?.length > 1 && options?.length} Date: Tue, 19 Dec 2023 10:57:34 +0100 Subject: [PATCH 15/89] chore: remove console logs --- src/routes/console/+layout.svelte | 14 +++++--------- .../billing/planSummary.svelte | 2 -- .../billing/wizard/addCredit.svelte | 1 - .../billing/wizard/paymentDetails.svelte | 2 +- .../wizard/cloudOrganization/paymentDetails.svelte | 2 +- src/routes/login/+page.svelte | 2 -- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index e36491bd8..23aa1c61e 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -248,16 +248,12 @@ if (isCloud) { if (!$page.url.pathname.includes('/console/onboarding')) { - try { - const orgs = await sdk.forConsole.teams.list([ - Query.equal('billingPlan', 'tier-0') - ]); + const orgs = await sdk.forConsole.teams.list([ + Query.equal('billingPlan', 'tier-0') + ]); - checkForPostReleaseProModal(orgs); - checkForFreeOrgOverflow(orgs); - } catch (error) { - console.log(error); - } + checkForPostReleaseProModal(orgs); + checkForFreeOrgOverflow(orgs); } } diff --git a/src/routes/console/organization-[organization]/billing/planSummary.svelte b/src/routes/console/organization-[organization]/billing/planSummary.svelte index 0134165e8..a756fa509 100644 --- a/src/routes/console/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/console/organization-[organization]/billing/planSummary.svelte @@ -28,8 +28,6 @@ $: currentPlan = $plansInfo.plans.find((p) => p.$id === $organization?.billingPlan); $: extraUsage = currentInvoice?.amount - currentPlan?.price; $: isTrial = new Date($organization?.billingTrialEndDate).getTime() - today.getTime() > 0; - - $: console.log(currentInvoice); {#if $organization} diff --git a/src/routes/console/organization-[organization]/billing/wizard/addCredit.svelte b/src/routes/console/organization-[organization]/billing/wizard/addCredit.svelte index 873d13dda..3e4a3707b 100644 --- a/src/routes/console/organization-[organization]/billing/wizard/addCredit.svelte +++ b/src/routes/console/organization-[organization]/billing/wizard/addCredit.svelte @@ -20,7 +20,6 @@ couponData = response; coupon = null; } catch (error) { - console.log('test'); couponData.code = coupon; couponData.status = 'error'; $wizard.interceptorNotificationEnabled = false; diff --git a/src/routes/console/organization-[organization]/billing/wizard/paymentDetails.svelte b/src/routes/console/organization-[organization]/billing/wizard/paymentDetails.svelte index d00904dee..b4f54264d 100644 --- a/src/routes/console/organization-[organization]/billing/wizard/paymentDetails.svelte +++ b/src/routes/console/organization-[organization]/billing/wizard/paymentDetails.svelte @@ -25,7 +25,7 @@ $addCreditWizardStore.paymentMethodId = method.$id; invalidate(Dependencies.PAYMENT_METHODS); } catch (e) { - console.log(e.message); + throw new Error('Something went wrong. Please try again.'); } } diff --git a/src/routes/console/wizard/cloudOrganization/paymentDetails.svelte b/src/routes/console/wizard/cloudOrganization/paymentDetails.svelte index a6c8135f5..5dc5821b0 100644 --- a/src/routes/console/wizard/cloudOrganization/paymentDetails.svelte +++ b/src/routes/console/wizard/cloudOrganization/paymentDetails.svelte @@ -35,7 +35,7 @@ $createOrganization.paymentMethodId = method.$id; invalidate(Dependencies.PAYMENT_METHODS); } catch (e) { - console.log(e.message); + throw new Error('Something went wrong. Please try again.'); } } diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index faf9afd07..7d4da5a0d 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -19,8 +19,6 @@ let mail: string, pass: string, disabled: boolean; - $: console.log($page.url.search); - async function login() { try { disabled = true; From 4b4904332814165611c16168056bc1ff81643322 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 19 Dec 2023 11:54:54 +0100 Subject: [PATCH 16/89] fix: headerAlert not loading, and payment required iframe not loading --- .../billing/alerts/paymentAuthRequired.svelte | 4 ++-- src/lib/stores/billing.ts | 8 +++++--- src/routes/console/+layout.svelte | 9 ++++----- .../billing/+page.svelte | 17 ++++++----------- .../billing/replaceCard.svelte | 5 +++-- src/routes/console/store.ts | 3 +++ 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/lib/components/billing/alerts/paymentAuthRequired.svelte b/src/lib/components/billing/alerts/paymentAuthRequired.svelte index c83e9bca4..d8819b492 100644 --- a/src/lib/components/billing/alerts/paymentAuthRequired.svelte +++ b/src/lib/components/billing/alerts/paymentAuthRequired.svelte @@ -9,8 +9,8 @@ const endpoint = VARS.APPWRITE_ENDPOINT ?? `${$page.url.origin}/v1`; -{#if $actionRequiredInvoices && $actionRequiredInvoices.total && !$page.url.pathname.includes('/console/account')} - +{#if $actionRequiredInvoices && $actionRequiredInvoices?.invoices?.length && !$page.url.pathname.includes('/console/account')} + Please authorize your upcoming payment for {$organization.name}. Your bank requires this security measure to proceed with payment. diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 67a1c3783..d139f71c6 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -13,7 +13,7 @@ import { addNotification, notifications } from './notifications'; import { goto } from '$app/navigation'; import { base } from '$app/paths'; import TooManyFreOrgs from '$lib/components/billing/alerts/tooManyFreeOrgs.svelte'; -import { showPostReleaseModal } from '$routes/console/store'; +import { activeHeaderAlert, showPostReleaseModal } from '$routes/console/store'; import MarkedForDeletion from '$lib/components/billing/alerts/markedForDeletion.svelte'; export type Tier = 'tier-0' | 'tier-1' | 'tier-2'; @@ -207,8 +207,7 @@ export async function checkPaymentAuthorizationRequired(org: Organization) { Query.equal('status', 'requires_authentication') ]); - actionRequiredInvoices.set(invoices); - if (get(actionRequiredInvoices) && get(actionRequiredInvoices)?.invoices?.length > 0) { + if (invoices?.invoices?.length > 0) { headerAlert.add({ id: 'paymentAuthRequired', component: PaymentAuthRequired, @@ -216,6 +215,9 @@ export async function checkPaymentAuthorizationRequired(org: Organization) { importance: 8 }); } + activeHeaderAlert.set(headerAlert.get()); + + actionRequiredInvoices.set(invoices); } export async function paymentExpired(org: Organization) { diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index 23aa1c61e..479647d18 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -42,7 +42,7 @@ import ExcesLimitModal from './organization-[organization]/excesLimitModal.svelte'; import { showExcess } from './organization-[organization]/store'; import UsageRates from './wizard/cloudOrganization/usageRates.svelte'; - import { consoleVariables, showPostReleaseModal } from './store'; + import { activeHeaderAlert, consoleVariables, showPostReleaseModal } from './store'; import { Query } from '@appwrite.io/console'; import { headerAlert } from '$lib/stores/headerAlert'; import PostReleaseModal from './(billing-modal)/postReleaseModal.svelte'; @@ -242,7 +242,6 @@ } ]); let isOpen = false; - let selectedHeaderAlert = headerAlert.get(); onMount(async () => { loading.set(false); @@ -303,7 +302,7 @@ $registerSearchers(orgSearcher, projectsSearcher); afterUpdate(() => { - selectedHeaderAlert = headerAlert.get(); + $activeHeaderAlert = headerAlert.get(); }); @@ -317,8 +316,8 @@ !$page.url.pathname.includes('/console/card') && !$page.url.pathname.includes('/console/onboarding')}> - {#if selectedHeaderAlert?.show} - + {#if $activeHeaderAlert?.show} + {/if}
diff --git a/src/routes/console/organization-[organization]/billing/+page.svelte b/src/routes/console/organization-[organization]/billing/+page.svelte index eedb477da..422b97f71 100644 --- a/src/routes/console/organization-[organization]/billing/+page.svelte +++ b/src/routes/console/organization-[organization]/billing/+page.svelte @@ -14,7 +14,7 @@ import type { PaymentMethodData } from '$lib/sdk/billing'; import { onMount } from 'svelte'; import { page } from '$app/stores'; - import { confirmPayment, initializeStripe, isStripeInitialized } from '$lib/stores/stripe'; + import { confirmPayment } from '$lib/stores/stripe'; import { sdk } from '$lib/stores/sdk'; import { toLocaleDate } from '$lib/helpers/date'; import { wizard } from '$lib/stores/wizard'; @@ -35,21 +35,12 @@ ) { wizard.start(ChangeOrganizationTierCloud); } - if ($page.url.searchParams.has('clientSecret')) { - if (!$isStripeInitialized) { - await initializeStripe(); - } - const clientSecret = $page.url.searchParams.get('clientSecret'); - await confirmPayment($organization.$id, clientSecret, $organization.paymentMethodId); - } + if ( $page.url.searchParams.has('invoice') && $page.url.searchParams.has('type') && $page.url.searchParams.get('type') === 'confirmation' ) { - if (!$isStripeInitialized) { - await initializeStripe(); - } const invoiceId = $page.url.searchParams.get('invoice'); const invoice = await sdk.forConsole.billing.getInvoice( $page.params.organization, @@ -62,6 +53,10 @@ $organization.paymentMethodId ); } + if ($page.url.searchParams.has('clientSecret')) { + const clientSecret = $page.url.searchParams.get('clientSecret'); + await confirmPayment($organization.$id, clientSecret, $organization.paymentMethodId); + } }); diff --git a/src/routes/console/organization-[organization]/billing/replaceCard.svelte b/src/routes/console/organization-[organization]/billing/replaceCard.svelte index c68e64bee..8dfc4fe50 100644 --- a/src/routes/console/organization-[organization]/billing/replaceCard.svelte +++ b/src/routes/console/organization-[organization]/billing/replaceCard.svelte @@ -49,8 +49,6 @@ } } }); - - observer.observe(element, { childList: true }); }); onDestroy(() => { @@ -115,6 +113,9 @@ $: if (show) { isStripeInitialized.set(false); + if (element) { + observer.observe(element, { childList: true }); + } } $: if (!show) { diff --git a/src/routes/console/store.ts b/src/routes/console/store.ts index 122918505..af3eb65ee 100644 --- a/src/routes/console/store.ts +++ b/src/routes/console/store.ts @@ -1,4 +1,5 @@ import { page } from '$app/stores'; +import type { HeaderAlert } from '$lib/stores/headerAlert'; import type { Models } from '@appwrite.io/console'; import { derived, writable } from 'svelte/store'; @@ -9,3 +10,5 @@ export const consoleVariables = derived( ); export const showPostReleaseModal = writable(false); + +export const activeHeaderAlert = writable(null); From 6b2e28fcf5de9894b22ce96c7920c9f4c6e96565 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 19 Dec 2023 13:51:08 +0100 Subject: [PATCH 17/89] fix: review --- .../billing/availableCredit.svelte | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/routes/console/organization-[organization]/billing/availableCredit.svelte b/src/routes/console/organization-[organization]/billing/availableCredit.svelte index 0c2b20ac6..753e389d7 100644 --- a/src/routes/console/organization-[organization]/billing/availableCredit.svelte +++ b/src/routes/console/organization-[organization]/billing/availableCredit.svelte @@ -27,9 +27,7 @@ let show = false; let reloadOnWizardClose = false; - onMount(async () => { - request(); - }); + onMount(request); const limit = 5; From 50448fbc5b12cf4e7f62f157a7c806a3dab634aa Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 19 Dec 2023 14:17:46 +0100 Subject: [PATCH 18/89] chore: remove imports --- src/lib/components/billing/alerts/tooManyFreeOrgs.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte index f8c18e34c..f5fa340d4 100644 --- a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte +++ b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte @@ -1,6 +1,4 @@ From afe700ee7dcb1d2c5dc43fe08102d8b1cc72cd98 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 19 Dec 2023 16:30:04 +0100 Subject: [PATCH 19/89] fix: two col modal --- src/lib/components/modalSideCol.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/modalSideCol.svelte b/src/lib/components/modalSideCol.svelte index 4e12602ab..81dbe2464 100644 --- a/src/lib/components/modalSideCol.svelte +++ b/src/lib/components/modalSideCol.svelte @@ -10,7 +10,7 @@
-
+
From c38bb98347684099b99176183ed2beacb96d4e13 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 19 Dec 2023 17:51:20 +0100 Subject: [PATCH 20/89] fix: add check for wrong cards --- .../cloudOrganization/paymentDetails.svelte | 35 +++++++++++--- .../paymentDetails.svelte | 46 +++++++++++++------ 2 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/routes/console/wizard/cloudOrganization/paymentDetails.svelte b/src/routes/console/wizard/cloudOrganization/paymentDetails.svelte index 5dc5821b0..b9378f5f1 100644 --- a/src/routes/console/wizard/cloudOrganization/paymentDetails.svelte +++ b/src/routes/console/wizard/cloudOrganization/paymentDetails.svelte @@ -19,23 +19,44 @@ let methods: PaymentList; let name: string; let budgetEnabled = false; + let initialPaymentMethodId: string; onMount(async () => { methods = await sdk.forConsole.billing.listPaymentMethods(); - $createOrganization.paymentMethodId = + initialPaymentMethodId = methods.paymentMethods.find((method) => !!method?.last4)?.$id ?? null; + $createOrganization.paymentMethodId = initialPaymentMethodId; }); async function handleSubmit() { if ($createOrganization.billingBudget < 0) { throw new Error('Budget cannot be negative'); } - try { - const method = await submitStripeCard(name); - $createOrganization.paymentMethodId = method.$id; - invalidate(Dependencies.PAYMENT_METHODS); - } catch (e) { - throw new Error('Something went wrong. Please try again.'); + if ($createOrganization.paymentMethodId) { + const card = await sdk.forConsole.billing.getPaymentMethod( + $createOrganization.paymentMethodId + ); + if (!card?.last4) { + throw new Error( + 'The payment method you selected is not valid. Please select a different one.' + ); + } + } else { + try { + const method = await submitStripeCard(name); + const card = await sdk.forConsole.billing.getPaymentMethod(method.$id); + if (card?.last4) { + $createOrganization.paymentMethodId = card.$id; + } else { + throw new Error( + 'The payment method you selected is not valid. Please select a different one.' + ); + } + invalidate(Dependencies.PAYMENT_METHODS); + } catch (e) { + $createOrganization.paymentMethodId = initialPaymentMethodId; + throw new Error(e.message); + } } } diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte index 4a0e90c6e..b82943719 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/paymentDetails.svelte @@ -18,16 +18,17 @@ let filteredMethods: PaymentMethodData[]; let name: string; let budgetEnabled = false; - + let initialPaymentMethodId: string; onMount(async () => { methods = await sdk.forConsole.billing.listPaymentMethods(); filteredMethods = methods?.paymentMethods.filter((method) => !!method?.last4); - $changeOrganizationTier.paymentMethodId = + initialPaymentMethodId = $organization?.paymentMethodId ?? $organization?.backupPaymentMethodId ?? filteredMethods[0]?.$id ?? null; + $changeOrganizationTier.paymentMethodId = initialPaymentMethodId; $changeOrganizationTier.billingBudget = $organization?.billingBudget; budgetEnabled = !!$organization?.billingBudget; }); @@ -36,19 +37,36 @@ if ($changeOrganizationTier.billingBudget < 0) { throw new Error('Budget cannot be negative'); } + if ($changeOrganizationTier.paymentMethodId) { + const card = await sdk.forConsole.billing.getPaymentMethod( + $changeOrganizationTier.paymentMethodId + ); + if (!card?.last4) { + throw new Error( + 'The payment method you selected is not valid. Please select a different one.' + ); + } + } else { + try { + await submitStripeCard(name); + const latestMethods = await sdk.forConsole.billing.listPaymentMethods(); + const paymentMethod = symmetricDifference( + methods.paymentMethods, + latestMethods.paymentMethods + )[0] as PaymentMethodData; + const card = await sdk.forConsole.billing.getPaymentMethod(paymentMethod.$id); + if (card?.last4) { + $changeOrganizationTier.paymentMethodId = paymentMethod.$id; + } else { + throw new Error( + 'The payment method you selected is not valid. Please select a different one.' + ); + } - try { - await submitStripeCard(name); - const latestMethods = await sdk.forConsole.billing.listPaymentMethods(); - const paymentMethod = symmetricDifference( - methods.paymentMethods, - latestMethods.paymentMethods - )[0] as PaymentMethodData; - - $changeOrganizationTier.paymentMethodId = paymentMethod.$id; - invalidate(Dependencies.PAYMENT_METHODS); - } catch (e) { - throw new Error(e.message); + invalidate(Dependencies.PAYMENT_METHODS); + } catch (e) { + throw new Error(e.message); + } } } From 9c362e99b0ebf546f4b505070e790c120f3b6e2a Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 19 Dec 2023 18:37:23 +0100 Subject: [PATCH 21/89] fix: center component --- src/lib/layout/containerHeader.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/layout/containerHeader.svelte b/src/lib/layout/containerHeader.svelte index 4411b6f81..08a7813f1 100644 --- a/src/lib/layout/containerHeader.svelte +++ b/src/lib/layout/containerHeader.svelte @@ -102,7 +102,7 @@ {/if}
-
+
{title} {#if isCloud && isLimited} From b66740faabfe34fba490f5b0363de40c51242b00 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 19 Dec 2023 18:41:18 +0100 Subject: [PATCH 22/89] fix: observer --- src/lib/components/billing/paymentBoxes.svelte | 6 ++++-- src/routes/console/account/payments/paymentModal.svelte | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/components/billing/paymentBoxes.svelte b/src/lib/components/billing/paymentBoxes.svelte index 62170b813..c6ead8911 100644 --- a/src/lib/components/billing/paymentBoxes.svelte +++ b/src/lib/components/billing/paymentBoxes.svelte @@ -29,13 +29,15 @@ } } }); - - observer.observe(element, { childList: true }); }); onDestroy(() => { observer.disconnect(); }); + + $: if (element) { + observer.observe(element, { childList: true }); + } diff --git a/src/routes/console/account/payments/paymentModal.svelte b/src/routes/console/account/payments/paymentModal.svelte index 02390978b..abe6767fe 100644 --- a/src/routes/console/account/payments/paymentModal.svelte +++ b/src/routes/console/account/payments/paymentModal.svelte @@ -55,14 +55,16 @@ } } }); - - observer.observe(element, { childList: true }); }); onDestroy(() => { observer.disconnect(); document.documentElement.classList.remove('u-overflow-hidden'); }); + + $: if (element) { + observer.observe(element, { childList: true }); + } From 0e0e27d48f7cf5862c722648bcfd1c7da686e723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 19 Dec 2023 20:20:47 +0100 Subject: [PATCH 23/89] Fix redirect --- src/routes/console/(billing-modal)/postReleaseModal.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/console/(billing-modal)/postReleaseModal.svelte b/src/routes/console/(billing-modal)/postReleaseModal.svelte index c303698cf..145da0c9a 100644 --- a/src/routes/console/(billing-modal)/postReleaseModal.svelte +++ b/src/routes/console/(billing-modal)/postReleaseModal.svelte @@ -25,10 +25,10 @@ async function handleUpgrade() { if (selectedOrg) { - await goto(`${base}/console/organization/${selectedOrg}/billing`); + await goto(`${base}/console/organization-${selectedOrg}/billing`); } else { const freeOrg = orgs.teams.find((o) => o.billingPlan === 'tier-0'); - await goto(`${base}/console/organization/${freeOrg.$id}/billing`); + await goto(`${base}/console/organization-${freeOrg.$id}/billing`); } show = false; wizard.start(ChangeOrganizationTierCloud); From 41e8f1124588f4eac328fe78d0fae2d3772b3422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 19 Dec 2023 20:38:53 +0100 Subject: [PATCH 24/89] Fix error page on usage --- .../usage/[[invoice]]/+page.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts index 176d456fe..d80e5d919 100644 --- a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts +++ b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts @@ -41,12 +41,16 @@ export const load: PageLoad = async ({ params, parent }) => { sdk.forConsole.billing.listUsage(params.organization, startDate, endDate) ]); - const projectNames = await sdk.forConsole.projects.list([ - Query.equal( + const queries: string[] = []; + + if(usage.projects.length > 0) { + queries.push(Query.equal( '$id', usage.projects.map((p) => p.projectId) - ) - ]); + )); + } + + const projectNames = await sdk.forConsole.projects.list(queries); return { organizationUsage: usage, From 19209dd2d32b0c39438232a23026074bf99af2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 19 Dec 2023 20:44:14 +0100 Subject: [PATCH 25/89] Fix linter --- .../usage/[[invoice]]/+page.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts index d80e5d919..8f5203de9 100644 --- a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts +++ b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts @@ -43,11 +43,13 @@ export const load: PageLoad = async ({ params, parent }) => { const queries: string[] = []; - if(usage.projects.length > 0) { - queries.push(Query.equal( - '$id', - usage.projects.map((p) => p.projectId) - )); + if (usage.projects.length > 0) { + queries.push( + Query.equal( + '$id', + usage.projects.map((p) => p.projectId) + ) + ); } const projectNames = await sdk.forConsole.projects.list(queries); From 31a33a43ed30a91b33a1e68bfd3e17206d3359d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 19 Dec 2023 20:47:21 +0100 Subject: [PATCH 26/89] Fix missing error --- src/routes/console/changeOrganizationTierCloud.svelte | 2 +- src/routes/console/createOrganizationCloud.svelte | 2 +- .../organization-[organization]/billing/addCreditWizard.svelte | 2 +- .../organization-[organization]/createProjectCloud.svelte | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte index 44d28677b..8d7e22381 100644 --- a/src/routes/console/changeOrganizationTierCloud.svelte +++ b/src/routes/console/changeOrganizationTierCloud.svelte @@ -174,7 +174,7 @@ } catch (e) { addNotification({ type: 'error', - message: e.mesage + message: e.message }); trackError( e, diff --git a/src/routes/console/createOrganizationCloud.svelte b/src/routes/console/createOrganizationCloud.svelte index acc6018a8..40bc62dd2 100644 --- a/src/routes/console/createOrganizationCloud.svelte +++ b/src/routes/console/createOrganizationCloud.svelte @@ -106,7 +106,7 @@ } catch (e) { addNotification({ type: 'error', - message: e.mesage + message: e.message }); trackError(e, Submit.OrganizationCreate); } diff --git a/src/routes/console/organization-[organization]/billing/addCreditWizard.svelte b/src/routes/console/organization-[organization]/billing/addCreditWizard.svelte index f94676a37..5b4029d34 100644 --- a/src/routes/console/organization-[organization]/billing/addCreditWizard.svelte +++ b/src/routes/console/organization-[organization]/billing/addCreditWizard.svelte @@ -38,7 +38,7 @@ } catch (e) { addNotification({ type: 'error', - message: e.mesage + message: e.message }); trackError(e, Submit.CreditRedeem); } diff --git a/src/routes/console/organization-[organization]/createProjectCloud.svelte b/src/routes/console/organization-[organization]/createProjectCloud.svelte index cc78d87f4..03dc414a8 100644 --- a/src/routes/console/organization-[organization]/createProjectCloud.svelte +++ b/src/routes/console/organization-[organization]/createProjectCloud.svelte @@ -42,7 +42,7 @@ } catch (e) { addNotification({ type: 'error', - message: e.mesage + message: e.message }); trackError(e, Submit.ProjectCreate); } From b09267c251af4cf67820531968eccb4a371ee5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 19 Dec 2023 20:59:18 +0100 Subject: [PATCH 27/89] Fix empty zip --- src/routes/console/account/payments/addressModal.svelte | 2 +- src/routes/console/account/payments/editAddressModal.svelte | 6 +++++- src/routes/console/changeOrganizationTierCloud.svelte | 4 +++- src/routes/console/createOrganizationCloud.svelte | 4 +++- .../billing/replaceAddress.svelte | 5 +++-- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/routes/console/account/payments/addressModal.svelte b/src/routes/console/account/payments/addressModal.svelte index 3a92e8c2a..fbeb783af 100644 --- a/src/routes/console/account/payments/addressModal.svelte +++ b/src/routes/console/account/payments/addressModal.svelte @@ -47,7 +47,7 @@ address, city, state, - zip, + zip ? zip : undefined, address2 ? address2 : undefined ); trackEvent(Submit.BillingAddressCreate); diff --git a/src/routes/console/account/payments/editAddressModal.svelte b/src/routes/console/account/payments/editAddressModal.svelte index 3ad0772d9..975288ae3 100644 --- a/src/routes/console/account/payments/editAddressModal.svelte +++ b/src/routes/console/account/payments/editAddressModal.svelte @@ -22,6 +22,10 @@ onMount(async () => { const countryList = await sdk.forProject.locale.listCountries(); + const locale = await sdk.forProject.locale.get(); + if (locale.countryCode) { + country = locale.countryCode; + } options = countryList.countries.map((country) => { return { value: country.code, @@ -38,7 +42,7 @@ selectedAddress.streetAddress, selectedAddress.city, selectedAddress.state, - selectedAddress.postalCode, + selectedAddress.postalCode ? selectedAddress.postalCode : undefined, selectedAddress.addressLine2 ? selectedAddress.addressLine2 : undefined ); await invalidate(Dependencies.ADDRESS); diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte index 44d28677b..a11806747 100644 --- a/src/routes/console/changeOrganizationTierCloud.svelte +++ b/src/routes/console/changeOrganizationTierCloud.svelte @@ -96,7 +96,9 @@ $changeOrganizationTier.billingAddress.streetAddress, $changeOrganizationTier.billingAddress.city, $changeOrganizationTier.billingAddress.state, - $changeOrganizationTier.billingAddress.postalCode, + $changeOrganizationTier.billingAddress.postalCode + ? $changeOrganizationTier.billingAddress.postalCode + : undefined, $changeOrganizationTier.billingAddress.addressLine2 ? $changeOrganizationTier.billingAddress.addressLine2 : undefined diff --git a/src/routes/console/createOrganizationCloud.svelte b/src/routes/console/createOrganizationCloud.svelte index acc6018a8..a40f68fdb 100644 --- a/src/routes/console/createOrganizationCloud.svelte +++ b/src/routes/console/createOrganizationCloud.svelte @@ -49,7 +49,9 @@ $createOrganization.billingAddress.streetAddress, $createOrganization.billingAddress.city, $createOrganization.billingAddress.state, - $createOrganization.billingAddress.postalCode, + $createOrganization.billingAddress.postalCode + ? $createOrganization.billingAddress.postalCode + : undefined, $createOrganization.billingAddress.addressLine2 ? $createOrganization.billingAddress.addressLine2 : undefined diff --git a/src/routes/console/organization-[organization]/billing/replaceAddress.svelte b/src/routes/console/organization-[organization]/billing/replaceAddress.svelte index 75dfae08a..0eb06bbef 100644 --- a/src/routes/console/organization-[organization]/billing/replaceAddress.svelte +++ b/src/routes/console/organization-[organization]/billing/replaceAddress.svelte @@ -27,6 +27,7 @@ label: 'United States' } ]; + onMount(async () => { addresses = await sdk.forConsole.billing.listAddresses(); @@ -61,8 +62,8 @@ streetAddress, city, state, - postalCode, - addressLine2 + postalCode ? postalCode : undefined, + addressLine2 ? postalCode : undefined ); await sdk.forConsole.billing.setBillingAddress($organization.$id, address.$id); From d935b06bdda894e76a53d01de83a762ffc24ca62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 19 Dec 2023 21:02:30 +0100 Subject: [PATCH 28/89] Fix bug --- src/routes/console/account/payments/editAddressModal.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/account/payments/editAddressModal.svelte b/src/routes/console/account/payments/editAddressModal.svelte index 975288ae3..bea14ab0e 100644 --- a/src/routes/console/account/payments/editAddressModal.svelte +++ b/src/routes/console/account/payments/editAddressModal.svelte @@ -24,7 +24,7 @@ const countryList = await sdk.forProject.locale.listCountries(); const locale = await sdk.forProject.locale.get(); if (locale.countryCode) { - country = locale.countryCode; + selectedAddress.country = locale.countryCode; } options = countryList.countries.map((country) => { return { From ecedef8eb2d6d91ca956bc3dfed4d54675d634b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 19 Dec 2023 21:13:02 +0100 Subject: [PATCH 29/89] Add aspect ratio to hoodie giveaway --- src/routes/console/(billing-modal)/hoodieCover.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/(billing-modal)/hoodieCover.svelte b/src/routes/console/(billing-modal)/hoodieCover.svelte index 63dae4986..a2e886d72 100644 --- a/src/routes/console/(billing-modal)/hoodieCover.svelte +++ b/src/routes/console/(billing-modal)/hoodieCover.svelte @@ -98,7 +98,7 @@
- +
Date: Tue, 19 Dec 2023 21:15:45 +0100 Subject: [PATCH 30/89] Code formatting --- src/routes/console/(billing-modal)/hoodieCover.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/routes/console/(billing-modal)/hoodieCover.svelte b/src/routes/console/(billing-modal)/hoodieCover.svelte index a2e886d72..dbad9e24d 100644 --- a/src/routes/console/(billing-modal)/hoodieCover.svelte +++ b/src/routes/console/(billing-modal)/hoodieCover.svelte @@ -98,7 +98,12 @@
- +
Date: Wed, 20 Dec 2023 10:28:35 +0100 Subject: [PATCH 31/89] fix: usage page broken when no projects --- .../organization-[organization]/usage/[[invoice]]/+page.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts index 8f5203de9..b1ef9a272 100644 --- a/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts +++ b/src/routes/console/organization-[organization]/usage/[[invoice]]/+page.ts @@ -43,7 +43,7 @@ export const load: PageLoad = async ({ params, parent }) => { const queries: string[] = []; - if (usage.projects.length > 0) { + if (usage?.projects?.length > 0) { queries.push( Query.equal( '$id', From 759cf2b924cb2aa2ea4327fb596b23cff6a42258 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 10:32:01 +0100 Subject: [PATCH 32/89] fix: `de` to `fra` --- src/lib/sdk/billing.ts | 2 +- src/routes/console/onboarding/+page.svelte | 2 +- .../organization-[organization]/createProjectCloud.svelte | 2 +- src/routes/console/organization-[organization]/wizard/store.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 7f535263d..32f6f0a2b 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -185,7 +185,7 @@ export type AggregationList = { }; export type AllowedRegions = - | 'eu-de' + | 'eu-fra' | 'us-nyc' | 'us-sfo' | 'ap-in' diff --git a/src/routes/console/onboarding/+page.svelte b/src/routes/console/onboarding/+page.svelte index 244d86136..c2b26314e 100644 --- a/src/routes/console/onboarding/+page.svelte +++ b/src/routes/console/onboarding/+page.svelte @@ -39,7 +39,7 @@ id ?? ID.unique(), name, org.$id, - isCloud ? 'eu-de' : 'default' + isCloud ? 'eu-fra' : 'default' ); await invalidate(Dependencies.ACCOUNT); goto(`/console/project-${project.$id}`); diff --git a/src/routes/console/organization-[organization]/createProjectCloud.svelte b/src/routes/console/organization-[organization]/createProjectCloud.svelte index 03dc414a8..6128fea00 100644 --- a/src/routes/console/organization-[organization]/createProjectCloud.svelte +++ b/src/routes/console/organization-[organization]/createProjectCloud.svelte @@ -52,7 +52,7 @@ $createProject = { id: null, name: null, - region: 'eu-de' + region: 'eu-fra' }; }); diff --git a/src/routes/console/organization-[organization]/wizard/store.ts b/src/routes/console/organization-[organization]/wizard/store.ts index d171e8202..5bcbc4472 100644 --- a/src/routes/console/organization-[organization]/wizard/store.ts +++ b/src/routes/console/organization-[organization]/wizard/store.ts @@ -7,5 +7,5 @@ export const createProject = writable<{ }>({ id: null, name: null, - region: 'eu-de' + region: 'eu-fra' }); From e1a70395a799713587b8170926564089f4b7e17b Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 10:39:49 +0100 Subject: [PATCH 33/89] fix: regions --- src/lib/sdk/billing.ts | 18 +++++++++--------- src/routes/console/onboarding/+page.svelte | 2 +- .../createProjectCloud.svelte | 2 +- .../wizard/store.ts | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 32f6f0a2b..31c2a0797 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -185,15 +185,15 @@ export type AggregationList = { }; export type AllowedRegions = - | 'eu-fra' - | 'us-nyc' - | 'us-sfo' - | 'ap-in' - | 'eu-gb' - | 'eu-nl' - | 'ap-sg' - | 'ap-ca' - | 'ap-au' + | 'fra' + | 'nyc' + | 'sfo' + | 'blr' + | 'lon' + | 'ams' + | 'sgp' + | 'tor' + | 'syd' | 'default'; //TODO: remove after migration export type Region = { diff --git a/src/routes/console/onboarding/+page.svelte b/src/routes/console/onboarding/+page.svelte index c2b26314e..5cf93944c 100644 --- a/src/routes/console/onboarding/+page.svelte +++ b/src/routes/console/onboarding/+page.svelte @@ -39,7 +39,7 @@ id ?? ID.unique(), name, org.$id, - isCloud ? 'eu-fra' : 'default' + isCloud ? 'fra' : 'default' ); await invalidate(Dependencies.ACCOUNT); goto(`/console/project-${project.$id}`); diff --git a/src/routes/console/organization-[organization]/createProjectCloud.svelte b/src/routes/console/organization-[organization]/createProjectCloud.svelte index 6128fea00..7072e6b0f 100644 --- a/src/routes/console/organization-[organization]/createProjectCloud.svelte +++ b/src/routes/console/organization-[organization]/createProjectCloud.svelte @@ -52,7 +52,7 @@ $createProject = { id: null, name: null, - region: 'eu-fra' + region: 'fra' }; }); diff --git a/src/routes/console/organization-[organization]/wizard/store.ts b/src/routes/console/organization-[organization]/wizard/store.ts index 5bcbc4472..d79bd1ded 100644 --- a/src/routes/console/organization-[organization]/wizard/store.ts +++ b/src/routes/console/organization-[organization]/wizard/store.ts @@ -7,5 +7,5 @@ export const createProject = writable<{ }>({ id: null, name: null, - region: 'eu-fra' + region: 'fra' }); From 2adcafa470fe9ada07481dc8947208507402d30b Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 12:23:21 +0100 Subject: [PATCH 34/89] fix: credit under zero --- .../wizard/cloudOrganizationChangeTier/confirmDetails.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte index db1e8b24a..03e529630 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte @@ -125,7 +125,9 @@

Estimated total

${couponData?.status === 'active' - ? totalExpences - couponData.credits || 0 + ? totalExpences - couponData.credits >= 0 + ? totalExpences - couponData.credits + : 0 : totalExpences}

From 18c9275a865aea171a9f1dfec17a4df9a54c7e4d Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 12:50:49 +0100 Subject: [PATCH 35/89] refactor: add billing id to create and upgrade org --- src/lib/sdk/billing.ts | 12 ++++-- src/lib/stores/billing.ts | 1 + .../changeOrganizationTierCloud.svelte | 41 ++----------------- .../console/createOrganizationCloud.svelte | 37 +---------------- .../cloudOrganization/addressDetails.svelte | 40 ++++++++++++++---- .../console/wizard/cloudOrganization/store.ts | 11 ----- .../addressDetails.svelte | 40 ++++++++++++++---- .../cloudOrganizationChangeTier/store.ts | 11 ----- 8 files changed, 79 insertions(+), 114 deletions(-) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 31c2a0797..8773bb77b 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -276,14 +276,16 @@ export class Billing { organizationId: string, name: string, billingPlan: string, - paymentMethodId: string + paymentMethodId: string, + billingAddressId: string ): Promise { const path = `/organizations`; const params = { organizationId, name, billingPlan, - paymentMethodId + paymentMethodId, + billingAddressId }; const uri = new URL(this.client.config.endpoint + path); return await this.client.call( @@ -331,13 +333,15 @@ export class Billing { async updatePlan( organizationId: string, billingPlan: string, - paymentMethodId: string + paymentMethodId: string, + billingAddressId: string ): Promise { const path = `/organizations/${organizationId}/plan`; const params = { organizationId, billingPlan, - paymentMethodId + paymentMethodId, + billingAddressId }; const uri = new URL(this.client.config.endpoint + path); return await this.client.call( diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index d139f71c6..63d6b4dfa 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -283,6 +283,7 @@ export async function checkForFreeOrgOverflow(orgs: Models.TeamList>) { diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte index a4001b887..64afb5bc2 100644 --- a/src/routes/console/changeOrganizationTierCloud.svelte +++ b/src/routes/console/changeOrganizationTierCloud.svelte @@ -40,7 +40,8 @@ await sdk.forConsole.billing.updatePlan( $organization.$id, $changeOrganizationTier.billingPlan, - $changeOrganizationTier.paymentMethodId + $changeOrganizationTier.paymentMethodId, + $changeOrganizationTier.billingAddressId ); feedback.submitFeedback( 'downgrade', @@ -78,35 +79,10 @@ const org = await sdk.forConsole.billing.updatePlan( $organization.$id, $changeOrganizationTier.billingPlan, - $changeOrganizationTier.paymentMethodId + $changeOrganizationTier.paymentMethodId, + $changeOrganizationTier.billingAddressId ); - //Add billing address - if ($changeOrganizationTier.billingAddressId) { - await sdk.forConsole.billing.setBillingAddress( - org.$id, - $changeOrganizationTier.billingAddressId - ); - } else if ( - $changeOrganizationTier.billingAddress && - $changeOrganizationTier.billingAddress.streetAddress - ) { - const response = await sdk.forConsole.billing.createAddress( - $changeOrganizationTier.billingAddress.country, - $changeOrganizationTier.billingAddress.streetAddress, - $changeOrganizationTier.billingAddress.city, - $changeOrganizationTier.billingAddress.state, - $changeOrganizationTier.billingAddress.postalCode - ? $changeOrganizationTier.billingAddress.postalCode - : undefined, - $changeOrganizationTier.billingAddress.addressLine2 - ? $changeOrganizationTier.billingAddress.addressLine2 - : undefined - ); - - await sdk.forConsole.billing.setBillingAddress(org.$id, response.$id); - } - //Add coupon if ($changeOrganizationTier.couponCode) { await sdk.forConsole.billing.addCredit( @@ -193,15 +169,6 @@ paymentMethodId: null, collaborators: [], billingAddressId: null, - billingAddress: { - $id: null, - streetAddress: null, - addressLine2: null, - city: null, - state: null, - postalCode: null, - country: null - }, taxId: null, feedbackMessage: null }; diff --git a/src/routes/console/createOrganizationCloud.svelte b/src/routes/console/createOrganizationCloud.svelte index 9e958a28c..8c0fb58f7 100644 --- a/src/routes/console/createOrganizationCloud.svelte +++ b/src/routes/console/createOrganizationCloud.svelte @@ -32,33 +32,9 @@ $createOrganization.id ?? ID.unique(), $createOrganization.name, $createOrganization.billingPlan, - $createOrganization.paymentMethodId + $createOrganization.paymentMethodId, + $createOrganization.billingAddressId ); - //Add billing address - if ($createOrganization.billingAddressId) { - await sdk.forConsole.billing.setBillingAddress( - org.$id, - $createOrganization.billingAddressId - ); - } else if ( - $createOrganization.billingAddress && - $createOrganization.billingAddress.streetAddress - ) { - const response = await sdk.forConsole.billing.createAddress( - $createOrganization.billingAddress.country, - $createOrganization.billingAddress.streetAddress, - $createOrganization.billingAddress.city, - $createOrganization.billingAddress.state, - $createOrganization.billingAddress.postalCode - ? $createOrganization.billingAddress.postalCode - : undefined, - $createOrganization.billingAddress.addressLine2 - ? $createOrganization.billingAddress.addressLine2 - : undefined - ); - - await sdk.forConsole.billing.setBillingAddress(org.$id, response.$id); - } //Add budget if ($createOrganization?.billingBudget) { @@ -121,15 +97,6 @@ paymentMethodId: null, collaborators: [], billingAddressId: null, - billingAddress: { - $id: null, - streetAddress: null, - addressLine2: null, - city: null, - state: null, - postalCode: null, - country: null - }, taxId: null }; }); diff --git a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte index af7cbce05..608833f9c 100644 --- a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte +++ b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte @@ -14,6 +14,30 @@ } ]; let addressList: AddressesList; + let country: string; + let streetAddress: string; + let city: string; + let state: string; + let postalCode: string; + let addressLine2: string; + + async function handleAddress() { + if (!$createOrganization.billingAddressId) { + try { + const response = await sdk.forConsole.billing.createAddress( + country, + streetAddress, + city, + state, + postalCode ? postalCode : undefined, + addressLine2 ? addressLine2 : undefined + ); + $createOrganization.billingAddressId = response.$id; + } catch (error) { + throw new Error(error.message); + } + } + } onMount(async () => { addressList = await sdk.forConsole.billing.listAddresses(); @@ -21,7 +45,7 @@ const countryList = await sdk.forProject.locale.listCountries(); const locale = await sdk.forProject.locale.get(); if (locale?.countryCode) { - $createOrganization.billingAddress.country = locale.countryCode; + country = locale.countryCode; } options = countryList.countries.map((country) => { return { @@ -32,7 +56,7 @@ }); - + Billing address Add a billing address for your organization. @@ -70,25 +94,25 @@ placeholder="Enter tax ID" optionalText="(optional)" /> diff --git a/src/routes/console/wizard/cloudOrganization/store.ts b/src/routes/console/wizard/cloudOrganization/store.ts index 7c1247fe3..481924e9d 100644 --- a/src/routes/console/wizard/cloudOrganization/store.ts +++ b/src/routes/console/wizard/cloudOrganization/store.ts @@ -1,5 +1,4 @@ import type { WizardStepsType } from '$lib/layout/wizard.svelte'; -import type { Address } from '$lib/sdk/billing'; import type { Tier } from '$lib/stores/billing'; import { writable } from 'svelte/store'; @@ -12,7 +11,6 @@ export const createOrganization = writable<{ billingPlan: Tier; paymentMethodId: string; billingAddressId: string; - billingAddress?: Address; collaborators?: string[]; billingBudget?: number; taxId?: string; @@ -23,14 +21,5 @@ export const createOrganization = writable<{ paymentMethodId: null, collaborators: [], billingAddressId: null, - billingAddress: { - $id: null, - streetAddress: null, - addressLine2: null, - city: null, - state: null, - postalCode: null, - country: null - }, taxId: null }); diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte index 03861a9c0..5bd9ebaf5 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte @@ -15,6 +15,30 @@ } ]; let addressList: AddressesList; + let country: string; + let streetAddress: string; + let city: string; + let state: string; + let postalCode: string; + let addressLine2: string; + + async function handleAddress() { + if (!$changeOrganizationTier.billingAddressId) { + try { + const response = await sdk.forConsole.billing.createAddress( + country, + streetAddress, + city, + state, + postalCode ? postalCode : undefined, + addressLine2 ? addressLine2 : undefined + ); + $changeOrganizationTier.billingAddressId = response.$id; + } catch (error) { + throw new Error(error.message); + } + } + } onMount(async () => { addressList = await sdk.forConsole.billing.listAddresses(); @@ -23,7 +47,7 @@ : addressList.billingAddresses?.[0]?.$id ?? null; const locale = await sdk.forProject.locale.get(); if (locale?.countryCode && !$changeOrganizationTier.billingAddressId) { - $changeOrganizationTier.billingAddress.country = locale.countryCode; + country = locale.countryCode; } const countryList = await sdk.forProject.locale.listCountries(); options = countryList.countries.map((country) => { @@ -35,7 +59,7 @@ }); - + Billing address Add a billing address for your organization. @@ -73,25 +97,25 @@ placeholder="Enter tax ID" optionalText="(optional)" /> diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts index 25f69bf5d..0721a89c3 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts @@ -1,5 +1,4 @@ import type { WizardStepsType } from '$lib/layout/wizard.svelte'; -import type { Address } from '$lib/sdk/billing'; import type { Tier } from '$lib/stores/billing'; import { writable } from 'svelte/store'; @@ -12,7 +11,6 @@ export const changeOrganizationTier = writable<{ billingPlan: Tier; paymentMethodId: string; billingAddressId: string; - billingAddress?: Address; billingBudget?: number; collaborators?: string[]; isOverLimit?: boolean; @@ -33,14 +31,5 @@ export const changeOrganizationTier = writable<{ collaborators: [], isOverLimit: false, billingAddressId: null, - billingAddress: { - $id: null, - streetAddress: null, - addressLine2: null, - city: null, - state: null, - postalCode: null, - country: null - }, taxId: null }); From d715b80b1c611651f1a10197942e09cb91537f2e Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 13:05:15 +0100 Subject: [PATCH 36/89] fix: error check --- src/routes/console/onboarding/+page.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/src/routes/console/onboarding/+page.svelte b/src/routes/console/onboarding/+page.svelte index 5cf93944c..55ebefea7 100644 --- a/src/routes/console/onboarding/+page.svelte +++ b/src/routes/console/onboarding/+page.svelte @@ -62,6 +62,7 @@ ID.unique(), 'Personal Projects', 'tier-0', + null, null ); } else return await sdk.forConsole.teams.create(ID.unique(), 'Personal Projects'); From 0a40599b6d126a687b07946e1fe2c3617ef6db44 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 15:41:43 +0100 Subject: [PATCH 37/89] fix: github login route --- src/routes/login/+page.svelte | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index 7d4da5a0d..a46062288 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -61,10 +61,12 @@ url = `${base}/console${$page.url.search ?? ''}`; } } - sdk.forConsole.account.createOAuth2Session('github', url, window.location.origin, [ - 'read:user', - 'user:email' - ]); + sdk.forConsole.account.createOAuth2Session( + 'github', + window.location.origin + url, + window.location.origin, + ['read:user', 'user:email'] + ); } From 1ca379f01b77fb9d880b7474fca7b76b7f283c89 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 15:56:20 +0100 Subject: [PATCH 38/89] fix: org presistency when switchin org --- src/routes/console/organization-[organization]/+layout.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/routes/console/organization-[organization]/+layout.ts b/src/routes/console/organization-[organization]/+layout.ts index aea1df5dd..16c152cfe 100644 --- a/src/routes/console/organization-[organization]/+layout.ts +++ b/src/routes/console/organization-[organization]/+layout.ts @@ -9,6 +9,7 @@ import Header from './header.svelte'; import { headerAlert } from '$lib/stores/headerAlert'; import ProjectsAtRisk from '$lib/components/billing/alerts/projectsAtRisk.svelte'; import { get } from 'svelte/store'; +import { preferences } from '$lib/stores/preferences'; export const load: LayoutLoad = async ({ params, depends }) => { depends(Dependencies.ORGANIZATION); @@ -28,6 +29,10 @@ export const load: LayoutLoad = async ({ params, depends }) => { } try { + const prefs = await sdk.forConsole.account.getPrefs(); + const newPrefs = { ...prefs, organization: params.organization }; + sdk.forConsole.account.updatePrefs(newPrefs); + preferences.loadTeamPrefs(params.organization); return { header: Header, breadcrumbs: Breadcrumbs, @@ -35,6 +40,9 @@ export const load: LayoutLoad = async ({ params, depends }) => { members: await sdk.forConsole.teams.listMemberships(params.organization) }; } catch (e) { + const prefs = await sdk.forConsole.account.getPrefs(); + const newPrefs = { ...prefs, organization: '' }; + sdk.forConsole.account.updatePrefs(newPrefs); localStorage.removeItem('organization'); throw error(e.code, e.message); } From 94b14d1d83f80e2319437599156ad4448a39a873 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 16:01:58 +0100 Subject: [PATCH 39/89] fix: only throw error message --- src/lib/stores/stripe.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/stores/stripe.ts b/src/lib/stores/stripe.ts index c0ba12ef8..4f81173de 100644 --- a/src/lib/stores/stripe.ts +++ b/src/lib/stores/stripe.ts @@ -71,7 +71,7 @@ export async function submitStripeCard(name: string, urlRoute?: string) { if (error) { const e = new Error(error.message); trackError(e, Submit.PaymentMethodCreate); - throw error; + throw e; } if (setupIntent && setupIntent.status === 'succeeded') { @@ -87,11 +87,11 @@ export async function submitStripeCard(name: string, urlRoute?: string) { } else { const e = new Error('Something went wrong'); trackError(e, Submit.PaymentMethodCreate); - throw e; + throw e.message; } } catch (e) { trackError(e, Submit.PaymentMethodCreate); - throw e; + throw e.message; } } @@ -109,7 +109,7 @@ export async function confirmPayment(orgId: string, clientSecret: string, paymen } }); if (error) { - throw new Error(); + throw error.message; } } catch (e) { addNotification({ From 872ae79c9d6c2422fd2458aa73b1a8b46d60a862 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 16:12:56 +0100 Subject: [PATCH 40/89] fix: header alert too many free orgs --- .../components/billing/alerts/tooManyFreeOrgs.svelte | 11 ++++------- src/lib/stores/billing.ts | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte index f5fa340d4..5cd439e86 100644 --- a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte +++ b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte @@ -1,11 +1,8 @@ -{#if $failedInvoice} - - All but one organization will be automatically upgraded to a Pro plan on 01 Feb 2024. - You can add a payment method or transfer projects from your settings. - -{/if} + + All but one organization will be automatically upgraded to a Pro plan on 01 Feb 2024. You + can add a payment method or transfer projects from your settings. + diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 63d6b4dfa..ea24fff91 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -282,8 +282,8 @@ export async function checkForFreeOrgOverflow(orgs: Models.TeamList>) { From 206c3ee3c9f22dda3da665c616b93a46530b84c1 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 16:44:53 +0100 Subject: [PATCH 41/89] fix: show upgrade cta only to free users --- src/lib/layout/activity.svelte | 7 +++++-- src/lib/layout/logs.svelte | 16 +++++++++------- .../functions/function-[function]/+page.svelte | 9 ++++----- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/lib/layout/activity.svelte b/src/lib/layout/activity.svelte index 03d0577b2..908ab6b8a 100644 --- a/src/lib/layout/activity.svelte +++ b/src/lib/layout/activity.svelte @@ -21,6 +21,7 @@ import { tierToPlan, type PlanServices } from '$lib/stores/billing'; import { isCloud } from '$lib/system'; import { organization } from '$lib/stores/organization'; + import { Button } from '$lib/elements/forms'; export let logs: Models.LogList; export let offset = 0; @@ -50,8 +51,10 @@ Logs are retained in rolling {hoursToDays(limit)} intervals with the {tierToPlan($organization.billingPlan).name} plan. - to increase your log retention for a longer period. + {#if $organization?.billingPlan === 'tier-0'} + to increase your log + retention for a longer period. + {/if}

{#each logs.logs as log} diff --git a/src/lib/layout/logs.svelte b/src/lib/layout/logs.svelte index a7abce0c4..19be13b4c 100644 --- a/src/lib/layout/logs.svelte +++ b/src/lib/layout/logs.svelte @@ -19,6 +19,7 @@ import { getServiceLimit, tierToPlan } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; import { app } from '$lib/stores/app'; + import { Button } from '$lib/elements/forms'; let selectedRequest = 'parameters'; let selectedResponse = 'logs'; @@ -310,13 +311,14 @@ Logs are retained in rolling {hoursToDays(limit)} intervals with the {tier} plan. - to increase your log retention for - a longer period. + {#if $organization.billingPlan === 'tier-0'} + to increase your log retention + for a longer period. + {/if} {/if} diff --git a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte index da05c0b6f..5f32548a1 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte @@ -221,11 +221,10 @@ Logs are retained in rolling {hoursToDays(limit)} intervals with the {tierToPlan($organization.billingPlan).name} plan. - to increase - your log retention for a longer period. + {#if $organization.billingPlan === 'tier-0'} + to increase + your log retention for a longer period. + {/if}

{#each $deploymentList.deployments as deployment, index (deployment.$id)} From 4996b49b2fbc0bb3b4a01f8184bbee5735d78f4a Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 16:47:28 +0100 Subject: [PATCH 42/89] fix: remove warning in deployment page --- .../functions/function-[function]/+page.svelte | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte index 5f32548a1..1462e407d 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/+page.svelte @@ -40,9 +40,7 @@ import DeploymentCreatedBy from './deploymentCreatedBy.svelte'; import DeploymentDomains from './deploymentDomains.svelte'; import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system'; - import { readOnly, tierToPlan } from '$lib/stores/billing'; - import { hoursToDays } from '$lib/helpers/date'; - import { organization } from '$lib/stores/organization'; + import { readOnly } from '$lib/stores/billing'; export let data; @@ -215,18 +213,7 @@ Size - - -

- Logs are retained in rolling {hoursToDays(limit)} intervals with the - {tierToPlan($organization.billingPlan).name} - plan. - {#if $organization.billingPlan === 'tier-0'} - to increase - your log retention for a longer period. - {/if} -

-
+ {#each $deploymentList.deployments as deployment, index (deployment.$id)} {@const status = deployment.status} From 52038f1389a6f1db114dd1f3cd892307851ec946 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Dec 2023 17:30:44 +0100 Subject: [PATCH 43/89] fix: add cta to tooManyFreeOrg header alert --- src/lib/components/billing/alerts/tooManyFreeOrgs.svelte | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte index 5cd439e86..4f02244ae 100644 --- a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte +++ b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte @@ -1,8 +1,13 @@ All but one organization will be automatically upgraded to a Pro plan on 01 Feb 2024. You can add a payment method or transfer projects from your settings. + + + + From 0b3f30dedccf167ef1a6385cd232c116e699f1a8 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 10:54:00 +0100 Subject: [PATCH 44/89] fix: project usage dropdown --- src/lib/components/cardGrid.svelte | 2 +- src/lib/components/collapsibleItem.svelte | 2 +- .../usage/[[invoice]]/ProjectBreakdown.svelte | 50 +++++++++---------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/lib/components/cardGrid.svelte b/src/lib/components/cardGrid.svelte index 33dff20d1..67e0d2ad4 100644 --- a/src/lib/components/cardGrid.svelte +++ b/src/lib/components/cardGrid.svelte @@ -10,7 +10,7 @@
-
+
diff --git a/src/lib/components/collapsibleItem.svelte b/src/lib/components/collapsibleItem.svelte index cd44bc824..8397454dc 100644 --- a/src/lib/components/collapsibleItem.svelte +++ b/src/lib/components/collapsibleItem.svelte @@ -9,7 +9,7 @@
Project breakdown -
- - - Project - Usage - - - - {#each groupByProject(metric).sort((a, b) => b.usage - a.usage) as project} - - - {getProjectName(project.projectId)} - - {format(project.usage)} - - View project usage - - - {/each} - -
-
+ + + Project + Usage + + + + {#each groupByProject(metric).sort((a, b) => b.usage - a.usage) as project} + + + {getProjectName(project.projectId)} + + {format(project.usage)} + + View project usage + + + {/each} + +
From 5a7598df2aadca8c6f6b2d4148b03a885ef2e61b Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 12:11:01 +0100 Subject: [PATCH 45/89] fix: upgrade flow --- .../cloudOrganizationChangeTier/choosePlan.svelte | 4 ++-- .../cloudOrganizationChangeTier/inviteMembers.svelte | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte index e1aea276e..64d01a71c 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte @@ -64,10 +64,10 @@ $changeOrganizationTier.limitOverflow.members > 0 ) { $changeOrganizationTier.isOverLimit = true; - $changeTierSteps = updateStepStatus($changeTierSteps, 4, false); + $changeTierSteps = updateStepStatus($changeTierSteps, 5, false); } else { $changeOrganizationTier.isOverLimit = false; - $changeTierSteps = updateStepStatus($changeTierSteps, 4, true); + $changeTierSteps = updateStepStatus($changeTierSteps, 5, true); } } diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte index 61a5f1154..b1eee6a60 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte @@ -12,12 +12,24 @@ } from '$lib/elements/table'; import { WizardStep } from '$lib/layout'; import { plansInfo } from '$lib/stores/billing'; + import { onMount } from 'svelte'; import { changeOrganizationTier } from './store'; + import { sdk } from '$lib/stores/sdk'; + import { user } from '$lib/stores/user'; const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan); let email: string; + onMount(async () => { + const members = await sdk.forConsole.teams.listMemberships($changeOrganizationTier.id); + if (members.total) { + $changeOrganizationTier.collaborators = members.memberships.map((m) => { + if (m.userEmail !== $user.email) return m.userEmail; + }); + } + }); + function addCollaborator() { if (!email) return; if ($changeOrganizationTier.collaborators.includes(email)) return; From de4b86ac000c52677f7a18fd4c1b0b1bfc5f2731 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 12:35:49 +0100 Subject: [PATCH 46/89] fix: wrong parameter for end of trial --- src/lib/stores/billing.ts | 4 ++-- src/lib/stores/organization.ts | 2 +- src/routes/console/account/organizations/+page.svelte | 2 +- .../organization-[organization]/billing/planSummary.svelte | 2 +- src/routes/console/organization-[organization]/header.svelte | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index ea24fff91..b79693b10 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -158,7 +158,7 @@ export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: num export function calculateTrialDay(org: Organization) { if (org?.billingPlan === 'tier-0') return false; - const endDate = new Date(org?.billingTrialEndDate); + const endDate = new Date(org?.billingStartDate); const today = new Date(); const days = diffDays(today, endDate); daysLeftInTrial.set(days); @@ -176,7 +176,7 @@ export function checkForTrialEnding(org: Organization) { tierToPlan(org.billingPlan).name } plan. You will be billed on a recurring 30-day cycle after your trial period ends on ${toLocaleDate( - org.billingTrialEndDate + org.billingStartDate )}` }); localStorage.setItem('trialEndingNotification', 'true'); diff --git a/src/lib/stores/organization.ts b/src/lib/stores/organization.ts index f7fadb9be..38914e5b0 100644 --- a/src/lib/stores/organization.ts +++ b/src/lib/stores/organization.ts @@ -14,7 +14,7 @@ export type Organization = Models.Team> & { billingCurrentInvoiceDate: string; billingNextInvoiceDate: string; billingTrialStartDate?: string; - billingTrialEndDate?: string; + billingStartDate?: string; billingTrialDays?: number; billingAddressId?: string; amount: number; diff --git a/src/routes/console/account/organizations/+page.svelte b/src/routes/console/account/organizations/+page.svelte index 1a1cf9ac1..f7eb4272c 100644 --- a/src/routes/console/account/organizations/+page.svelte +++ b/src/routes/console/account/organizations/+page.svelte @@ -86,7 +86,7 @@ class="u-flex u-cross-center" use:tooltip={{ content: `Your trial ends on ${toLocaleDate( - organization.billingTrialEndDate + organization.billingStartDate )}. ${$daysLeftInTrial} days remaining.` }}> FREE TRIAL diff --git a/src/routes/console/organization-[organization]/billing/planSummary.svelte b/src/routes/console/organization-[organization]/billing/planSummary.svelte index a756fa509..bbd7def2a 100644 --- a/src/routes/console/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/console/organization-[organization]/billing/planSummary.svelte @@ -27,7 +27,7 @@ $: currentPlan = $plansInfo.plans.find((p) => p.$id === $organization?.billingPlan); $: extraUsage = currentInvoice?.amount - currentPlan?.price; - $: isTrial = new Date($organization?.billingTrialEndDate).getTime() - today.getTime() > 0; + $: isTrial = new Date($organization?.billingStartDate).getTime() - today.getTime() > 0; {#if $organization} diff --git a/src/routes/console/organization-[organization]/header.svelte b/src/routes/console/organization-[organization]/header.svelte index 0a8476867..fbc193c3f 100644 --- a/src/routes/console/organization-[organization]/header.svelte +++ b/src/routes/console/organization-[organization]/header.svelte @@ -97,7 +97,7 @@ class="u-flex u-cross-center" use:tooltip={{ content: `Your trial ends on ${toLocaleDate( - $organization.billingTrialEndDate + $organization.billingStartDate )}. ${$daysLeftInTrial} days remaining.` }}> FREE TRIAL From 00fcfea171597b2d1555d144878b52861f1631c0 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 13:21:28 +0100 Subject: [PATCH 47/89] fix: remove falsy values --- .../cloudOrganizationChangeTier/inviteMembers.svelte | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte index b1eee6a60..aa83d85ce 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte @@ -24,9 +24,11 @@ onMount(async () => { const members = await sdk.forConsole.teams.listMemberships($changeOrganizationTier.id); if (members.total) { - $changeOrganizationTier.collaborators = members.memberships.map((m) => { - if (m.userEmail !== $user.email) return m.userEmail; - }); + $changeOrganizationTier.collaborators = members.memberships + .map((m) => { + if (m.userEmail !== $user.email) return m.userEmail; + }) + .filter(Boolean); } }); From bf0965907c6903a3a335c6d3bc97b8119f454e35 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 15:40:54 +0100 Subject: [PATCH 48/89] fix: old region issue, wrap address in if --- .../console/organization-[organization]/+page.svelte | 10 ++++++---- .../billing/billingAddress.svelte | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/routes/console/organization-[organization]/+page.svelte b/src/routes/console/organization-[organization]/+page.svelte index 513fd7843..baf090007 100644 --- a/src/routes/console/organization-[organization]/+page.svelte +++ b/src/routes/console/organization-[organization]/+page.svelte @@ -131,6 +131,7 @@ }); function findRegion(project: Partial) { + console.log(project, regions); const region = regions.regions.find((region) => region.$id === project.region); return region; } @@ -165,6 +166,9 @@ offset={data.offset} on:click={handleCreateProject}> {#each data.projects.projects as project} + {@const platforms = filterPlatforms( + project.platforms.map((platform) => getPlatformInfo(platform.type)) + )}
  • @@ -178,9 +182,7 @@ diff --git a/src/routes/console/organization-[organization]/billing/billingAddress.svelte b/src/routes/console/organization-[organization]/billing/billingAddress.svelte index ab8c8afbc..aa432851b 100644 --- a/src/routes/console/organization-[organization]/billing/billingAddress.svelte +++ b/src/routes/console/organization-[organization]/billing/billingAddress.svelte @@ -155,8 +155,12 @@ - - +{#if showCreate} + +{/if} +{#if showEdit} + +{/if} {#if showReplace} {/if} From 94bdc167b7b75233e807f976f6c51644a39f2a9c Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 15:41:14 +0100 Subject: [PATCH 49/89] chore: remove log --- src/routes/console/organization-[organization]/+page.svelte | 1 - 1 file changed, 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/+page.svelte b/src/routes/console/organization-[organization]/+page.svelte index baf090007..9dd8d2580 100644 --- a/src/routes/console/organization-[organization]/+page.svelte +++ b/src/routes/console/organization-[organization]/+page.svelte @@ -131,7 +131,6 @@ }); function findRegion(project: Partial) { - console.log(project, regions); const region = regions.regions.find((region) => region.$id === project.region); return region; } From 707c37b32bd65f9eff130f7ae6cc6bc6d1f31b34 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 15:51:54 +0100 Subject: [PATCH 50/89] tmp fix: login logout login not loading org --- .../organization-[organization]/+page.svelte | 169 +++++++++--------- .../breadcrumbs.svelte | 4 +- .../organization-[organization]/header.svelte | 166 ++++++++--------- 3 files changed, 172 insertions(+), 167 deletions(-) diff --git a/src/routes/console/organization-[organization]/+page.svelte b/src/routes/console/organization-[organization]/+page.svelte index 9dd8d2580..337589afc 100644 --- a/src/routes/console/organization-[organization]/+page.svelte +++ b/src/routes/console/organization-[organization]/+page.svelte @@ -31,6 +31,7 @@ import type { RegionList } from '$lib/sdk/billing'; import { onMount } from 'svelte'; import CreateOrganizationCloud from '../createOrganizationCloud.svelte'; + import { organization } from '$lib/stores/organization'; export let data; @@ -136,94 +137,96 @@ } - -
    - Projects +{#if $organization?.$id} + +
    + Projects - - - - (showCreate = true)}>Empty project - -
    - Import project Experimental -
    -
    -
    -
    -
    + + + + (showCreate = true)}>Empty project + +
    + Import project Experimental +
    +
    +
    +
    +
    - {#if data.projects.total} - - {#each data.projects.projects as project} - {@const platforms = filterPlatforms( - project.platforms.map((platform) => getPlatformInfo(platform.type)) - )} -
  • - - - {project?.platforms?.length ? project?.platforms?.length : 'No'} apps - - - {project.name} - - {#if allServiceDisabled(project)} -

    -

    - {/if} + {#if data.projects.total} + + {#each data.projects.projects as project} + {@const platforms = filterPlatforms( + project.platforms.map((platform) => getPlatformInfo(platform.type)) + )} +
  • + + + {project?.platforms?.length ? project?.platforms?.length : 'No'} apps + + + {project.name} + + {#if allServiceDisabled(project)} +

    +

    + {/if} - {#each platforms as platform, i} - {#if i < 3} + {#each platforms as platform, i} + {#if i < 3} + + + {/if} + {/each} + {#if platforms?.length > 3} - {/if} - {/each} - {#if platforms?.length > 3} - - +{project.platforms.length - 3} - - {/if} - - {#if isCloud && regions} - {@const region = findRegion(project)} - - {region?.name} - - {/if} - -
    -
  • - {/each} - -

    Create a new project

    -
    - - {:else} - - {/if} + + {#if isCloud && regions} + {@const region = findRegion(project)} + + {region?.name} + + {/if} + + + + {/each} + +

    Create a new project

    +
    + + {:else} + + {/if} - - + + - - + + +{/if} diff --git a/src/routes/console/organization-[organization]/breadcrumbs.svelte b/src/routes/console/organization-[organization]/breadcrumbs.svelte index 62b3a6f20..e2a847beb 100644 --- a/src/routes/console/organization-[organization]/breadcrumbs.svelte +++ b/src/routes/console/organization-[organization]/breadcrumbs.svelte @@ -4,8 +4,8 @@ $: breadcrumbs = [ { - href: `/console/organization-${$organization.$id}`, - title: $organization.name + href: `/console/organization-${$organization?.$id}`, + title: $organization?.name } ]; diff --git a/src/routes/console/organization-[organization]/header.svelte b/src/routes/console/organization-[organization]/header.svelte index fbc193c3f..df325e0c7 100644 --- a/src/routes/console/organization-[organization]/header.svelte +++ b/src/routes/console/organization-[organization]/header.svelte @@ -80,86 +80,88 @@ : permanentTabs; - - - - - - {#each $organizationList.teams as org} - (showDropdown = false)}> - {org.name} - - {/each} - - -
    -
      - - New Organization - -
    -
    -
    -
    -
    - - - -
    - +{#if $organization.$id} + + + + + + {#each $organizationList.teams as org} + (showDropdown = false)}> + {org.name} + + {/each} + + +
    +
      + + New Organization + +
    +
    +
    +
    +
    + + + +
    + +
    -
    -
    - - {#each tabs as tab} - - {tab.title} - - {/each} - - +
    + + {#each tabs as tab} + + {tab.title} + + {/each} + + +{/if} From abf53641624ca8537011f8bf374f7c085dd0174b Mon Sep 17 00:00:00 2001 From: tglide <26071571+TGlide@users.noreply.github.com> Date: Thu, 21 Dec 2023 15:51:03 +0000 Subject: [PATCH 51/89] fix conditional chaining --- src/routes/console/organization-[organization]/header.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/header.svelte b/src/routes/console/organization-[organization]/header.svelte index df325e0c7..65bf1e582 100644 --- a/src/routes/console/organization-[organization]/header.svelte +++ b/src/routes/console/organization-[organization]/header.svelte @@ -80,7 +80,7 @@ : permanentTabs; -{#if $organization.$id} +{#if $organization?.$id} From 4fa8a30a7b36d719098a77b7e19dcb7d1195147e Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 17:53:52 +0100 Subject: [PATCH 52/89] fix: free date extension --- .../console/organization-[organization]/excesLimitModal.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/excesLimitModal.svelte b/src/routes/console/organization-[organization]/excesLimitModal.svelte index 1e58d381f..2a04c277d 100644 --- a/src/routes/console/organization-[organization]/excesLimitModal.svelte +++ b/src/routes/console/organization-[organization]/excesLimitModal.svelte @@ -62,7 +62,7 @@ Appwrite Pro is now available. To facilitate a smooth transition for your projects, Starter plan will maintain its current state of unlimited resource usage. This extension will be in effect - until January 15th, 2024. + until February 1st, 2024. {#if $organization.billingPlan === 'tier-0'}

    From 17c0d4b500ec7169835b7bda1460aefe3689f06f Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 17:59:33 +0100 Subject: [PATCH 53/89] fix: date --- .../console/organization-[organization]/excesLimitModal.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/organization-[organization]/excesLimitModal.svelte b/src/routes/console/organization-[organization]/excesLimitModal.svelte index 2a04c277d..1b4053f43 100644 --- a/src/routes/console/organization-[organization]/excesLimitModal.svelte +++ b/src/routes/console/organization-[organization]/excesLimitModal.svelte @@ -62,7 +62,7 @@ Appwrite Pro is now available. To facilitate a smooth transition for your projects, Starter plan will maintain its current state of unlimited resource usage. This extension will be in effect - until February 1st, 2024. + until January 31st, 2024. {#if $organization.billingPlan === 'tier-0'}

    From 969743ddbe67423a09ec8c44e36e5e695e8116af Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 17:59:59 +0100 Subject: [PATCH 54/89] fix: another date --- src/lib/components/billing/alerts/tooManyFreeOrgs.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte index 4f02244ae..cf37e4d45 100644 --- a/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte +++ b/src/lib/components/billing/alerts/tooManyFreeOrgs.svelte @@ -4,8 +4,8 @@ - All but one organization will be automatically upgraded to a Pro plan on 01 Feb 2024. You - can add a payment method or transfer projects from your settings. + All but one organization will be automatically upgraded to a Pro plan on 31 January 2024. + You can add a payment method or transfer projects from your settings. From 5d2cf0241a05f83c540da0e1ff3cf516ccf6d8de Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 21 Dec 2023 19:04:24 +0100 Subject: [PATCH 55/89] fix: plan limit tag shown for users, upgrade flow wrong step, upgrade flow invited member --- src/lib/stores/billing.ts | 9 +++++++-- src/routes/console/+layout.svelte | 2 +- src/routes/console/changeOrganizationTierCloud.svelte | 3 --- .../cloudOrganizationChangeTier/choosePlan.svelte | 11 ++++++----- .../cloudOrganizationChangeTier/confirmDetails.svelte | 4 ---- .../cloudOrganizationChangeTier/inviteMembers.svelte | 3 ++- .../cloudOrganizationChangeTier/planExcess.svelte | 2 ++ .../wizard/cloudOrganizationChangeTier/store.ts | 2 -- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index b79693b10..7b7174e0f 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -183,18 +183,23 @@ export function checkForTrialEnding(org: Organization) { } } -export function checkForUsageLimit(org: Organization) { +export async function checkForUsageLimit(org: Organization) { if (!org?.billingLimits) { readOnly.set(false); return; } const { bandwidth, documents, executions, storage, users } = org.billingLimits; + const members = await sdk.forConsole.teams.listMemberships(org.$id); + const plan = get(plansInfo).plans.find((plan) => plan.$id === org.billingPlan); + const membersOverflow = + members?.total > plan.members ? members.total - (plan.members || Infinity) : 0; if ( bandwidth >= 100 || documents >= 100 || executions >= 100 || storage >= 100 || - users >= 100 + users >= 100 || + membersOverflow > 0 ) { readOnly.set(true); } else readOnly.set(false); diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index 479647d18..4035a9a31 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -284,7 +284,7 @@ calculateTrialDay(org); checkForTrialEnding(org); await paymentExpired(org); - checkForUsageLimit(org); + await checkForUsageLimit(org); checkForMarkedForDeletion(org); await checkPaymentAuthorizationRequired(org); } diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte index 64afb5bc2..56374d08d 100644 --- a/src/routes/console/changeOrganizationTierCloud.svelte +++ b/src/routes/console/changeOrganizationTierCloud.svelte @@ -61,7 +61,6 @@ wizard.hide(); trackEvent(Submit.OrganizationDowngrade, { - customId: !!$changeOrganizationTier.id, plan: tierToPlan($changeOrganizationTier.billingPlan)?.name }); } catch (e) { @@ -144,7 +143,6 @@ }); } trackEvent($isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade, { - customId: !!$changeOrganizationTier.id, plan: tierToPlan($changeOrganizationTier.billingPlan)?.name }); wizard.hide(); @@ -164,7 +162,6 @@ onDestroy(() => { $changeOrganizationTier = { - id: null, billingPlan: 'tier-1', paymentMethodId: null, collaborators: [], diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte index 64d01a71c..058651b90 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte @@ -57,11 +57,12 @@ members: members.total > plan.members ? members.total - (plan.members || Infinity) : 0 }; if ( - $changeOrganizationTier.limitOverflow.bandwidth > 0 || - $changeOrganizationTier.limitOverflow.storage > 0 || - $changeOrganizationTier.limitOverflow.users > 0 || - $changeOrganizationTier.limitOverflow.executions > 0 || - $changeOrganizationTier.limitOverflow.members > 0 + ($changeOrganizationTier.limitOverflow.bandwidth > 0 || + $changeOrganizationTier.limitOverflow.storage > 0 || + $changeOrganizationTier.limitOverflow.users > 0 || + $changeOrganizationTier.limitOverflow.executions > 0 || + $changeOrganizationTier.limitOverflow.members > 0) && + $changeOrganizationTier.billingPlan === 'tier-0' ) { $changeOrganizationTier.isOverLimit = true; $changeTierSteps = updateStepStatus($changeTierSteps, 5, false); diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte index 03e529630..f6095b62f 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte @@ -1,7 +1,6 @@ diff --git a/src/routes/console/organization-[organization]/createMember.svelte b/src/routes/console/organization-[organization]/createMember.svelte index a1cf2b682..57500de0d 100644 --- a/src/routes/console/organization-[organization]/createMember.svelte +++ b/src/routes/console/organization-[organization]/createMember.svelte @@ -17,7 +17,7 @@ const dispatch = createEventDispatcher(); const url = `${$page.url.origin}/invite`; - $: plan = $plansInfo?.plans?.find((p) => p.$id === $organization?.billingPlan); + $: plan = $plansInfo?.get($organization?.billingPlan); let email: string, name: string, error: string; diff --git a/src/routes/console/organization-[organization]/excesLimitModal.svelte b/src/routes/console/organization-[organization]/excesLimitModal.svelte index 1b4053f43..62d853221 100644 --- a/src/routes/console/organization-[organization]/excesLimitModal.svelte +++ b/src/routes/console/organization-[organization]/excesLimitModal.svelte @@ -15,7 +15,7 @@ import { last } from '$lib/helpers/array'; export let show = false; - const plan = $plansInfo.plans.find((plan) => plan.$id === $organization.billingPlan); + const plan = $plansInfo?.get($organization.billingPlan); let usage: OrganizationUsage = null; let members: Models.MembershipList = null; let excess: Record = null; diff --git a/src/routes/console/wizard/cloudOrganization/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganization/confirmDetails.svelte index 114403c34..dddf24fa2 100644 --- a/src/routes/console/wizard/cloudOrganization/confirmDetails.svelte +++ b/src/routes/console/wizard/cloudOrganization/confirmDetails.svelte @@ -7,7 +7,7 @@ import { sdk } from '$lib/stores/sdk'; import { createOrganization, createOrganizationFinalAction } from './store'; - const plan = $plansInfo.plans.find((p) => p.$id === $createOrganization.billingPlan); + const plan = $plansInfo?.get($createOrganization.billingPlan); const collaboratorPrice = plan?.addons.member?.price ?? 0; const collaboratorsNumber = $createOrganization?.collaborators?.length ?? 0; const totalExpences = plan.price + collaboratorPrice * collaboratorsNumber; diff --git a/src/routes/console/wizard/cloudOrganization/inviteMembers.svelte b/src/routes/console/wizard/cloudOrganization/inviteMembers.svelte index 4c3dda396..c0f88e257 100644 --- a/src/routes/console/wizard/cloudOrganization/inviteMembers.svelte +++ b/src/routes/console/wizard/cloudOrganization/inviteMembers.svelte @@ -30,7 +30,7 @@ ); } - const plan = $plansInfo.plans.find((p) => p.$id === $createOrganization.billingPlan); + const plan = $plansInfo?.get($createOrganization.billingPlan); diff --git a/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte b/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte index 8cedbdafe..552e71372 100644 --- a/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte +++ b/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte @@ -29,9 +29,9 @@ $createOrgSteps = updateStepStatus($createOrgSteps, 4, false); } - $: freePlan = $plansInfo.plans.find((p) => p.$id === 'tier-0'); - $: proPlan = $plansInfo.plans.find((p) => p.$id === 'tier-1'); - $: scalePlan = $plansInfo.plans.find((p) => p.$id === 'tier-2'); + $: freePlan = $plansInfo.get('tier-0'); + $: proPlan = $plansInfo.get('tier-1'); + $: scalePlan = $plansInfo.get('tier-2'); diff --git a/src/routes/console/wizard/cloudOrganization/usageRates.svelte b/src/routes/console/wizard/cloudOrganization/usageRates.svelte index 55d94d6a3..489915463 100644 --- a/src/routes/console/wizard/cloudOrganization/usageRates.svelte +++ b/src/routes/console/wizard/cloudOrganization/usageRates.svelte @@ -12,13 +12,13 @@ import { toLocaleDate } from '$lib/helpers/date'; import { organization } from '$lib/stores/organization'; import { createOrganization } from './store'; - import { plansInfo } from '$lib/stores/billing'; + import { plansInfo, type Tier } from '$lib/stores/billing'; import { abbreviateNumber } from '$lib/helpers/numbers'; export let show = false; - export let tier: string; + export let tier: Tier; - $: plan = $plansInfo.plans.find((p) => p.$id === tier); + $: plan = $plansInfo?.get(tier); $: nextDate = $createOrganization?.name ? new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1).toString() diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte index 058651b90..5b177bc61 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte @@ -37,9 +37,7 @@ function checkOverUsage() { if (!usage) return; - const plan = $plansInfo.plans.find( - (plan) => plan.$id === $changeOrganizationTier.billingPlan - ); + const plan = $plansInfo?.get($changeOrganizationTier.billingPlan); const totBandwidth = usage?.bandwidth?.length > 0 ? usage.bandwidth[0].value : 0; const totUsers = usage?.users?.length > 0 ? usage.users[0].value : 0; @@ -97,9 +95,9 @@ } } - $: freePlan = $plansInfo.plans.find((p) => p.$id === 'tier-0'); - $: proPlan = $plansInfo.plans.find((p) => p.$id === 'tier-1'); - $: scalePlan = $plansInfo.plans.find((p) => p.$id === 'tier-2'); + $: freePlan = $plansInfo?.get('tier-0'); + $: proPlan = $plansInfo?.get('tier-1'); + $: scalePlan = $plansInfo?.get('tier-2'); diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte index f6095b62f..9236781df 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte @@ -10,7 +10,7 @@ import { sdk } from '$lib/stores/sdk'; import { changeOrganizationFinalAction, changeOrganizationTier, isUpgrade } from './store'; - const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan); + const plan = $plansInfo.get($changeOrganizationTier.billingPlan); const collaboratorPrice = plan?.addons.member?.price ?? 0; const collaboratorsNumber = $changeOrganizationTier?.collaborators?.length ?? 0; const totalExpences = plan.price + collaboratorPrice * collaboratorsNumber; diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte index 173ce045f..5fb8b167a 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/inviteMembers.svelte @@ -18,7 +18,7 @@ import { user } from '$lib/stores/user'; import { organization } from '$lib/stores/organization'; - const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan); + const plan = $plansInfo.get($changeOrganizationTier.billingPlan); let email: string; diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte index 21e69ed67..ed545fd89 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/planExcess.svelte @@ -26,7 +26,7 @@ } = null; export let currentTier: Tier; - const plan = $plansInfo.plans.find((p) => p.$id === currentTier); + const plan = $plansInfo?.get(currentTier); const collaboratorPrice = plan?.addons.member?.price ?? 0; From f851e61124d323b8a856500c68da58398b613128 Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 22 Dec 2023 17:47:49 +0100 Subject: [PATCH 66/89] refactor: tiers into enum --- src/lib/components/support.svelte | 7 +++- src/lib/constants.ts | 6 +++ src/lib/layout/activity.svelte | 3 +- src/lib/layout/containerButton.svelte | 3 +- src/lib/layout/containerHeader.svelte | 9 +++-- src/lib/layout/header.svelte | 3 +- src/lib/layout/logs.svelte | 3 +- src/lib/layout/navigation.svelte | 3 +- src/lib/stores/billing.ts | 13 ++++--- src/routes/console/+layout.svelte | 4 +- .../account/organizations/+page.svelte | 3 +- .../changeOrganizationTierCloud.svelte | 6 +-- .../console/createOrganizationCloud.svelte | 6 +-- src/routes/console/onboarding/+page.svelte | 4 +- .../billing/+page.svelte | 3 +- .../billing/budgetCap.svelte | 4 +- .../billing/planSummary.svelte | 7 ++-- .../createMember.svelte | 6 +-- .../excesLimitModal.svelte | 3 +- .../organization-[organization]/header.svelte | 5 ++- .../usage/[[invoice]]/+page.svelte | 9 +++-- .../auth/templates/+page.svelte | 3 +- .../executions/+page.svelte | 4 +- .../settings/smtp/+page.svelte | 7 ++-- .../settings/usage/[[invoice]]/+page.svelte | 9 +++-- .../bucket-[bucket]/create-file/step1.svelte | 5 ++- .../settings/updateMaxFileSize.svelte | 5 ++- .../cloudOrganization/confirmDetails.svelte | 11 +++--- .../cloudOrganization/inviteMembers.svelte | 9 +++-- .../organizationDetails.svelte | 15 ++++---- .../console/wizard/cloudOrganization/store.ts | 3 +- .../cloudOrganization/usageRates.svelte | 7 ++-- .../choosePlan.svelte | 37 ++++++++++--------- .../confirmDetails.svelte | 7 ++-- .../inviteMembers.svelte | 9 +++-- .../planExcess.svelte | 11 +++--- .../cloudOrganizationChangeTier/store.ts | 3 +- 37 files changed, 146 insertions(+), 109 deletions(-) diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte index 06bf93f2a..c63200f73 100644 --- a/src/lib/components/support.svelte +++ b/src/lib/components/support.svelte @@ -10,10 +10,13 @@ import { isSupportOnline, showSupportModal } from '../../routes/console/wizard/support/store'; import { isCloud } from '$lib/system'; import { organization } from '$lib/stores/organization'; + import { BillingPlan } from '$lib/constants'; export let show = false; - $: isPaid = $organization?.billingPlan === 'tier-1' || $organization?.billingPlan === 'tier-2'; + $: isPaid = + $organization?.billingPlan === BillingPlan.PRO || + $organization?.billingPlan === BillingPlan.SCALE; {#if isCloud} @@ -39,7 +42,7 @@

    {/if}
    - {#if $organization?.billingPlan === 'tier-0'} + {#if $organization?.billingPlan === BillingPlan.STARTER} diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 52d2b999b..4b9dedb14 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -616,3 +616,9 @@ export const limitRates = { } ] }; + +export enum BillingPlan { + STARTER = 'tier-0', + PRO = 'tier-1', + SCALE = 'tier-2' +} diff --git a/src/lib/layout/activity.svelte b/src/lib/layout/activity.svelte index 908ab6b8a..e888b3b2e 100644 --- a/src/lib/layout/activity.svelte +++ b/src/lib/layout/activity.svelte @@ -22,6 +22,7 @@ import { isCloud } from '$lib/system'; import { organization } from '$lib/stores/organization'; import { Button } from '$lib/elements/forms'; + import { BillingPlan } from '$lib/constants'; export let logs: Models.LogList; export let offset = 0; @@ -51,7 +52,7 @@ Logs are retained in rolling {hoursToDays(limit)} intervals with the {tierToPlan($organization.billingPlan).name} plan. - {#if $organization?.billingPlan === 'tier-0'} + {#if $organization?.billingPlan === BillingPlan.STARTER} to increase your log retention for a longer period. {/if} diff --git a/src/lib/layout/containerButton.svelte b/src/lib/layout/containerButton.svelte index 48459fb81..6c39746ad 100644 --- a/src/lib/layout/containerButton.svelte +++ b/src/lib/layout/containerButton.svelte @@ -1,12 +1,13 @@ @@ -53,7 +54,7 @@ {/if}
    - {#if $createOrganization.billingPlan !== 'tier-0'} + {#if $createOrganization.billingPlan !== BillingPlan.STARTER}

    Additional members

    {collaboratorsNumber} members

    @@ -75,7 +76,7 @@
    {/if} - {#if $createOrganization.billingPlan !== 'tier-0'} + {#if $createOrganization.billingPlan !== BillingPlan.STARTER}

    {plan.name} plan

    ${plan.price}

    @@ -91,7 +92,7 @@

    ${totalExpences}

    - {#if $createOrganization.billingPlan !== 'tier-0'} + {#if $createOrganization.billingPlan !== BillingPlan.STARTER}

    This amount, and any additional usage fees, will be charged on a recurring 30-day billing cycle after your trial period ends on import { Alert } from '$lib/components'; + import { BillingPlan } from '$lib/constants'; import { Button, Form, FormList, InputEmail } from '$lib/elements/forms'; import { Table, @@ -41,10 +42,10 @@ - {#if $createOrganization.billingPlan === 'tier-2'} + {#if $createOrganization.billingPlan === BillingPlan.SCALE} You can add unlimited organization members on the {plan.name} plan at no cost. Each member added will receive an email invite to your organization on completion. - {:else if $createOrganization.billingPlan === 'tier-1'} + {:else if $createOrganization.billingPlan === BillingPlan.PRO} You can add unlimited organization members on the {plan.name} plan for ${plan.addons.member.price} each per month. Each member added will receive an email invite to your organization on completion. @@ -70,7 +71,7 @@ Collaborator - {#if $createOrganization.billingPlan === 'tier-1'} + {#if $createOrganization.billingPlan === BillingPlan.PRO} Cost {/if} @@ -79,7 +80,7 @@ {#each $createOrganization.collaborators as collaborator} {collaborator} - {#if $createOrganization.billingPlan === 'tier-1'} + {#if $createOrganization.billingPlan === BillingPlan.PRO} 15$ {/if} diff --git a/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte b/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte index 8cedbdafe..785b74862 100644 --- a/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte +++ b/src/routes/console/wizard/cloudOrganization/organizationDetails.svelte @@ -1,5 +1,6 @@ diff --git a/src/routes/console/wizard/cloudOrganization/store.ts b/src/routes/console/wizard/cloudOrganization/store.ts index 481924e9d..0c2e71e7a 100644 --- a/src/routes/console/wizard/cloudOrganization/store.ts +++ b/src/routes/console/wizard/cloudOrganization/store.ts @@ -1,3 +1,4 @@ +import { BillingPlan } from '$lib/constants'; import type { WizardStepsType } from '$lib/layout/wizard.svelte'; import type { Tier } from '$lib/stores/billing'; import { writable } from 'svelte/store'; @@ -17,7 +18,7 @@ export const createOrganization = writable<{ }>({ id: null, name: null, - billingPlan: 'tier-1', + billingPlan: BillingPlan.PRO, paymentMethodId: null, collaborators: [], billingAddressId: null, diff --git a/src/routes/console/wizard/cloudOrganization/usageRates.svelte b/src/routes/console/wizard/cloudOrganization/usageRates.svelte index 55d94d6a3..7810b8e3e 100644 --- a/src/routes/console/wizard/cloudOrganization/usageRates.svelte +++ b/src/routes/console/wizard/cloudOrganization/usageRates.svelte @@ -14,6 +14,7 @@ import { createOrganization } from './store'; import { plansInfo } from '$lib/stores/billing'; import { abbreviateNumber } from '$lib/helpers/numbers'; + import { BillingPlan } from '$lib/constants'; export let show = false; export let tier: string; @@ -49,7 +50,7 @@ } ]; - $: isFree = tier === 'tier-0'; + $: isFree = tier === BillingPlan.STARTER; @@ -57,12 +58,12 @@ Usage on the Starter plan is limited for the following resources. Next billing period: {toLocaleDate( nextDate )}. - {:else if tier === 'tier-1'} + {:else if tier === BillingPlan.PRO}

    Usage on the Pro plan will be charged at the end of each billing period at the following rates. Next billing period: {toLocaleDate(nextDate)}.

    - {:else if tier === 'tier-2'} + {:else if tier === BillingPlan.SCALE}

    Usage on the Scale plan will be charged at the end of each billing period at the following rates. Next billing period: {toLocaleDate(nextDate)}. diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte index 058651b90..7c3095ddd 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte @@ -11,19 +11,20 @@ import type { Models } from '@appwrite.io/console'; import { sizeToBytes } from '$lib/helpers/sizeConvertion'; import { Pill } from '$lib/elements'; + import { BillingPlan } from '$lib/constants'; let usage: OrganizationUsage = null; let members: Models.MembershipList = null; - $: if ($changeOrganizationTier.billingPlan === 'tier-0' && $changeTierSteps) { + $: if ($changeOrganizationTier.billingPlan === BillingPlan.STARTER && $changeTierSteps) { $changeTierSteps = updateStepStatus($changeTierSteps, 2, true); $changeTierSteps = updateStepStatus($changeTierSteps, 3, true); $changeTierSteps = updateStepStatus($changeTierSteps, 4, true); } $: if ( - $changeOrganizationTier.billingPlan === 'tier-2' || - $changeOrganizationTier.billingPlan === 'tier-1' + $changeOrganizationTier.billingPlan === BillingPlan.SCALE || + $changeOrganizationTier.billingPlan === BillingPlan.PRO ) { $changeTierSteps = updateStepStatus($changeTierSteps, 2, false); $changeTierSteps = updateStepStatus($changeTierSteps, 3, false); @@ -62,7 +63,7 @@ $changeOrganizationTier.limitOverflow.users > 0 || $changeOrganizationTier.limitOverflow.executions > 0 || $changeOrganizationTier.limitOverflow.members > 0) && - $changeOrganizationTier.billingPlan === 'tier-0' + $changeOrganizationTier.billingPlan === BillingPlan.STARTER ) { $changeOrganizationTier.isOverLimit = true; $changeTierSteps = updateStepStatus($changeTierSteps, 5, false); @@ -77,14 +78,14 @@ members = await sdk.forConsole.teams.listMemberships($organization.$id); //Select closest tier from starting one - // if ($organization.billingPlan === 'tier-2') { - // $changeOrganizationTier.billingPlan = 'tier-1'; + // if ($organization.billingPlan === BillingPlan.SCALE) { + // $changeOrganizationTier.billingPlan = BillingPlan.PRO; // } // else - if ($organization.billingPlan === 'tier-1') { - $changeOrganizationTier.billingPlan = 'tier-0'; - } else if ($organization.billingPlan === 'tier-0') { - $changeOrganizationTier.billingPlan = 'tier-1'; + if ($organization.billingPlan === BillingPlan.PRO) { + $changeOrganizationTier.billingPlan = BillingPlan.STARTER; + } else if ($organization.billingPlan === BillingPlan.STARTER) { + $changeOrganizationTier.billingPlan = BillingPlan.PRO; } }); @@ -92,14 +93,14 @@ if (!$changeOrganizationTier.billingPlan) { throw new Error('Please select a plan.'); } - if ($changeOrganizationTier.billingPlan === 'tier-0') { + if ($changeOrganizationTier.billingPlan === BillingPlan.STARTER) { $changeOrganizationTier.collaborators = []; } } - $: freePlan = $plansInfo.plans.find((p) => p.$id === 'tier-0'); - $: proPlan = $plansInfo.plans.find((p) => p.$id === 'tier-1'); - $: scalePlan = $plansInfo.plans.find((p) => p.$id === 'tier-2'); + $: freePlan = $plansInfo.plans.find((p) => p.$id === BillingPlan.STARTER); + $: proPlan = $plansInfo.plans.find((p) => p.$id === BillingPlan.PRO); + $: scalePlan = $plansInfo.plans.find((p) => p.$id === BillingPlan.SCALE); @@ -122,7 +123,7 @@ name="plan" bind:group={$changeOrganizationTier.billingPlan} value="tier-0" - disabled={$organization.billingPlan === 'tier-0'}> + disabled={$organization.billingPlan === BillingPlan.STARTER}>

    {tierFree.description}

    - {#if $organization.billingPlan === 'tier-0'} + {#if $organization.billingPlan === BillingPlan.STARTER} CURRENT PLAN {/if}
    @@ -145,7 +146,7 @@ name="plan" bind:group={$changeOrganizationTier.billingPlan} value="tier-1" - disabled={$organization.billingPlan === 'tier-1'}> + disabled={$organization.billingPlan === BillingPlan.PRO}>
    - {#if $organization.billingPlan === 'tier-1'} + {#if $organization.billingPlan === BillingPlan.PRO} CURRENT PLAN {:else} 14 DAY FREE TRIAL diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte index f6095b62f..0b8f05344 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte @@ -1,6 +1,7 @@ -
    - + Create a new organization + + {#if !showCustomId}
    (showCustomId = !showCustomId)}>
    {:else} - + {/if} - . +

    + + + +
    + {/if} + diff --git a/src/routes/console/onboarding/header.svelte b/src/routes/console/onboarding/header.svelte index 51f7314c6..4bf595ce1 100644 --- a/src/routes/console/onboarding/header.svelte +++ b/src/routes/console/onboarding/header.svelte @@ -1,7 +1,10 @@ - Let's create your first project +
    + Welcome to Appwrite +
    From 6b305329002726a2e6a65623cde11550601dfe0f Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 28 Dec 2023 17:37:46 +0100 Subject: [PATCH 75/89] fix: org name --- src/routes/console/onboarding/+page.svelte | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/routes/console/onboarding/+page.svelte b/src/routes/console/onboarding/+page.svelte index 647399936..fa7263dd4 100644 --- a/src/routes/console/onboarding/+page.svelte +++ b/src/routes/console/onboarding/+page.svelte @@ -41,12 +41,13 @@ }); async function handleSubmit() { + const orgName = name?.length ? name : 'Personal Projects'; if (isCloud) { if (plan === BillingPlan.STARTER) { try { const org = await sdk.forConsole.billing.createOrganization( id ?? ID.unique(), - name ?? 'Personal Projects', + orgName, plan, null, null @@ -64,9 +65,7 @@ await invalidate(Dependencies.ACCOUNT); await goto(`/console/organization-${org.$id}`); addNotification({ - message: `${ - name?.length ? name : 'Personal Projects' - } organization successfully created`, + message: `${orgName} organization successfully created`, type: 'success' }); } catch (error) { @@ -78,16 +77,13 @@ } } else { wizard.start(CreateOrganizationCloud, null, 2); - $createOrganization.name = name?.length ? name : 'Personal Projects'; + $createOrganization.name = orgName; $createOrganization.billingPlan = plan; $createOrganization.id = id; } } else { try { - const org = await sdk.forConsole.teams.create( - id ?? ID.unique(), - name?.length ? name : 'Personal Projects' - ); + const org = await sdk.forConsole.teams.create(id ?? ID.unique(), orgName); const project = await sdk.forConsole.projects.create( ID.unique(), 'My first project', @@ -97,7 +93,7 @@ await invalidate(Dependencies.ACCOUNT); await goto(`/console/project-${project.$id}`); addNotification({ - message: `${name ?? 'Personal Projects'} organization successfully created`, + message: `${orgName} organization successfully created`, type: 'success' }); } catch (error) { From 99416057e3477f9e5fb3a8d4b55cd4188f36cee4 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 28 Dec 2023 18:04:36 +0100 Subject: [PATCH 76/89] feat: add loading state to buttons while submitting --- src/lib/elements/forms/button.svelte | 9 ++++++++- src/routes/console/onboarding/+page.svelte | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/lib/elements/forms/button.svelte b/src/lib/elements/forms/button.svelte index 3b8647c21..30bcfb871 100644 --- a/src/lib/elements/forms/button.svelte +++ b/src/lib/elements/forms/button.svelte @@ -23,6 +23,7 @@ let classes: string = undefined; export { classes as class }; export let actions: MultiActionArray = []; + export let submissionLoader = false; const isSubmitting = hasContext('form') ? getContext('form').isSubmitting @@ -77,6 +78,12 @@ aria-label={ariaLabel} type={submit ? 'submit' : 'button'} use:multiAction={actions}> - + {#if $isSubmitting && submissionLoader} +