From 7bd20f2417bb7db577a6b06d30a7cf8ba958e72a Mon Sep 17 00:00:00 2001
From: Arman
Date: Fri, 24 Nov 2023 14:00:01 +0100
Subject: [PATCH 1/7] feat: confimation payment stripe
---
src/lib/sdk/billing.ts | 5 +-
.../billing/+page.svelte | 63 ++++++++++++++-----
.../excesLimitModal.svelte | 7 ++-
3 files changed, 56 insertions(+), 19 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 08821c7af..fd0f37c4c 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -37,6 +37,7 @@ export type Invoice = {
to: string;
status: string;
dueAt: string;
+ clientSecret: string;
};
export type InvoiceList = {
@@ -145,10 +146,10 @@ export type Aggregation = {
};
export type OrganizationUsage = {
- bandwidth: [];
+ bandwidth: { date: string; value: number }[];
executions: number;
storage: number;
- users: [];
+ users: { date: string; value: number }[];
};
export type AggregationList = {
diff --git a/src/routes/console/organization-[organization]/billing/+page.svelte b/src/routes/console/organization-[organization]/billing/+page.svelte
index 02ea49441..0699966b5 100644
--- a/src/routes/console/organization-[organization]/billing/+page.svelte
+++ b/src/routes/console/organization-[organization]/billing/+page.svelte
@@ -14,8 +14,10 @@
import type { PaymentMethodData } from '$lib/sdk/billing';
import { onMount } from 'svelte';
import { page } from '$app/stores';
- import { isStripeInitialized, stripe } from '$lib/stores/stripe';
+ import { initializeStripe, isStripeInitialized, stripe } from '$lib/stores/stripe';
import { base } from '$app/paths';
+ import { sdk } from '$lib/stores/sdk';
+ import { addNotification } from '$lib/stores/notifications';
$: defaultPaymentMethod = $paymentMethods?.paymentMethods?.find(
(method: PaymentMethodData) => method.$id === $organization?.paymentMethodId
@@ -27,25 +29,58 @@
onMount(async () => {
if (
- $isStripeInitialized &&
- $page.url.searchParams.has('invoice') &&
- $page.url.searchParams.has('type') &&
- $page.url.searchParams.get('type') === 'confirmation'
+ ($page.url.searchParams.has('invoice') &&
+ $page.url.searchParams.has('type') &&
+ $page.url.searchParams.get('type') === 'confirmation') ||
+ $page.url.searchParams.has('clientSecret')
) {
+ if (!$isStripeInitialized) {
+ await initializeStripe();
+ }
console.log('test');
console.log($page.url.searchParams.get('invoice'));
-
- const { setupIntent, error } = await $stripe.confirmCardSetup(
- '{SETUP_INTENT_CLIENT_SECRET}',
- {
- payment_method: {
- id: $organization.paymentMethodId,
+ try {
+ const invoiceId = $page.url.searchParams.get('invoice');
+ const invoice = await sdk.forConsole.billing.getInvoice(
+ $page.params.organization,
+ invoiceId
+ );
+ const { setupIntent, error } = await $stripe.confirmCardSetup(
+ invoice.clientSecret,
+ {
+ payment_method: $organization.paymentMethodId,
return_url: `${base}/console/organization-${$organization.$id}/billing`
}
+ );
+ console.log(setupIntent);
+ if (error) {
+ console.log('Something went wrong');
}
- );
- if (error) {
- console.log('Something went wrong');
+ if (setupIntent.status === 'succeeded') {
+ if (typeof setupIntent.payment_method === 'string') {
+ await sdk.forConsole.billing.setOrganizationPaymentMethod(
+ $page.params.organization,
+ setupIntent.payment_method
+ );
+ } else {
+ await sdk.forConsole.billing.setOrganizationPaymentMethod(
+ $page.params.organization,
+ setupIntent.payment_method.id
+ );
+ }
+ addNotification({
+ title: 'Success',
+ message: 'Your payment method has been updated',
+ type: 'success'
+ });
+ }
+ } catch (error) {
+ addNotification({
+ title: 'Error',
+ message:
+ 'There was an error processing your payment, try again later. If the problem persists, please contact support.',
+ type: 'error'
+ });
}
}
});
diff --git a/src/routes/console/organization-[organization]/excesLimitModal.svelte b/src/routes/console/organization-[organization]/excesLimitModal.svelte
index 90c06db66..102fa4258 100644
--- a/src/routes/console/organization-[organization]/excesLimitModal.svelte
+++ b/src/routes/console/organization-[organization]/excesLimitModal.svelte
@@ -30,14 +30,15 @@
});
function calculateExcess() {
+ const totBandwidth = usage?.bandwidth?.length > 0 ? usage.bandwidth[0].value : 0;
+ const totUsers = usage?.users?.length > 0 ? usage.users[0].value : 0;
excess = {
- bandwidth:
- usage?.bandwidth?.[0] > plan.bandwidth ? usage?.bandwidth?.[0] - plan.bandwidth : 0,
+ bandwidth: totBandwidth > plan.bandwidth ? totBandwidth - plan.bandwidth : 0,
storage:
usage?.storage[0] > sizeToBytes(plan.storage, 'GB')
? usage.storage[0] - plan.storage
: 0,
- users: usage?.users?.[0] > plan.users ? usage?.users?.[0] - plan.users : 0,
+ users: totUsers > plan.users ? totUsers - plan.users : 0,
executions:
usage?.executions[0] > plan.executions ? usage.executions[0] - plan.executions : 0,
members: members.total > plan.members ? members.total - (plan.members || Infinity) : 0
From 6cc245c60e621ce8dd94d0684cb8e8258c281598 Mon Sep 17 00:00:00 2001
From: Arman
Date: Fri, 24 Nov 2023 15:43:43 +0100
Subject: [PATCH 2/7] fix: feedback
---
src/lib/sdk/billing.ts | 13 ++++++-
.../changeOrganizationTierCloud.svelte | 14 +++++--
.../wizard/step2.svelte | 39 ++++++++++++++++++-
src/routes/console/supportWizard.svelte | 3 +-
.../confirmDetails.svelte | 1 -
.../cloudOrganizationChangeTier/store.ts | 1 +
6 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index fd0f37c4c..1320c2502 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -157,8 +157,19 @@ export type AggregationList = {
total: number;
};
+export type AllowedRegions =
+ | 'eu-de'
+ | 'us-nyc'
+ | 'us-sfo'
+ | 'ap-in'
+ | 'eu-gb'
+ | 'eu-nl'
+ | 'ap-sg'
+ | 'ap-ca'
+ | 'ap-au';
+
export type Region = {
- $id: string;
+ $id: AllowedRegions;
name: string;
disabled: boolean;
default: boolean;
diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte
index d911a994d..073106313 100644
--- a/src/routes/console/changeOrganizationTierCloud.svelte
+++ b/src/routes/console/changeOrganizationTierCloud.svelte
@@ -25,11 +25,13 @@
import { wizard } from '$lib/stores/wizard';
import { tierToPlan } from '$lib/stores/billing';
import deepEqual from 'deep-equal';
+ import { user } from '$lib/stores/user';
+ import { feedback } from '$lib/stores/feedback';
const dispatch = createEventDispatcher();
async function onFinish() {
- await invalidate(Dependencies.FUNCTIONS);
+ await invalidate(Dependencies.ORGANIZATION);
}
async function changeTier() {
@@ -40,8 +42,13 @@
$changeOrganizationTier.billingPlan,
$changeOrganizationTier.paymentMethodId
);
+ feedback.submitFeedback(
+ 'downgrade',
+ $changeOrganizationTier.feedbackMessage,
+ $user?.name ?? '',
+ $user.email
+ );
- //TODO: send feedback
addNotification({
type: 'success',
isHtml: true,
@@ -174,7 +181,8 @@
postalCode: null,
country: null
},
- taxId: null
+ taxId: null,
+ feedbackMessage: null
};
});
diff --git a/src/routes/console/organization-[organization]/wizard/step2.svelte b/src/routes/console/organization-[organization]/wizard/step2.svelte
index df817841e..fff6bc9c3 100644
--- a/src/routes/console/organization-[organization]/wizard/step2.svelte
+++ b/src/routes/console/organization-[organization]/wizard/step2.svelte
@@ -6,11 +6,42 @@
import { onMount } from 'svelte';
import { createProject } from './store';
import type { RegionList } from '$lib/sdk/billing';
+ import { user } from '$lib/stores/user';
+ import { VARS } from '$lib/system';
+ import { addNotification } from '$lib/stores/notifications';
let regions: RegionList;
+ let selectedRegion: string;
onMount(async () => {
regions = await sdk.forConsole.billing.listRegions();
});
+
+ async function notifyRegion() {
+ const response = await fetch(
+ `https://${VARS.GROWTH_ENDPOINT}/v1/mailinglists/${selectedRegion}`,
+ {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ name: $user.name,
+ email: $user.email
+ })
+ }
+ );
+ if (response.status !== 200) {
+ addNotification({
+ message: 'There was an error submitting your request',
+ type: 'error'
+ });
+ } else {
+ addNotification({
+ message: 'Your request was submitted successfully',
+ type: 'success'
+ });
+ }
+ }
@@ -39,7 +70,13 @@
flag={region.flag}
name={region.name} />
{region.name}
-
+ {
+ selectedRegion = region.$id;
+ notifyRegion();
+ }}>
Notify me
diff --git a/src/routes/console/supportWizard.svelte b/src/routes/console/supportWizard.svelte
index 6f7f20dc0..db07c38de 100644
--- a/src/routes/console/supportWizard.svelte
+++ b/src/routes/console/supportWizard.svelte
@@ -8,6 +8,7 @@
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { addNotification } from '$lib/stores/notifications';
import { wizard } from '$lib/stores/wizard';
+ import { VARS } from '$lib/system';
onDestroy(() => {
$supportData = {
@@ -25,7 +26,7 @@
});
async function handleSubmit() {
- const response = await fetch('https://growth.appwrite.io/v1/support', {
+ const response = await fetch(`https://${VARS.GROWTH_ENDPOINT}/v1/support`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
index 789b100d6..5f8fb1ac1 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
@@ -55,7 +55,6 @@
there is a specific reason you chose to change your plan at this time, please let us
know.
-
- {
- show = false;
- goto(`/console/organization-${$organization.$id}/usage`);
- }}>View usage
+
+
(show = false)}>Cancel
+
+ {
+ show = false;
+ goto(`/console/organization-${$organization.$id}/usage`);
+ }}>View usage
- {
- show = false;
- wizard.start(ChangeOrganizationTierCloud);
- }}>Upgrade plan
+ {
+ show = false;
+ wizard.start(ChangeOrganizationTierCloud);
+ }}>Upgrade plan
+
+
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
index 847840580..100615b30 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/choosePlan.svelte
@@ -41,14 +41,15 @@
(plan) => plan.$id === $changeOrganizationTier.billingPlan
);
+ const totBandwidth = usage?.bandwidth?.length > 0 ? usage.bandwidth[0].value : 0;
+ const totUsers = usage?.users?.length > 0 ? usage.users[0].value : 0;
$changeOrganizationTier.limitOverflow = {
- bandwidth:
- usage.bandwidth[0] > plan.bandwidth ? usage.bandwidth[0] - plan.bandwidth : 0,
+ bandwidth: totBandwidth > plan.bandwidth ? totBandwidth - plan.bandwidth : 0,
storage:
usage.storage[0] > sizeToBytes(plan.storage, 'GB')
? usage.storage[0] - plan.storage
: 0,
- users: usage.users[0] > plan.users ? usage.users[0] - plan.users : 0,
+ users: totUsers > plan.users ? totUsers - plan.users : 0,
executions:
usage.executions[0] > plan.executions ? usage.executions[0] - plan.executions : 0,
members: members.total > plan.members ? members.total - (plan.members || Infinity) : 0
From 1c13749cbd354d3df66b1bcd30f0483e7183827f Mon Sep 17 00:00:00 2001
From: Arman
Date: Fri, 24 Nov 2023 16:42:46 +0100
Subject: [PATCH 4/7] feat: add credits to upgrade flow
---
src/lib/sdk/billing.ts | 11 +++-
.../changeOrganizationTierCloud.svelte | 8 +++
.../confirmDetails.svelte | 56 +++++++++++++++++--
.../cloudOrganizationChangeTier/store.ts | 1 +
4 files changed, 71 insertions(+), 5 deletions(-)
diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts
index 1320c2502..ae547df4b 100644
--- a/src/lib/sdk/billing.ts
+++ b/src/lib/sdk/billing.ts
@@ -45,6 +45,15 @@ export type InvoiceList = {
total: number;
};
+export type Coupon = {
+ $id: string;
+ code: string;
+ credits: number;
+ expiration: string;
+ status: string; // 'active' | 'disabled' | 'expired'
+ validity: number;
+};
+
export type Credit = {
/**
* Credit ID.
@@ -580,7 +589,7 @@ export class Billing {
);
}
- async getCoupon(couponId: string): Promise> {
+ async getCoupon(couponId: string): Promise {
const path = `/console/coupons/${couponId}`;
const params = {
couponId
diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte
index 073106313..1b78d8821 100644
--- a/src/routes/console/changeOrganizationTierCloud.svelte
+++ b/src/routes/console/changeOrganizationTierCloud.svelte
@@ -101,6 +101,14 @@
await sdk.forConsole.billing.setBillingAddress(org.$id, response.$id);
}
+ //Add coupon
+ if ($changeOrganizationTier.couponCode) {
+ await sdk.forConsole.billing.addCredit(
+ org.$id,
+ $changeOrganizationTier.couponCode
+ );
+ }
+
//Add budget
if ($changeOrganizationTier?.billingBudget) {
await sdk.forConsole.billing.updateBudget(
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
index 5f8fb1ac1..3b403fc01 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte
@@ -4,6 +4,7 @@
import { Button, FormList, InputText, InputTextarea } from '$lib/elements/forms';
import { toLocaleDate } from '$lib/helpers/date';
import { WizardStep } from '$lib/layout';
+ import type { Coupon } from '$lib/sdk/billing';
import { plansInfo } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
@@ -21,6 +22,12 @@
let coupon: string = null;
let comment: string = null;
+ let couponData: Partial = {
+ code: null,
+ status: null,
+ credits: null
+ };
+ let showCoupon: boolean = false;
async function fetchCard() {
try {
const card = await sdk.forConsole.billing.getPaymentMethod(
@@ -32,15 +39,30 @@
}
}
- async function applyCredit() {
+ async function addCoupon() {
try {
- await sdk.forConsole.billing.getCoupon(coupon);
+ const response = await sdk.forConsole.billing.getCoupon(coupon);
coupon = null;
+ couponData = response;
+ showCoupon = true;
+ $changeOrganizationTier.couponCode = response.$id;
} catch (error) {
console.log(error);
+ couponData.code = coupon;
+ couponData.status = 'error';
+ showCoupon = true;
}
}
+ function removeCoupon() {
+ couponData = {
+ code: null,
+ status: null,
+ credits: null
+ };
+ showCoupon = false;
+ }
+
$: downgradeToStarter = $changeOrganizationTier.billingPlan === 'tier-0';
$: if (!$isUpgrade) {
$changeOrganizationFinalAction = 'Confirm plan change';
@@ -101,14 +123,40 @@
{/if}
-
+
- Apply
+
+ Apply
+
+ {#if showCoupon}
+ {#if couponData?.status === 'error'}
+
+
+
+ {couponData.code} is not a valid promo code
+
+
+ {:else}
+
+
+
+
+ {couponData.code} applied (-${couponData.credits})
+
+
+
Remove
+
+ {/if}
+ {/if}
{#if $changeOrganizationTier.billingPlan !== 'tier-0'}
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts
index 969d28dc8..f07f4061d 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts
@@ -24,6 +24,7 @@ export const changeOrganizationTier = writable<{
};
taxId?: string;
feedbackMessage?: string;
+ couponCode?: string;
}>({
id: null,
billingPlan: 'tier-1',
From b7a50ec303c334436263d24eaa1661fd1a33bc07 Mon Sep 17 00:00:00 2001
From: Arman
Date: Fri, 24 Nov 2023 17:30:12 +0100
Subject: [PATCH 5/7] feat: save notifications into user prefs
---
.../wizard/step2.svelte | 65 +++++++++----------
1 file changed, 29 insertions(+), 36 deletions(-)
diff --git a/src/routes/console/organization-[organization]/wizard/step2.svelte b/src/routes/console/organization-[organization]/wizard/step2.svelte
index fff6bc9c3..7eae737f7 100644
--- a/src/routes/console/organization-[organization]/wizard/step2.svelte
+++ b/src/routes/console/organization-[organization]/wizard/step2.svelte
@@ -5,43 +5,35 @@
import { sdk } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { createProject } from './store';
- import type { RegionList } from '$lib/sdk/billing';
- import { user } from '$lib/stores/user';
- import { VARS } from '$lib/system';
+ import type { Region, RegionList } from '$lib/sdk/billing';
import { addNotification } from '$lib/stores/notifications';
+ import type { Models } from '@appwrite.io/console';
let regions: RegionList;
- let selectedRegion: string;
+ let prefs: Models.Preferences;
onMount(async () => {
regions = await sdk.forConsole.billing.listRegions();
+ prefs = await sdk.forConsole.account.getPrefs();
});
- async function notifyRegion() {
- const response = await fetch(
- `https://${VARS.GROWTH_ENDPOINT}/v1/mailinglists/${selectedRegion}`,
- {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- name: $user.name,
- email: $user.email
- })
- }
- );
- if (response.status !== 200) {
+ async function notifyRegion(selectedRegion: Region) {
+ try {
+ let newPrefs = { ...prefs };
+ newPrefs.notifications = newPrefs.notifications ?? [];
+ newPrefs.notifications = [...newPrefs.notifications, selectedRegion.$id];
+ const response = await sdk.forConsole.account.updatePrefs(newPrefs);
+ prefs = response.prefs;
addNotification({
- message: 'There was an error submitting your request',
- type: 'error'
- });
- } else {
- addNotification({
- message: 'Your request was submitted successfully',
- type: 'success'
+ type: 'success',
+ isHtml: true,
+ message: `You will be notified when ${selectedRegion.name} region is available`
});
+ } catch (error) {
+ console.log(error);
}
}
+
+ $: notifications = prefs?.notifications ?? [];
@@ -70,16 +62,17 @@
flag={region.flag}
name={region.name} />
{region.name}
- {
- selectedRegion = region.$id;
- notifyRegion();
- }}>
-
- Notify me
-
+ {#if !notifications.includes(region.$id)}
+ {
+ notifyRegion(region);
+ }}>
+
+ Notify me
+
+ {/if}
{:else}
Date: Fri, 24 Nov 2023 17:52:48 +0100
Subject: [PATCH 6/7] feat: new billing address flow during creation and
upgrade
---
.../changeOrganizationTierCloud.svelte | 13 +-
.../console/createOrganizationCloud.svelte | 8 +-
.../cloudOrganization/addressDetails.svelte | 148 ++++++++++------
.../console/wizard/cloudOrganization/store.ts | 4 +-
.../addressDetails.svelte | 160 +++++++++++-------
.../cloudOrganizationChangeTier/store.ts | 14 +-
6 files changed, 220 insertions(+), 127 deletions(-)
diff --git a/src/routes/console/changeOrganizationTierCloud.svelte b/src/routes/console/changeOrganizationTierCloud.svelte
index 1b78d8821..588d07ad6 100644
--- a/src/routes/console/changeOrganizationTierCloud.svelte
+++ b/src/routes/console/changeOrganizationTierCloud.svelte
@@ -14,7 +14,6 @@
changeOrganizationFinalAction,
changeOrganizationTier,
changeTierSteps,
- currentBillingAddress,
isUpgrade
} from './wizard/cloudOrganizationChangeTier/store';
import { goto, invalidate } from '$app/navigation';
@@ -24,7 +23,6 @@
import { organization } from '$lib/stores/organization';
import { wizard } from '$lib/stores/wizard';
import { tierToPlan } from '$lib/stores/billing';
- import deepEqual from 'deep-equal';
import { user } from '$lib/stores/user';
import { feedback } from '$lib/stores/feedback';
@@ -82,10 +80,14 @@
);
//Add billing address
- if (
+ if ($changeOrganizationTier.billingAddressId) {
+ await sdk.forConsole.billing.setBillingAddress(
+ org.$id,
+ $changeOrganizationTier.billingAddressId
+ );
+ } else if (
$changeOrganizationTier.billingAddress &&
- $changeOrganizationTier.billingAddress.streetAddress &&
- !deepEqual($changeOrganizationTier.billingAddress, $currentBillingAddress)
+ $changeOrganizationTier.billingAddress.streetAddress
) {
const response = await sdk.forConsole.billing.createAddress(
$changeOrganizationTier.billingAddress.country,
@@ -180,6 +182,7 @@
billingPlan: 'tier-1',
paymentMethodId: null,
collaborators: [],
+ billingAddressId: null,
billingAddress: {
$id: null,
streetAddress: null,
diff --git a/src/routes/console/createOrganizationCloud.svelte b/src/routes/console/createOrganizationCloud.svelte
index 6f1c7506f..00865408d 100644
--- a/src/routes/console/createOrganizationCloud.svelte
+++ b/src/routes/console/createOrganizationCloud.svelte
@@ -33,7 +33,12 @@
$createOrganization.paymentMethodId
);
//Add billing address
- if (
+ if ($createOrganization.billingAddressId) {
+ await sdk.forConsole.billing.setBillingAddress(
+ org.$id,
+ $createOrganization.billingAddressId
+ );
+ } else if (
$createOrganization.billingAddress &&
$createOrganization.billingAddress.streetAddress
) {
@@ -106,6 +111,7 @@
billingPlan: 'tier-1',
paymentMethodId: null,
collaborators: [],
+ billingAddressId: null,
billingAddress: {
$id: null,
streetAddress: null,
diff --git a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte
index 478de06d6..cd22c6f43 100644
--- a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte
@@ -1,10 +1,11 @@
@@ -41,54 +39,98 @@
Depending on your location, your billing address might need to be in the same country
associated with the payment method for your organization.
-
-
-
-
-
-
-
-
-
-
+
+ Billing address
+
+
+ {#if addressList?.total}
+ {#each addressList.billingAddresses as address}
+
+
+
+
{address.streetAddress}
+ {#if address?.addressLine2}
+
{address.addressLine2}
+ {/if}
+
{address.city}
+
{address.state}
+
{address.postalCode}
+
{address.country}
+
+
+
+ {/each}
+ {/if}
+
+
+ {#if addressList?.total}
+
+ Add new billing address
+
+ {/if}
+ {#if $changeOrganizationTier.billingAddressId === null}
+
+
+
+
+
+
+
+
+
+
+
+ {/if}
+
+
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts
index f07f4061d..25f69bf5d 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/store.ts
@@ -11,7 +11,8 @@ export const changeOrganizationTier = writable<{
id?: string;
billingPlan: Tier;
paymentMethodId: string;
- billingAddress: Address;
+ billingAddressId: string;
+ billingAddress?: Address;
billingBudget?: number;
collaborators?: string[];
isOverLimit?: boolean;
@@ -31,6 +32,7 @@ export const changeOrganizationTier = writable<{
paymentMethodId: null,
collaborators: [],
isOverLimit: false,
+ billingAddressId: null,
billingAddress: {
$id: null,
streetAddress: null,
@@ -42,13 +44,3 @@ export const changeOrganizationTier = writable<{
},
taxId: null
});
-
-export const currentBillingAddress = writable({
- $id: null,
- streetAddress: null,
- addressLine2: null,
- city: null,
- state: null,
- postalCode: null,
- country: null
-});
From fc137fecc513455c5c0dee7370baf140de44a4a4 Mon Sep 17 00:00:00 2001
From: Arman
Date: Fri, 24 Nov 2023 22:26:16 +0100
Subject: [PATCH 7/7] fix: QA issues
---
src/lib/elements/forms/button.svelte | 2 +
src/lib/layout/headerAlert.svelte | 26 ++++++++
src/lib/layout/index.ts | 1 +
src/routes/console/+layout.svelte | 60 ++++++++++---------
.../billing/replaceCard.svelte | 9 ++-
.../createMember.svelte | 1 +
.../members/+page.ts | 5 +-
.../settings/+page.svelte | 2 +-
.../settings/+page.ts | 10 ++++
.../{ => settings}/deleteOrganization.svelte | 35 +++++++----
.../organization-[organization]/store.ts | 5 +-
.../cloudOrganization/addressDetails.svelte | 6 --
.../addressDetails.svelte | 6 --
13 files changed, 111 insertions(+), 57 deletions(-)
create mode 100644 src/lib/layout/headerAlert.svelte
create mode 100644 src/routes/console/organization-[organization]/settings/+page.ts
rename src/routes/console/organization-[organization]/{ => settings}/deleteOrganization.svelte (59%)
diff --git a/src/lib/elements/forms/button.svelte b/src/lib/elements/forms/button.svelte
index af466aa46..48e986b8d 100644
--- a/src/lib/elements/forms/button.svelte
+++ b/src/lib/elements/forms/button.svelte
@@ -15,6 +15,7 @@
export let external = false;
export let href: string = null;
export let fullWidth = false;
+ export let fullWidthMobile = false;
export let ariaLabel: string = null;
export let noMargin = false;
export let event: string = null;
@@ -47,6 +48,7 @@
text && 'is-text',
danger && 'is-danger',
fullWidth && 'is-full-width',
+ fullWidthMobile && 'is-full-width-mobile',
noMargin && 'u-padding-inline-0',
classes
]
diff --git a/src/lib/layout/headerAlert.svelte b/src/lib/layout/headerAlert.svelte
new file mode 100644
index 000000000..df1887aee
--- /dev/null
+++ b/src/lib/layout/headerAlert.svelte
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ {#if title || $$slots.title}
+
+
+ {title}
+
+
+ {/if}
+
+
+
+
+ {#if $$slots.buttons}
+
+
+
+ {/if}
+
+
diff --git a/src/lib/layout/index.ts b/src/lib/layout/index.ts
index 9537e351b..7b1c1ddc0 100644
--- a/src/lib/layout/index.ts
+++ b/src/lib/layout/index.ts
@@ -17,3 +17,4 @@ export { default as Activity } from './activity.svelte';
export { default as Progress } from './progress.svelte';
export { default as GridHeader } from './gridHeader.svelte';
export { default as ContainerHeader } from './containerHeader.svelte';
+export { default as HeaderAlert } from './headerAlert.svelte';
diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte
index ee09e81f6..a01736043 100644
--- a/src/routes/console/+layout.svelte
+++ b/src/routes/console/+layout.svelte
@@ -1,7 +1,7 @@
@@ -40,13 +43,25 @@
title="Delete organization"
onSubmit={deleteOrg}
bind:show={showDelete}
+ bind:error
icon="exclamation"
state="warning"
headerDivider={false}>
-
- Are you sure you want to delete {$organization.name} ? All projects ({$organization.total})
- and data associated with this organization will be deleted. This action is irreversible.
-
+ {#if TEMPORARY_SET_FOR_DELETION}
+
+ The organization {$organization.name} will be flagged for deletion.
+
+
+
+ All existing projects will be paused and the organization will be deleted once your
+ upcoming invoice is processed on {toLocaleDate($organization.billingNextInvoiceDate)}.
+
+ {:else}
+
+ Are you sure you want to delete {$organization.name} ? All projects ({$projects.total})
+ and data associated with this organization will be deleted. This action is irreversible.
+
+ {/if}
(showDelete = false)}>Cancel
Delete
diff --git a/src/routes/console/organization-[organization]/store.ts b/src/routes/console/organization-[organization]/store.ts
index c753c34de..07b0ca110 100644
--- a/src/routes/console/organization-[organization]/store.ts
+++ b/src/routes/console/organization-[organization]/store.ts
@@ -1,3 +1,6 @@
-import { writable } from 'svelte/store';
+import { page } from '$app/stores';
+import type { Models } from '@appwrite.io/console';
+import { derived, writable } from 'svelte/store';
export const showExcess = writable(false);
+export const projects = derived(page, ($page) => $page.data?.projects as Models.ProjectList);
diff --git a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte
index cd22c6f43..c502e545d 100644
--- a/src/routes/console/wizard/cloudOrganization/addressDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganization/addressDetails.svelte
@@ -3,7 +3,6 @@
import { WizardStep } from '$lib/layout';
import { onMount } from 'svelte';
import { sdk } from '$lib/stores/sdk';
- import { Alert } from '$lib/components';
import { createOrganization } from './store';
import type { AddressesList } from '$lib/sdk/billing';
@@ -32,11 +31,6 @@
Billing address
Add a billing address for your organization.
-
- Depending on your location, your billing address might need to be in the same country
- associated with the payment method for your organization.
-
-
Billing address
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte
index f4d581dbc..2efc06f8f 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/addressDetails.svelte
@@ -3,7 +3,6 @@
import { WizardStep } from '$lib/layout';
import { onMount } from 'svelte';
import { sdk } from '$lib/stores/sdk';
- import { Alert } from '$lib/components';
import { changeOrganizationTier } from './store';
import { organization } from '$lib/stores/organization';
import type { AddressesList } from '$lib/sdk/billing';
@@ -35,11 +34,6 @@
Billing address
Add a billing address for your organization.
-
- Depending on your location, your billing address might need to be in the same country
- associated with the payment method for your organization.
-
-
Billing address