Skip to content

Commit 1a296a2

Browse files
committed
fix: ensure billing address on the org and account page updates
1 parent 6867b35 commit 1a296a2

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

src/routes/(console)/account/payments/addressModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
if (organization) {
5757
org = await sdk.forConsole.billing.setBillingAddress(organization, response.$id);
5858
trackEvent(Submit.OrganizationBillingAddressUpdate);
59-
await invalidate(Dependencies.ORGANIZATION);
59+
await invalidate(Dependencies.ORGANIZATIONS);
6060
}
6161
await invalidate(Dependencies.ADDRESS);
6262

src/routes/(console)/organization-[organization]/billing/+page.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@
135135
currentInvoice={data?.billingInvoice} />
136136
<PaymentHistory />
137137
<PaymentMethods organization={data?.organization} methods={data?.paymentMethods} />
138-
<BillingAddress {data} />
138+
<BillingAddress
139+
organization={data?.organization}
140+
billingAddress={data?.billingAddress}
141+
locale={data?.locale}
142+
countryList={data?.countryList} />
139143
<TaxId />
140144
<BudgetCap organization={data?.organization} currentPlan={data?.currentPlan} />
141145
<AvailableCredit areCreditsSupported={data.areCreditsSupported} />

src/routes/(console)/organization-[organization]/billing/billingAddress.svelte

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import type { Address } from '$lib/sdk/billing';
88
import { addressList } from '$lib/stores/billing';
99
import { addNotification } from '$lib/stores/notifications';
10-
import { organization } from '$lib/stores/organization';
10+
import { type Organization } from '$lib/stores/organization';
1111
import { sdk } from '$lib/stores/sdk';
1212
import RemoveAddress from './removeAddress.svelte';
1313
import { user } from '$lib/stores/user';
@@ -23,14 +23,11 @@
2323
IconTrash
2424
} from '@appwrite.io/pink-icons-svelte';
2525
import type { Models } from '@appwrite.io/console';
26-
import type { PageData } from './$types';
2726
28-
export let data: PageData;
29-
30-
const locale: Models.Locale = data.locale;
31-
const countryList: Models.CountryList = data.countryList;
32-
33-
let billingAddress: Address = data?.billingAddress;
27+
export let organization: Organization;
28+
export let locale: Models.Locale;
29+
export let countryList: Models.CountryList;
30+
export let billingAddress: Address;
3431
3532
let showCreate = false;
3633
let showEdit = false;
@@ -39,16 +36,16 @@
3936
4037
async function addAddress(addressId: string) {
4138
try {
42-
await sdk.forConsole.billing.setBillingAddress($organization.$id, addressId);
39+
await sdk.forConsole.billing.setBillingAddress(organization.$id, addressId);
4340
4441
addNotification({
4542
type: 'success',
46-
message: `A new billing address has been added to ${$organization.name}`
43+
message: `A new billing address has been added to ${organization.name}`
4744
});
4845
trackEvent(Submit.OrganizationBillingAddressUpdate);
4946
5047
invalidate(Dependencies.ADDRESS);
51-
invalidate(Dependencies.ORGANIZATION);
48+
invalidate(Dependencies.ORGANIZATIONS);
5249
} catch (error) {
5350
addNotification({
5451
type: 'error',
@@ -63,7 +60,7 @@
6360
<svelte:fragment slot="title">Billing address</svelte:fragment>
6461
View or update your billing address. This address will be included in your invoices from Appwrite.
6562
<svelte:fragment slot="aside">
66-
{#if $organization?.billingAddressId && billingAddress}
63+
{#if organization?.billingAddressId && billingAddress}
6764
<Card.Base variant="secondary" padding="s">
6865
<Layout.Stack direction="row" justifyContent="space-between">
6966
<div>
@@ -140,7 +137,7 @@
140137
</CardGrid>
141138

142139
{#if showCreate}
143-
<AddressModal bind:show={showCreate} organization={$organization?.$id} {countryList} {locale} />
140+
<AddressModal bind:show={showCreate} organization={organization?.$id} {countryList} {locale} />
144141
{/if}
145142
{#if showEdit}
146143
<EditAddressModal

src/routes/(console)/organization-[organization]/billing/removeAddress.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
message: `The billing address has been removed from ${$organization.name}`
2121
});
2222
trackEvent(Submit.OrganizationBillingAddressDelete);
23-
invalidate(Dependencies.ORGANIZATION);
23+
invalidate(Dependencies.ORGANIZATIONS);
2424
show = false;
2525
} catch (e) {
2626
error = e.message;

0 commit comments

Comments
 (0)