|
7 | 7 | import type { Address } from '$lib/sdk/billing';
|
8 | 8 | import { addressList } from '$lib/stores/billing';
|
9 | 9 | import { addNotification } from '$lib/stores/notifications';
|
10 |
| - import { organization } from '$lib/stores/organization'; |
| 10 | + import { type Organization } from '$lib/stores/organization'; |
11 | 11 | import { sdk } from '$lib/stores/sdk';
|
12 | 12 | import RemoveAddress from './removeAddress.svelte';
|
13 | 13 | import { user } from '$lib/stores/user';
|
|
23 | 23 | IconTrash
|
24 | 24 | } from '@appwrite.io/pink-icons-svelte';
|
25 | 25 | import type { Models } from '@appwrite.io/console';
|
26 |
| - import type { PageData } from './$types'; |
27 | 26 |
|
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; |
34 | 31 |
|
35 | 32 | let showCreate = false;
|
36 | 33 | let showEdit = false;
|
|
39 | 36 |
|
40 | 37 | async function addAddress(addressId: string) {
|
41 | 38 | try {
|
42 |
| - await sdk.forConsole.billing.setBillingAddress($organization.$id, addressId); |
| 39 | + await sdk.forConsole.billing.setBillingAddress(organization.$id, addressId); |
43 | 40 |
|
44 | 41 | addNotification({
|
45 | 42 | 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}` |
47 | 44 | });
|
48 | 45 | trackEvent(Submit.OrganizationBillingAddressUpdate);
|
49 | 46 |
|
50 | 47 | invalidate(Dependencies.ADDRESS);
|
51 |
| - invalidate(Dependencies.ORGANIZATION); |
| 48 | + invalidate(Dependencies.ORGANIZATIONS); |
52 | 49 | } catch (error) {
|
53 | 50 | addNotification({
|
54 | 51 | type: 'error',
|
|
63 | 60 | <svelte:fragment slot="title">Billing address</svelte:fragment>
|
64 | 61 | View or update your billing address. This address will be included in your invoices from Appwrite.
|
65 | 62 | <svelte:fragment slot="aside">
|
66 |
| - {#if $organization?.billingAddressId && billingAddress} |
| 63 | + {#if organization?.billingAddressId && billingAddress} |
67 | 64 | <Card.Base variant="secondary" padding="s">
|
68 | 65 | <Layout.Stack direction="row" justifyContent="space-between">
|
69 | 66 | <div>
|
|
140 | 137 | </CardGrid>
|
141 | 138 |
|
142 | 139 | {#if showCreate}
|
143 |
| - <AddressModal bind:show={showCreate} organization={$organization?.$id} {countryList} {locale} /> |
| 140 | + <AddressModal bind:show={showCreate} organization={organization?.$id} {countryList} {locale} /> |
144 | 141 | {/if}
|
145 | 142 | {#if showEdit}
|
146 | 143 | <EditAddressModal
|
|
0 commit comments