mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: add list orgs endpoint
This commit is contained in:
+17
-1
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user