Skip to content

Commit

Permalink
Fix invalid truth chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Macludde authored and Isak-Kallini committed Apr 16, 2024
1 parent 57b62d6 commit cb2ff22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/lib/utils/member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ export const getCurrentDoorPoliciesForMember = async (
positionsMappedToThisDoor.sort();
return {
...policy,
roles: positionsMappedToThisDoor || ["Du"],
roles:
positionsMappedToThisDoor.length > 0
? positionsMappedToThisDoor
: ["Du"],
};
},
);
Expand Down
5 changes: 2 additions & 3 deletions src/routes/(app)/members/[studentId]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ export const load: PageServerLoad = async ({ locals, params }) => {
const doorAccess =
member.id === user?.memberId
? await getCurrentDoorPoliciesForMember(prisma, studentId)
: (new Map() as unknown as Awaited<
ReturnType<typeof getCurrentDoorPoliciesForMember>
>);
: [];

console.log(await getCurrentDoorPoliciesForMember(prisma, studentId));
try {
return {
form: await superValidate(member, memberSchema),
Expand Down

0 comments on commit cb2ff22

Please sign in to comment.