mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: more create org workflow
This commit is contained in:
1 parent
283d6f5617
commit
ba691c5ab4
2 files changed
+39
-19
No files matched your search
@@ -1,7 +1,21 @@
|
||||
import type { Client } from '@appwrite.io/console';
|
||||
import type { PaymentMethod } from '@stripe/stripe-js';
|
||||
import type { Organization } from './organization';
|
||||
|
||||
export type PaymentMethod = {
|
||||
$id: string;
|
||||
providerMethodId: string;
|
||||
expiryMonth: number;
|
||||
expiryYear: number;
|
||||
last4: string;
|
||||
country: string;
|
||||
brand: string;
|
||||
};
|
||||
|
||||
export type PaymentList = {
|
||||
paymentMethods: PaymentMethod[];
|
||||
total: number;
|
||||
};
|
||||
|
||||
export class Billing {
|
||||
client: Client;
|
||||
|
||||
@@ -198,7 +212,7 @@ export class Billing {
|
||||
|
||||
//ACCOUNT
|
||||
|
||||
async listPaymentMethods(queries: [] = []): Promise<PaymentMethod> {
|
||||
async listPaymentMethods(queries: [] = []): Promise<PaymentList> {
|
||||
const path = `/account/payment-methods`;
|
||||
const params = {
|
||||
queries
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
import { createOrganization } from './store';
|
||||
import { Collapsible, CollapsibleItem } from '$lib/components';
|
||||
import UsageRates from './usageRates.svelte';
|
||||
import type { PaymentList } from '$lib/stores/billing';
|
||||
import { paymentMethods } from '../account/payments/store';
|
||||
|
||||
let methods = [];
|
||||
let methods: PaymentList;
|
||||
let name: string;
|
||||
let promo: string;
|
||||
let redeemedCodes = [];
|
||||
@@ -24,7 +26,7 @@
|
||||
|
||||
onMount(async () => {
|
||||
methods = await sdk.forConsole.billing.listPaymentMethods();
|
||||
if (methods.length) {
|
||||
if (methods?.total) {
|
||||
$createOrganization.paymentMethodId = methods[0].id;
|
||||
}
|
||||
});
|
||||
@@ -45,25 +47,29 @@
|
||||
<svelte:fragment slot="subtitle">Add a payment method to your organization.</svelte:fragment>
|
||||
|
||||
<FormList>
|
||||
<div class:boxes-wrapper={methods?.length}>
|
||||
{#if methods.length}
|
||||
{#each methods as method}
|
||||
<InputRadio
|
||||
id="payment-method"
|
||||
label="Payment method"
|
||||
value={method.id}
|
||||
name={method.id}
|
||||
group="payment" />
|
||||
<div class:boxes-wrapper={methods?.total}>
|
||||
{#if methods?.total}
|
||||
{#each methods.paymentMethods as method}
|
||||
<div class="box">
|
||||
<InputRadio
|
||||
id={`payment-method-${method.last4}`}
|
||||
label={`${method.brand} ending in ${method.last4}`}
|
||||
value={method.$id}
|
||||
name="payment"
|
||||
group={$createOrganization.paymentMethodId} />
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<div class="box">
|
||||
<InputRadio
|
||||
id="payment-method"
|
||||
label="Add new payment method"
|
||||
value={null}
|
||||
name="test"
|
||||
group={$createOrganization.paymentMethodId} />
|
||||
{#if methods?.total}
|
||||
<InputRadio
|
||||
id="payment-method"
|
||||
label="Add new payment method"
|
||||
value={null}
|
||||
name="payment"
|
||||
group={$createOrganization.paymentMethodId} />
|
||||
{/if}
|
||||
{#if $createOrganization.paymentMethodId === null}
|
||||
<InputText
|
||||
id="name"
|
||||
|
||||
Reference in new issue
Block a user