fix: add list orgs endpoint

This commit is contained in:
Arman
2024-02-16 09:44:13 +01:00
parent 7757d8dbb8
commit 5a6dce9351
3 changed files with 24 additions and 3 deletions
+17 -1
View File
@@ -1,5 +1,5 @@
import type { Client, Models, Query } from '@appwrite.io/console';
import type { Organization } from '../stores/organization';
import type { Organization, OrganizationList } from '../stores/organization';
import type { PaymentMethod } from '@stripe/stripe-js';
import type { Tier } from '$lib/stores/billing';
@@ -274,6 +274,22 @@ export class Billing {
this.client = client;
}
async listOrganization(queries: Query[] = []): Promise<OrganizationList> {
const path = `/organizations`;
const params = {
queries
};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call(
'GET',
uri,
{
'content-type': 'application/json'
},
params
);
}
async createOrganization(
organizationId: string,
name: string,
+2 -2
View File
@@ -268,13 +268,13 @@ export function checkForMarkedForDeletion(org: Organization) {
}
export async function checkForMissingPaymentMethod() {
const orgs = await sdk.forConsole.teams.list([
const orgs = await sdk.forConsole.billing.listOrganization([
Query.notEqual('billingPlan', BillingPlan.STARTER),
Query.isNull('paymentMethodId'),
Query.isNull('backupPaymentMethodId')
]);
if (orgs?.total) {
orgMissingPaymentMethod.set(orgs.teams[0] as Organization);
orgMissingPaymentMethod.set(orgs.organizations[0]);
headerAlert.add({
id: 'missingPaymentMethod',
component: MissingPaymentMethod,
+5
View File
@@ -22,6 +22,11 @@ export type Organization = Models.Team<Record<string, unknown>> & {
billingPlanDowngrade?: string;
};
export type OrganizationList = {
organizations: Organization[];
total: number;
};
export type BillingLimits = {
bandwidth: number;
documents: number;