mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: deletion modal now doesn't allow deletion when linked to orgs
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import AddressModal from './addressModal.svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import DeleteAddress from './deleteAddress.svelte';
|
||||
import DeleteAddress from './deleteAddressModal.svelte';
|
||||
import EditAddressModal from './editAddressModal.svelte';
|
||||
import type { Address } from '$lib/sdk/billing';
|
||||
import { organizationList, type Organization } from '$lib/stores/organization';
|
||||
@@ -25,6 +25,7 @@
|
||||
let show = false;
|
||||
let showEdit = false;
|
||||
let selectedAddress: Address;
|
||||
let selectedLinkedOrgs: Organization[] = [];
|
||||
let showDelete = false;
|
||||
let showDropdown = [];
|
||||
let countryList: Models.CountryList;
|
||||
@@ -126,6 +127,7 @@
|
||||
on:click={() => {
|
||||
showDelete = true;
|
||||
selectedAddress = address;
|
||||
selectedLinkedOrgs = linkedOrgs;
|
||||
showDropdown[i] = false;
|
||||
}}>
|
||||
Delete
|
||||
@@ -152,4 +154,4 @@
|
||||
|
||||
<AddressModal bind:show />
|
||||
<EditAddressModal bind:show={showEdit} {selectedAddress} />
|
||||
<DeleteAddress bind:showDelete {selectedAddress} />
|
||||
<DeleteAddress bind:showDelete {selectedAddress} linkedOrgs={selectedLinkedOrgs} />
|
||||
|
||||
+32
-3
@@ -1,15 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
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 type { Address } from '$lib/sdk/billing';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { Organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
export let showDelete = false;
|
||||
export let selectedAddress: Address;
|
||||
export let linkedOrgs: Organization[] = [];
|
||||
let error: string = null;
|
||||
|
||||
async function handleDelete() {
|
||||
@@ -35,12 +38,38 @@
|
||||
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 account?</p>
|
||||
<svelte:fragment slot="title">
|
||||
{linkedOrgs.length ? 'Unable to delete billing address' : 'Delete billing address'}
|
||||
</svelte:fragment>
|
||||
|
||||
{#if linkedOrgs.length === 1}
|
||||
<p class="text">
|
||||
This billing address is set as the default for the <span class="u-bold"
|
||||
>{linkedOrgs[0].name}</span
|
||||
>. As it has upcoming invoices it cannot be deleted from your account.
|
||||
</p>
|
||||
{:else if linkedOrgs.length > 1}
|
||||
<p class="text">
|
||||
This billing address is set as the default for the following organisations. As they have
|
||||
upcoming invoices it cannot be deleted from your account.
|
||||
</p>
|
||||
<ul>
|
||||
{#each linkedOrgs as org}
|
||||
<li class="text">
|
||||
<a class="link" href={`${base}/console/organization-${org.$id}/billing`}
|
||||
>{org.name}</a>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{:else}
|
||||
<p class="text">Are you sure you want to delete this billing address from your account?</p>
|
||||
{/if}
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
{#if !linkedOrgs.length}
|
||||
<Button secondary submit>Delete</Button>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -39,10 +39,9 @@
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="title"
|
||||
>{linkedOrgs.length
|
||||
? 'Unable to delete payment method'
|
||||
: 'Delete payment method'}</svelte:fragment>
|
||||
<svelte:fragment slot="title">
|
||||
{linkedOrgs.length ? 'Unable to delete payment method' : 'Delete payment method'}
|
||||
</svelte:fragment>
|
||||
{#if linkedOrgs.length === 1}
|
||||
<p class="text">
|
||||
This payment method is set as the default for the <span class="u-bold"
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
</DropList>
|
||||
</div>
|
||||
<div class="common-section">
|
||||
<span class="text"> Add a billing address</span>
|
||||
<span class="text">Add a billing address</span>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
Reference in New Issue
Block a user