1- import Image from "next/image" ;
21import Link from "next/link" ;
32import { useRouter } from "next/router" ;
43import Confetti from "react-confetti" ;
54
6- import { Avatar , AvatarFallback } from "@/components/ui/avatar" ;
75import { Button } from "@/components/ui/button" ;
8- import { Card , CardContent } from "@/components/ui/card " ;
6+ import HubDisplay from "@/components/ui/hub-display " ;
97import { useEvent } from "@/hooks/events" ;
108import ActionLayout from "@/pages/layouts/actionlayout" ;
119
1210export default function ParticipantsPage ( ) {
1311 const router = useRouter ( ) ;
1412 const { id } = router . query ;
1513 const eventId = Number ( id ) ;
14+ const { data : event } = useEvent ( eventId ) ;
1615
17- const { data : event , isLoading } = useEvent ( eventId ) ;
16+ if ( ! event ) {
17+ return < p > Event not found</ p > ;
18+ }
19+
20+ const eventDate = new Date ( event . event_date ) ;
21+ const now = new Date ( ) ;
22+ const hasEnded = eventDate < now ;
1823
1924 return (
2025 < >
@@ -35,50 +40,7 @@ export default function ParticipantsPage() {
3540 </ Link >
3641 }
3742 >
38- < div className = "mx-auto max-w-3xl px-4 sm:px-6 lg:px-0" >
39- < div className = "relative mb-6 h-56 w-full overflow-hidden rounded-xl bg-gray-200" >
40- { event ?. images ?. [ 0 ] ?. image && (
41- < Image
42- src = { event . images [ 0 ] . image }
43- alt = { event . event_name }
44- fill
45- className = "object-cover"
46- />
47- ) }
48- </ div >
49- { ! isLoading &&
50- event ?. participants &&
51- event . participants . length > 0 && (
52- < div className = "grid grid-cols-2 gap-4" >
53- { event . participants . map ( ( p ) => (
54- < Card key = { p . id } >
55- < CardContent className = "flex items-center gap-4 p-4" >
56- < Avatar >
57- < AvatarFallback >
58- { p . username . slice ( 0 , 2 ) . toUpperCase ( ) }
59- </ AvatarFallback >
60- </ Avatar >
61-
62- < div className = "flex-1" >
63- < p className = "font-medium" > { p . username } </ p >
64- < p className = "text-sm text-muted-foreground" >
65- Attending this event
66- </ p >
67- </ div >
68-
69- < Button variant = "default" size = "sm" >
70- meow
71- </ Button >
72- </ CardContent >
73- </ Card >
74- ) ) }
75- </ div >
76- ) }
77- </ div >
78-
79- { ! isLoading && event ?. participants ?. length === 0 && (
80- < p > No participants yet.</ p >
81- ) }
43+ { hasEnded ? < HubDisplay /> : < Button > Event has ended!</ Button > }
8244 </ ActionLayout >
8345 </ >
8446 ) ;
0 commit comments