|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import { useState } from 'react'; |
| 4 | +import Image from 'next/image'; |
| 5 | + |
| 6 | +import { GalleryCarousel } from '~/components/carousels'; |
| 7 | +import { |
| 8 | + Card, |
| 9 | + CardContent, |
| 10 | + Dialog, |
| 11 | + DialogClose, |
| 12 | + DialogContent, |
| 13 | +} from '~/components/ui'; |
| 14 | + |
| 15 | +interface ClubEvent { |
| 16 | + id: number; |
| 17 | + title: string; |
| 18 | + date: string; |
| 19 | + image: [string]; |
| 20 | + description: string; |
| 21 | +} |
| 22 | + |
| 23 | +export default function EventsSection({ |
| 24 | + events, |
| 25 | + locale, |
| 26 | + display_name, |
| 27 | + s3BaseUrl, |
| 28 | +}: { |
| 29 | + events: ClubEvent[]; |
| 30 | + locale: string; |
| 31 | + display_name: string; |
| 32 | + s3BaseUrl: string; |
| 33 | +}) { |
| 34 | + const [selectedEvent, setSelectedEvent] = useState<ClubEvent | null>(null); |
| 35 | + |
| 36 | + return ( |
| 37 | + <> |
| 38 | + <ul className="w-fulls grid grid-cols-1 gap-7 md:grid-cols-2 lg:grid-cols-3"> |
| 39 | + {events.map((event, i) => ( |
| 40 | + <li key={i} className="w-auto"> |
| 41 | + <div |
| 42 | + onClick={() => setSelectedEvent(event)} |
| 43 | + className="cursor-pointer" |
| 44 | + > |
| 45 | + <Card className="flex h-64 w-full flex-col justify-between border-none"> |
| 46 | + <CardContent |
| 47 | + className="relative flex h-full w-full justify-center rounded-lg bg-neutral-700 bg-cover bg-center p-4 bg-blend-overlay" |
| 48 | + style={{ |
| 49 | + backgroundImage: `url(${s3BaseUrl}/${event.image[0]})`, |
| 50 | + }} |
| 51 | + > |
| 52 | + <h1 className="my-auto text-4xl font-bold text-background"> |
| 53 | + {event.title} |
| 54 | + </h1> |
| 55 | + </CardContent> |
| 56 | + </Card> |
| 57 | + </div> |
| 58 | + </li> |
| 59 | + ))} |
| 60 | + </ul> |
| 61 | + |
| 62 | + <Dialog |
| 63 | + open={!!selectedEvent} |
| 64 | + onOpenChange={(open) => !open && setSelectedEvent(null)} |
| 65 | + > |
| 66 | + <DialogContent |
| 67 | + className="F z-[100] mx-4 mx-auto flex max-w-[90vw] flex-col items-center rounded-xl border border-primary-500 |
| 68 | + bg-background p-8 shadow-xl md:max-w-[80vw] |
| 69 | + lg:max-w-[1100px]" |
| 70 | + > |
| 71 | + {selectedEvent && ( |
| 72 | + <> |
| 73 | + <h2 className="text-primary-800 mb-4 self-center text-3xl font-bold"> |
| 74 | + {selectedEvent.title} |
| 75 | + </h2> |
| 76 | + |
| 77 | + <GalleryCarousel |
| 78 | + className="mb-6 w-full overflow-hidden rounded-lg" |
| 79 | + itemClassName="" |
| 80 | + > |
| 81 | + {selectedEvent.image.map((img, index) => ( |
| 82 | + <Image |
| 83 | + alt={`Image ${index + 1} of ${selectedEvent.title}`} |
| 84 | + height={400} |
| 85 | + key={index} |
| 86 | + src={`${s3BaseUrl}/${img}`} |
| 87 | + width={1000} |
| 88 | + className="h-40 w-full rounded-lg object-cover sm:h-60 md:h-80 lg:h-[400px]" |
| 89 | + /> |
| 90 | + ))} |
| 91 | + </GalleryCarousel> |
| 92 | + |
| 93 | + <p className="text-gray-700 text-base leading-relaxed"> |
| 94 | + {selectedEvent.description} |
| 95 | + </p> |
| 96 | + |
| 97 | + </> |
| 98 | + )} |
| 99 | + </DialogContent> |
| 100 | + </Dialog> |
| 101 | + </> |
| 102 | + ); |
| 103 | +} |
0 commit comments