mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Move free org check to server-side load function
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
import { type Coupon, type PaymentList } from '$lib/sdk/billing';
|
||||
import { plansInfo, tierToPlan } from '$lib/stores/billing';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { organization, organizationList, type Organization } from '$lib/stores/organization';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { VARS } from '$lib/system';
|
||||
@@ -30,16 +30,8 @@
|
||||
|
||||
let selectedPlan: BillingPlan = data.plan as BillingPlan;
|
||||
let selectedCoupon: Partial<Coupon> | null = data.coupon;
|
||||
|
||||
$: anyOrgFree = $organizationList.teams?.find(
|
||||
(org) => (org as Organization)?.billingPlan === BillingPlan.FREE
|
||||
);
|
||||
let previousPage: string = base;
|
||||
let showExitModal = false;
|
||||
afterNavigate(({ from }) => {
|
||||
previousPage = from?.url?.pathname || previousPage;
|
||||
});
|
||||
|
||||
let formComponent: Form;
|
||||
let isSubmitting = writable(false);
|
||||
let methods: PaymentList;
|
||||
@@ -53,10 +45,13 @@
|
||||
let taxId: string;
|
||||
let billingBudget: number;
|
||||
let showCreditModal = false;
|
||||
|
||||
let feedbackDowngradeReason: string;
|
||||
let feedbackMessage: string;
|
||||
|
||||
afterNavigate(({ from }) => {
|
||||
previousPage = from?.url?.pathname || previousPage;
|
||||
});
|
||||
|
||||
async function loadPaymentMethods() {
|
||||
methods = await sdk.forConsole.billing.listPaymentMethods();
|
||||
|
||||
@@ -224,7 +219,7 @@
|
||||
<PlanSelection
|
||||
bind:billingPlan={selectedPlan}
|
||||
selfService={data.selfService}
|
||||
anyOrgFree={!!anyOrgFree} />
|
||||
anyOrgFree={data.hasFreeOrgs} />
|
||||
|
||||
{#if isDowngrade}
|
||||
{#if selectedPlan === BillingPlan.FREE}
|
||||
|
||||
@@ -2,9 +2,10 @@ import { BillingPlan, Dependencies } from '$lib/constants';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { PageLoad } from './$types';
|
||||
import type { Coupon } from '$lib/sdk/billing';
|
||||
import type { Organization } from '$lib/stores/organization';
|
||||
|
||||
export const load: PageLoad = async ({ depends, parent, url }) => {
|
||||
const { members, organization, currentPlan } = await parent();
|
||||
const { members, organization, currentPlan, organizations } = await parent();
|
||||
depends(Dependencies.ORGANIZATION);
|
||||
|
||||
const coupon = await getCoupon(url);
|
||||
@@ -18,11 +19,16 @@ export const load: PageLoad = async ({ depends, parent, url }) => {
|
||||
|
||||
const selfService = currentPlan?.selfService ?? true;
|
||||
|
||||
const hasFreeOrgs = organizations.teams?.some(
|
||||
(org) => (org as Organization)?.billingPlan === BillingPlan.FREE
|
||||
);
|
||||
|
||||
return {
|
||||
members,
|
||||
plan,
|
||||
coupon,
|
||||
selfService
|
||||
selfService,
|
||||
hasFreeOrgs
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user