Skip to content

Commit

Permalink
Fixes undefined access on missing user
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Nov 27, 2023
1 parent 087832d commit 4ad8de1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/addons/dispatch/Premium.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
export let addon: AddOnListItem;
export let user: User;
export let user: User | null;
let spendingLimitEnabled = false;
let spendingLimit = 0;
$: creditBalance = getCreditBalance(user.organization);
$: creditBalance = user?.organization
? getCreditBalance(user.organization)
: 0;
$: isIndividualOrg =
typeof user.organization !== "string" && user.organization.individual;
typeof user?.organization !== "string" && user?.organization?.individual;
$: isPremium = addon?.parameters?.categories?.includes("premium") ?? false;
const { amount, unit } = addon?.parameters?.cost ?? {};
$: prettyCost = amount && unit ? handlePlural(amount, unit) : null;
Expand Down Expand Up @@ -144,7 +146,7 @@
</style>

{#if isPremium}
{#if isPremiumOrg(user.organization)}
{#if isPremiumOrg(user?.organization)}
<fieldset class="premium">
<legend>{$_("addonDispatchDialog.premium")}</legend>
<div class="row">
Expand Down Expand Up @@ -206,7 +208,7 @@
},
})}
callToAction={$_("addonDispatchDialog.premiumUpgrade.callToAction")}
on:click={() => triggerPremiumUpgradeFlow(user.organization)}
on:click={() => triggerPremiumUpgradeFlow(user?.organization)}
/>
{:else}
<UpgradePrompt
Expand Down
1 change: 1 addition & 0 deletions src/manager/orgsAndUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export async function inMyOrg(orgId, myId) {
}

export function isOrgAdmin(user) {
if (!user) return false;
const id =
typeof user.organization === "string"
? user.organization
Expand Down

0 comments on commit 4ad8de1

Please sign in to comment.