Skip to content

Commit

Permalink
Use verbose door name
Browse files Browse the repository at this point in the history
  • Loading branch information
Isak-Kallini committed Apr 24, 2024
1 parent bb50177 commit 0714bce
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/lib/utils/member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const getCustomAuthorOptions = async (

export type MemberDoorPolicies = Array<{
name: string;
verboseName: string | undefined;
roles: string[];
startDate: Date | null;
endDate: Date | null;
Expand Down Expand Up @@ -132,6 +133,8 @@ export const getCurrentDoorPoliciesForMember = async (
throw error(500, "Could not fetch door access");
});

const doors = await prisma.door.findMany();

const policiesByDoor: MemberDoorPolicies = userDoorPolicies.reduce(
(acc, policy) => {
const role = policy.role ?? "Du";
Expand All @@ -147,6 +150,8 @@ export const getCurrentDoorPoliciesForMember = async (
}
acc.push({
name: policy.doorName,
verboseName: doors.find((door) => door.name == policy.doorName)
?.verboseName,
roles: [role],
startDate: policy.startDatetime,
endDate: policy.endDatetime,
Expand Down
2 changes: 0 additions & 2 deletions src/routes/(app)/members/[studentId]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export const load: PageServerLoad = async ({ locals, params }) => {
? await getCurrentDoorPoliciesForMember(prisma, studentId)
: [];

console.log(await getCurrentDoorPoliciesForMember(prisma, studentId));

const email =
member.studentId !== null
? await keycloak.getEmail(member.studentId)
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(app)/members/[studentId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
</div>
</div>
<div
class="col-span-5 sm:col-span-3 sm:col-start-3 md:col-start-1 lg:col-span-2 lg:col-start-1 xl:col-span-1 xl:col-start-1"
class="col-span-5 sm:col-span-3 sm:col-start-3 md:col-start-1 lg:col-span-2 lg:col-start-1 xl:col-span-2 xl:col-start-1"
>
{#if data.doorAccess.length > 0}
<DoorAccess doorAccess={data.doorAccess} />
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(app)/members/[studentId]/DoorAccess.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class="my-2 flex items-center justify-between gap-4 rounded-lg bg-base-200 p-3"
>
<div class="flex flex-col">
<span class="font-semibold">{doorPolicy.name}</span>
<span class="font-semibold">{doorPolicy.verboseName}</span>
{#if doorPolicy.startDate != null || doorPolicy.endDate != null}
<span class="text-nowrap text-[0.5rem] font-semibold opacity-50">
{doorPolicy.startDate?.toLocaleDateString("sv-SE") ?? ""}
Expand Down

0 comments on commit 0714bce

Please sign in to comment.