diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte index 1b78d8821..588d07ad6 100644 --- a/src/routes/console/changeOrganizationTierCloud.svelte +++ b/src/routes/console/changeOrganizationTierCloud.svelte @@ -14,7 +14,6 @@ changeOrganizationFinalAction, changeOrganizationTier, changeTierSteps, - currentBillingAddress, isUpgrade } from './wizard/cloudOrganizationChangeTier/store'; import { goto, invalidate } from '$app/navigation'; @@ -24,7 +23,6 @@ import { organization } from '$lib/stores/organization'; import { wizard } from '$lib/stores/wizard'; import { tierToPlan } from '$lib/stores/billing'; - import deepEqual from 'deep-equal'; import { user } from '$lib/stores/user'; import { feedback } from '$lib/stores/feedback'; @@ -82,10 +80,14 @@ ); //Add billing address - if ( + if ($changeOrganizationTier.billingAddressId) { + await sdk.forConsole.billing.setBillingAddress( + org.$id, + $changeOrganizationTier.billingAddressId + ); + } else if ( $changeOrganizationTier.billingAddress && - $changeOrganizationTier.billingAddress.streetAddress && - !deepEqual($changeOrganizationTier.billingAddress, $currentBillingAddress) + $changeOrganizationTier.billingAddress.streetAddress ) { const response = await sdk.forConsole.billing.createAddress( $changeOrganizationTier.billingAddress.country, @@ -180,6 +182,7 @@ billingPlan: 'tier-1', paymentMethodId: null, collaborators: [], + billingAddressId: null, billingAddress: { $id: null, streetAddress: null, diff --git a/src/routes/console/createOrganizationCloud.svelte b/src/routes/console/createOrganizationCloud.svelte index 6f1c7506f..00865408d 100644 --- a/src/routes/console/createOrganizationCloud.svelte +++ b/src/routes/console/createOrganizationCloud.svelte @@ -33,7 +33,12 @@ $createOrganization.paymentMethodId ); //Add billing address - if ( + if ($createOrganization.billingAddressId) { + await sdk.forConsole.billing.setBillingAddress( + org.$id, + $createOrganization.billingAddressId + ); + } else if ( $createOrganization.billingAddress && $createOrganization.billingAddress.streetAddress ) { @@ -106,6 +111,7 @@ billingPlan: 'tier-1', paymentMethodId: null, collaborators: [], + billingAddressId: null, billingAddress: { $id: null, streetAddress: null, diff --git a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte index 478de06d6..cd22c6f43 100644 --- a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte +++ b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte @@ -1,10 +1,11 @@ @@ -41,54 +39,98 @@ Depending on your location, your billing address might need to be in the same country associated with the payment method for your organization. - - - - - - - - - - + +

Billing address

+ +
+ {#if addressList?.total} + {#each addressList.billingAddresses as address} +
+ +
+

{address.streetAddress}

+ {#if address?.addressLine2} +

{address.addressLine2}

+ {/if} +

{address.city}

+

{address.state}

+

{address.postalCode}

+

{address.country}

+
+
+
+ {/each} + {/if} + +
+ {#if addressList?.total} + + Add new billing address + + {/if} + {#if $changeOrganizationTier.billingAddressId === null} + + + + + + + + + + + + {/if} +
+
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts index f07f4061d..25f69bf5d 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts @@ -11,7 +11,8 @@ export const changeOrganizationTier = writable<{ id?: string; billingPlan: Tier; paymentMethodId: string; - billingAddress: Address; + billingAddressId: string; + billingAddress?: Address; billingBudget?: number; collaborators?: string[]; isOverLimit?: boolean; @@ -31,6 +32,7 @@ export const changeOrganizationTier = writable<{ paymentMethodId: null, collaborators: [], isOverLimit: false, + billingAddressId: null, billingAddress: { $id: null, streetAddress: null, @@ -42,13 +44,3 @@ export const changeOrganizationTier = writable<{ }, taxId: null }); - -export const currentBillingAddress = writable
({ - $id: null, - streetAddress: null, - addressLine2: null, - city: null, - state: null, - postalCode: null, - country: null -});