File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments