From 726d1650361b853d0dbf80bc7950574eca684f3d Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 22 Nov 2023 18:23:57 +0100 Subject: [PATCH] fix: address and invalidation --- .../account/payments/addressModal.svelte | 15 ++---- .../billing/availableCredit.svelte | 9 ++-- .../billing/billingAddress.svelte | 7 +++ .../billing/removeAddressModal.svelte | 51 +++++++++++++++++++ 4 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 src/routes/console/organization-[organization]/billing/removeAddressModal.svelte diff --git a/src/routes/console/account/payments/addressModal.svelte b/src/routes/console/account/payments/addressModal.svelte index ff46a2575..437a8508f 100644 --- a/src/routes/console/account/payments/addressModal.svelte +++ b/src/routes/console/account/payments/addressModal.svelte @@ -49,21 +49,16 @@ trackEvent(Submit.BillingAddressCreate); let org: Organization = null; if (organization) { - console.log(response); - Promise.allSettled([ - (org = await sdk.forConsole.billing.setBillingAddress( - organization, - response.$id - )) - ]); + org = await sdk.forConsole.billing.setBillingAddress(organization, response.$id); trackEvent(Submit.OrganizationBillingAddressUpdate); - console.log(org); + await invalidate(Dependencies.ORGANIZATION); } - Promise.allSettled([await invalidate(Dependencies.ADDRESS)]); + await invalidate(Dependencies.ADDRESS); + show = false; addNotification({ type: 'success', - message: org + message: org?.name ? `A new billing address has been added to ${org.name}` : `Address has been added` }); diff --git a/src/routes/console/organization-[organization]/billing/availableCredit.svelte b/src/routes/console/organization-[organization]/billing/availableCredit.svelte index 3775455ae..46440be3d 100644 --- a/src/routes/console/organization-[organization]/billing/availableCredit.svelte +++ b/src/routes/console/organization-[organization]/billing/availableCredit.svelte @@ -40,7 +40,8 @@ type: 'success', message: `Credit has been added to ${$organization.name}` }); - invalidate(Dependencies.ORGANIZATION); + await invalidate(Dependencies.CREDIT); + await invalidate(Dependencies.ORGANIZATION); trackEvent(Submit.CreditRedeem, { coupon }); @@ -92,7 +93,7 @@ Date Added - + Expiry Date Amount @@ -101,9 +102,9 @@ {toLocaleDate(credit.$createdAt)} - + ${credit.credits} diff --git a/src/routes/console/organization-[organization]/billing/billingAddress.svelte b/src/routes/console/organization-[organization]/billing/billingAddress.svelte index 4f884b582..c3320287d 100644 --- a/src/routes/console/organization-[organization]/billing/billingAddress.svelte +++ b/src/routes/console/organization-[organization]/billing/billingAddress.svelte @@ -11,16 +11,21 @@ import { sdk } from '$lib/stores/sdk'; import AddressModal from '$routes/console/account/payments/addressModal.svelte'; import EditAddressModal from '$routes/console/account/payments/editAddressModal.svelte'; + import RemoveAddressModal from './removeAddressModal.svelte'; let showDropdown = false; let showBillingAddressDropdown = false; let showCreate = false; let showEdit = false; + let showDelete = false; async function addAddress(addressId: string) { try { await sdk.forConsole.billing.setBillingAddress($organization.$id, addressId); + await invalidate(Dependencies.ADDRESS); + await invalidate(Dependencies.ORGANIZATION); + showDropdown = false; addNotification({ type: 'success', @@ -84,6 +89,7 @@ { + showDelete = true; showBillingAddressDropdown = false; }}> Delete @@ -144,3 +150,4 @@ + diff --git a/src/routes/console/organization-[organization]/billing/removeAddressModal.svelte b/src/routes/console/organization-[organization]/billing/removeAddressModal.svelte new file mode 100644 index 000000000..e187ca4e3 --- /dev/null +++ b/src/routes/console/organization-[organization]/billing/removeAddressModal.svelte @@ -0,0 +1,51 @@ + + + +

+ Are you sure you want to delete this billing address from your {$organization?.name}? +

+ + + + + +