From 269bf9f01e2ff0fa4d5ec51e8dfe4ca6d989c158 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 29 Jan 2025 04:05:33 +0000 Subject: [PATCH] fix formatting --- .../billing/discountsApplied.svelte | 2 +- .../components/billing/estimatedTotal.svelte | 24 +++++- src/lib/components/billing/index.ts | 2 +- src/lib/components/billing/selectPlan.svelte | 2 +- src/lib/sdk/billing.ts | 75 +++++++------------ src/lib/stores/billing.ts | 5 +- .../create-organization/+page.svelte | 2 - .../billing/+page.ts | 49 ++++++------ .../billing/planSummary.svelte | 15 ++-- 9 files changed, 89 insertions(+), 87 deletions(-) diff --git a/src/lib/components/billing/discountsApplied.svelte b/src/lib/components/billing/discountsApplied.svelte index 82ae0907e..433d02ecf 100644 --- a/src/lib/components/billing/discountsApplied.svelte +++ b/src/lib/components/billing/discountsApplied.svelte @@ -1,6 +1,6 @@ {#if estimation || error.length} diff --git a/src/lib/components/billing/index.ts b/src/lib/components/billing/index.ts index f58efa250..1cc70d3d9 100644 --- a/src/lib/components/billing/index.ts +++ b/src/lib/components/billing/index.ts @@ -7,4 +7,4 @@ export { default as EmptyCardCloud } from './emptyCardCloud.svelte'; export { default as CreditsApplied } from './creditsApplied.svelte'; export { default as PlanSelection } from './planSelection.svelte'; export { default as EstimatedTotal } from './estimatedTotal.svelte'; -export { default as SelectPlan } from './selectPlan.svelte'; \ No newline at end of file +export { default as SelectPlan } from './selectPlan.svelte'; diff --git a/src/lib/components/billing/selectPlan.svelte b/src/lib/components/billing/selectPlan.svelte index 4447c17e3..8aae2f0ac 100644 --- a/src/lib/components/billing/selectPlan.svelte +++ b/src/lib/components/billing/selectPlan.svelte @@ -19,7 +19,7 @@ = [], + invites: Array = [] ): Promise { const path = `/organizations/estimations/create-organization`; const params = { billingPlan, couponId, - invites, + invites }; const uri = new URL(this.client.config.endpoint + path); return await this.client.call( @@ -466,40 +465,30 @@ export class Billing { ); } - async estimationDeleteOrganization(organizationId: string): Promise { + async estimationDeleteOrganization( + organizationId: string + ): Promise { const path = `/organizations/${organizationId}/estimations/delete-organization`; const uri = new URL(this.client.config.endpoint + path); - return await this.client.call( - 'patch', - uri, - { - 'content-type': 'application/json' - } - ); + return await this.client.call('patch', uri, { + 'content-type': 'application/json' + }); } async getOrganizationPlan(organizationId: string): Promise { const path = `/organizations/${organizationId}/plan`; const uri = new URL(this.client.config.endpoint + path); - return await this.client.call( - 'get', - uri, - { - 'content-type': 'application/json' - } - ); + return await this.client.call('get', uri, { + 'content-type': 'application/json' + }); } async getPlan(planId: string): Promise { const path = `/console/plans/${planId}`; const uri = new URL(this.client.config.endpoint + path); - return await this.client.call( - 'get', - uri, - { - 'content-type': 'application/json' - } - ); + return await this.client.call('get', uri, { + 'content-type': 'application/json' + }); } async getRoles(organizationId: string): Promise { @@ -546,13 +535,13 @@ export class Billing { organizationId: string, billingPlan: string, couponId: string = null, - invites: Array = [], + invites: Array = [] ): Promise { const path = `/organizations/${organizationId}/estimations/update-plan`; const params = { billingPlan, couponId, - invites, + invites }; const uri = new URL(this.client.config.endpoint + path); return await this.client.call( @@ -565,18 +554,12 @@ export class Billing { ); } - async cancelDowngrade( - organizationId: string - ): Promise { + async cancelDowngrade(organizationId: string): Promise { const path = `/organizations/${organizationId}/plan/cancel`; const uri = new URL(this.client.config.endpoint + path); - return await this.client.call( - 'patch', - uri, - { - 'content-type': 'application/json' - } - ); + return await this.client.call('patch', uri, { + 'content-type': 'application/json' + }); } async updateBudget( diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 341e302bb..d4affddb6 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -275,7 +275,8 @@ export async function checkForUsageLimit(org: Organization) { const members = org.total; const plan = get(plansInfo)?.get(org.billingPlan); - const membersOverflow = (members - 1) > plan.addons.seats.limit ? members - (plan.addons.seats.limit || members) : 0; + const membersOverflow = + members - 1 > plan.addons.seats.limit ? members - (plan.addons.seats.limit || members) : 0; if (resources.some((r) => r.value >= 100) || membersOverflow > 0) { readOnly.set(true); @@ -490,4 +491,4 @@ export function calculateResourceSurplus(total: number, limit: number, limitUnit export function isOrganization(org: Organization | OrganizationError): org is Organization { return (org as Organization).$id !== undefined; -} \ No newline at end of file +} diff --git a/src/routes/(console)/create-organization/+page.svelte b/src/routes/(console)/create-organization/+page.svelte index d3de145b8..9137dc128 100644 --- a/src/routes/(console)/create-organization/+page.svelte +++ b/src/routes/(console)/create-organization/+page.svelte @@ -47,7 +47,6 @@ let billingPlan: BillingPlan = BillingPlan.FREE; let paymentMethodId: string; let collaborators: string[] = []; - let couponId: string | undefined; let couponData: Partial = { code: null, status: null, @@ -240,7 +239,6 @@ {billingBudget} {billingPlan} {collaborators} - {couponId} {couponData} /> {:else} diff --git a/src/routes/(console)/organization-[organization]/billing/+page.ts b/src/routes/(console)/organization-[organization]/billing/+page.ts index 2bf2039c7..b72e98ea0 100644 --- a/src/routes/(console)/organization-[organization]/billing/+page.ts +++ b/src/routes/(console)/organization-[organization]/billing/+page.ts @@ -20,42 +20,43 @@ export const load: PageLoad = async ({ parent, depends }) => { const billingAddressId = (organization as Organization)?.billingAddressId; const billingAddressPromise: Promise
= billingAddressId ? sdk.forConsole.billing - .getOrganizationBillingAddress(organization.$id, billingAddressId) - .catch(() => null) + .getOrganizationBillingAddress(organization.$id, billingAddressId) + .catch(() => null) : null; /** - * Needed to keep this out of Promise.all, as when organization is + * Needed to keep this out of Promise.all, as when organization is * initially created, these might return 404 * - can be removed later once that is fixed in back-end */ let billingAggregation = null; try { - billingAggregation = await sdk.forConsole.billing.getAggregation(organization.$id, (organization as Organization)?.billingAggregationId); - } catch (e) { - // ignore error - } - - let billingInvoice = null; - try { - billingInvoice = await sdk.forConsole.billing.getInvoice(organization.$id, (organization as Organization)?.billingInvoiceId); + billingAggregation = await sdk.forConsole.billing.getAggregation( + organization.$id, + (organization as Organization)?.billingAggregationId + ); } catch (e) { // ignore error } - const [ - paymentMethods, - addressList, - billingAddress, - creditList, - aggregationBillingPlan, - ] = await Promise.all([ - sdk.forConsole.billing.listPaymentMethods(), - sdk.forConsole.billing.listAddresses(), - billingAddressPromise, - sdk.forConsole.billing.listCredits(organization.$id), - sdk.forConsole.billing.getPlan(billingAggregation?.plan ?? organization.billingPlan), - ]); + let billingInvoice = null; + try { + billingInvoice = await sdk.forConsole.billing.getInvoice( + organization.$id, + (organization as Organization)?.billingInvoiceId + ); + } catch (e) { + // ignore error + } + + const [paymentMethods, addressList, billingAddress, creditList, aggregationBillingPlan] = + await Promise.all([ + sdk.forConsole.billing.listPaymentMethods(), + sdk.forConsole.billing.listAddresses(), + billingAddressPromise, + sdk.forConsole.billing.listCredits(organization.$id), + sdk.forConsole.billing.getPlan(billingAggregation?.plan ?? organization.billingPlan) + ]); return { paymentMethods, diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte index f88992b86..8cfaeee8c 100644 --- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte @@ -18,7 +18,7 @@ export let currentPlan: Plan; export let creditList: CreditList; export let currentInvoice: Invoice | undefined = undefined; - export let currentAggregation: Aggregation | undefined = undefined + export let currentAggregation: Aggregation | undefined = undefined; let showCancel: boolean = false; @@ -46,8 +46,7 @@
- - {tierToPlan($organization?.billingPlan)?.name} plan + {currentPlan.name} plan
{isTrial || $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION @@ -63,7 +62,9 @@ Add-ons{currentAggregation.additionalMembers > 0 ? currentInvoice.usage.length + 1 : currentInvoice.usage.length} + >{currentAggregation.additionalMembers > 0 + ? currentInvoice.usage.length + 1 + : currentInvoice.usage.length}
@@ -100,10 +101,12 @@ {#if currentInvoice?.usage} {#each currentInvoice.usage as excess, i}
  • + 0 ? 'u-padding-block-8' : 'u-padding-block-start-8'}" - class:u-sep-block-start={i > 0 || currentAggregation.additionalMembers > 0}> + class:u-sep-block-start={i > 0 || + currentAggregation.additionalMembers > 0}> {#if ['storage', 'bandwidth'].includes(excess.name)} {@const excessValue = humanFileSize( excess.value