This commit is contained in:
Damodar Lohani
2024-09-18 15:37:25 +05:45
parent a5532d84ba
commit a1fe4bdec4
2 changed files with 7 additions and 9 deletions
@@ -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) {
@@ -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 {