mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #825 from appwrite/fix-add-list-orgs-endpoint
fix: add list orgs endpoint
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
import { page } from '$app/stores';
|
||||
import { BillingPlan } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { HeaderAlert } from '$lib/layout';
|
||||
import { orgMissingPaymentMethod } from '$routes/console/store';
|
||||
</script>
|
||||
@@ -12,9 +11,8 @@
|
||||
type="error"
|
||||
title={`Payment method required for ${$orgMissingPaymentMethod.name}`}>
|
||||
<svelte:fragment>
|
||||
Add a payment method to {$orgMissingPaymentMethod.name} before {toLocaleDate(
|
||||
$orgMissingPaymentMethod.billingCurrentInvoiceDate
|
||||
)} to avoid service interruptions to your projects.
|
||||
Add a payment method to {$orgMissingPaymentMethod.name} to avoid service interruptions to
|
||||
your projects.
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="buttons">
|
||||
<Button
|
||||
|
||||
+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.teams[0]);
|
||||
headerAlert.add({
|
||||
id: 'missingPaymentMethod',
|
||||
component: MissingPaymentMethod,
|
||||
|
||||
@@ -22,6 +22,11 @@ export type Organization = Models.Team<Record<string, unknown>> & {
|
||||
billingPlanDowngrade?: string;
|
||||
};
|
||||
|
||||
export type OrganizationList = {
|
||||
teams: Organization[];
|
||||
total: number;
|
||||
};
|
||||
|
||||
export type BillingLimits = {
|
||||
bandwidth: number;
|
||||
documents: number;
|
||||
|
||||
Reference in New Issue
Block a user