mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: address and invalidation
This commit is contained in:
@@ -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`
|
||||
});
|
||||
|
||||
@@ -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 @@
|
||||
<Table noStyles noMargin>
|
||||
<TableHeader>
|
||||
<TableCellHead>Date Added</TableCellHead>
|
||||
<!-- <TableCellHead>Expiry Date</TableCellHead> -->
|
||||
<TableCellHead>Expiry Date</TableCellHead>
|
||||
<TableCellHead>Amount</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
@@ -101,9 +102,9 @@
|
||||
<TableCellText title="date added">
|
||||
{toLocaleDate(credit.$createdAt)}
|
||||
</TableCellText>
|
||||
<!-- <TableCellText title="expiry date">
|
||||
<TableCellText title="expiry date">
|
||||
{toLocaleDate(credit.expiration)}
|
||||
</TableCellText> -->
|
||||
</TableCellText>
|
||||
<TableCellText title="amount">
|
||||
${credit.credits}
|
||||
</TableCellText>
|
||||
|
||||
@@ -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 @@
|
||||
<DropListItem
|
||||
icon="trash"
|
||||
on:click={() => {
|
||||
showDelete = true;
|
||||
showBillingAddressDropdown = false;
|
||||
}}>
|
||||
Delete
|
||||
@@ -144,3 +150,4 @@
|
||||
|
||||
<AddressModal bind:show={showCreate} organization={$organization?.$id} />
|
||||
<EditAddressModal bind:show={showEdit} bind:selectedAddress={billingAddress} />
|
||||
<RemoveAddressModal bind:showDelete />
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
export let showDelete = false;
|
||||
let error: string = null;
|
||||
|
||||
async function handleDelete() {
|
||||
try {
|
||||
await sdk.forConsole.billing.removeBillingAddress($organization.$id);
|
||||
await invalidate(Dependencies.ADDRESS);
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Billing address has been removed from ${$organization.name}`
|
||||
});
|
||||
trackEvent(Submit.OrganizationBillingAddressDelete);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.OrganizationBillingAddressUpdate);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}
|
||||
title="Delete billing address"
|
||||
bind:error>
|
||||
<p class="text">
|
||||
Are you sure you want to delete this billing address from your <b>{$organization?.name}</b>?
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
Reference in New Issue
Block a user