Skip to content

Commit 71cad9b

Browse files
committed
fix: plan getter.
1 parent 3ce9054 commit 71cad9b

File tree

1 file changed

+11
-9
lines changed
  • src/routes/(console)/project-[region]-[project]

1 file changed

+11
-9
lines changed

src/routes/(console)/project-[region]-[project]/+layout.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,29 @@ export const load: LayoutLoad = async ({ params, depends, parent }) => {
2323
(org) => org.$id === project.teamId
2424
);
2525

26-
const includedInBasePlans = plansInfo.has(organization.billingPlan);
26+
// organization can be null if not in the filtered list!
27+
const includedInBasePlans = plansInfo.has(organization?.billingPlan);
2728

28-
const [org, regionalConsoleVariables, rolesResult, organizationPlan] = await Promise.all([
29+
const [org, regionalConsoleVariables, rolesResult] = await Promise.all([
2930
!organization
3031
? (sdk.forConsole.teams.get({ teamId: project.teamId }) as Promise<Organization>)
3132
: organization,
3233
sdk.forConsoleIn(project.region).console.variables(),
3334
isCloud ? sdk.forConsole.billing.getRoles(project.teamId) : null,
3435

35-
// fetch if not available in `plansInfo`
36-
includedInBasePlans
37-
? plansInfo.get(organization.billingPlan)
38-
: isCloud
39-
? sdk.forConsole.billing.getOrganizationPlan(organization.$id)
40-
: null,
41-
4236
loadAvailableRegions(project.teamId)
4337
]);
4438

4539
if (!organization) organization = org;
4640

41+
// fetch if not available in `plansInfo`.
42+
// out of promise.all because we filter orgs based on platform now!
43+
const organizationPlan = includedInBasePlans
44+
? plansInfo.get(organization?.billingPlan)
45+
: isCloud
46+
? await sdk.forConsole.billing.getOrganizationPlan(organization?.$id)
47+
: null;
48+
4749
const roles = rolesResult?.roles ?? defaultRoles;
4850
const scopes = rolesResult?.scopes ?? defaultScopes;
4951

0 commit comments

Comments
 (0)