Skip to content

Commit 1139ca4

Browse files
committed
Display waitlist position (#2268)
1 parent bdc3d83 commit 1139ca4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

apps/web/src/components/happening-sidebar.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ export const HappeningSidebar = async ({ event }: EventSidebarProps) => {
109109
(registration) => registration.userId === user?.id,
110110
)?.status;
111111

112+
const userWaitlistPosition =
113+
registrations
114+
.filter((registration) => {
115+
return registration.status === "waiting";
116+
})
117+
.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime())
118+
.findIndex((registration) => registration.userId === user?.id) + 1;
119+
112120
return (
113121
<div className="flex w-full flex-col gap-4 lg:max-w-[320px]">
114122
{/**
@@ -372,6 +380,17 @@ export const HappeningSidebar = async ({ event }: EventSidebarProps) => {
372380
</SidebarItem>
373381
)}
374382

383+
{/**
384+
* Show waitlist position if:
385+
* - User is on waitlist
386+
*/}
387+
{currentUserStatus === "waiting" && userWaitlistPosition > 0 && (
388+
<SidebarItem>
389+
<SidebarItemTitle>Plass på venteliste:</SidebarItemTitle>
390+
<SidebarItemContent>{userWaitlistPosition}</SidebarItemContent>
391+
</SidebarItem>
392+
)}
393+
375394
{/**
376395
* Show registration end date if:
377396
* - Registration is open

0 commit comments

Comments
 (0)