From a1fe4bdec41cc1dc97f22f4b7e1444df4604af01 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 18 Sep 2024 15:37:25 +0545 Subject: [PATCH] fixes --- .../(console)/organization-[organization]/+layout.ts | 10 ++++------ src/routes/(console)/project-[project]/+layout.ts | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/routes/(console)/organization-[organization]/+layout.ts b/src/routes/(console)/organization-[organization]/+layout.ts index a640a8d71..4e19f84eb 100644 --- a/src/routes/(console)/organization-[organization]/+layout.ts +++ b/src/routes/(console)/organization-[organization]/+layout.ts @@ -11,7 +11,6 @@ import ProjectsAtRisk from '$lib/components/billing/alerts/projectsAtRisk.svelte import { get } from 'svelte/store'; import { preferences } from '$lib/stores/preferences'; import type { Organization } from '$lib/stores/organization'; -import { canSeeBilling } from '$lib/stores/roles'; export const load: LayoutLoad = async ({ params, depends }) => { depends(Dependencies.ORGANIZATION); @@ -22,7 +21,10 @@ export const load: LayoutLoad = async ({ params, depends }) => { try { if (isCloud) { - if (get(canSeeBilling)) { + const res = await sdk.forConsole.billing.getRoles(params.organization); + roles = res.roles; + scopes = res.scopes; + if (scopes.includes('billing.read')) { await failedInvoice.load(params.organization); if (get(failedInvoice)) { headerAlert.add({ @@ -33,10 +35,6 @@ export const load: LayoutLoad = async ({ params, depends }) => { }); } } - - const res = await sdk.forConsole.billing.getRoles(params.organization); - roles = res.roles; - scopes = res.scopes; } const prefs = await sdk.forConsole.account.getPrefs(); if (prefs.organization !== params.organization) { diff --git a/src/routes/(console)/project-[project]/+layout.ts b/src/routes/(console)/project-[project]/+layout.ts index 41d5198e0..09578e15f 100644 --- a/src/routes/(console)/project-[project]/+layout.ts +++ b/src/routes/(console)/project-[project]/+layout.ts @@ -21,12 +21,12 @@ export const load: LayoutLoad = async ({ params, depends }) => { let roles = []; let scopes = []; if (isCloud) { - if (get(canSeeBilling)) { - await failedInvoice.load(project.teamId); - } const res = await sdk.forConsole.billing.getRoles(project.teamId); roles = res.roles; scopes = res.scopes; + if (scopes.includes('billing.read')) { + await failedInvoice.load(project.teamId); + } } return {