diff --git a/src/app/events/components/eventCard.jsx b/src/app/events/components/eventCard.jsx new file mode 100644 index 0000000..3db7a45 --- /dev/null +++ b/src/app/events/components/eventCard.jsx @@ -0,0 +1,70 @@ +import React, { useState } from "react"; + +import { getPublicUrl } from "@/lib/utils"; +import Link from "next/link"; + +import { Montserrat, Alata } from "next/font/google"; +const montserratFont = Montserrat({ + weight: ["100", "200", "400", "600"], + subsets: ["latin"], +}); +const boldMontserratFont = Montserrat({ + weight: ["600"], + subsets: ["latin"], +}); + +export default function EventCard(props) { + const [event, setEvent] = useState(props.event); + const [eventDate, setEventDate] = useState(event.date); + const [eventTime, setEventTime] = useState(event.time); + let posterUrl = getPublicUrl(`/events/${event.id}/poster`); + return ( +
+ +
+
+ +
+
+

{formatDate(eventDate)} | {formatTime(eventTime)}

+

{event.name}

+

{trimString(event.description,50)}

+
+
+ +
+ ); +} +function formatDate(dateString) { + const [year, month, day] = dateString.split("-"); + const date = new Date(year, month - 1, day); // Month is 0-indexed + + const formattedDay = date.getDate(); + const monthName = date.toLocaleString("default", { month: "long" }); + const formattedYear = date.getFullYear(); + + return `${formattedDay} ${monthName} ${formattedYear}`; + } + + + const formatTime = (timeString) => { + const timeRegex = /^(\d{2}):(\d{2}):(\d{2})$/; + const match = timeString.match(timeRegex); + if (!match) { + return 'Invalid Time Format'; + } + let hours = parseInt(match[1], 10); + const minutes = parseInt(match[2], 10); + const ampm = hours >= 12 ? 'PM' : 'AM'; + hours = hours % 12; + hours = hours ? hours : 12; + const formattedMinutes = String(minutes).padStart(2, '0'); + return `${hours}:${formattedMinutes} ${ampm}`; +}; + +const trimString = (str, maxLength) => { + if (str.length > maxLength) { + return str.substring(0, maxLength) + '...'; + } + return str; +}; \ No newline at end of file diff --git a/src/app/events/layout.tsx b/src/app/events/layout.tsx new file mode 100644 index 0000000..34d3e5f --- /dev/null +++ b/src/app/events/layout.tsx @@ -0,0 +1,17 @@ +import React from "react"; +import Navbar from "@/components/navbar"; +import Footer from "@/components/footer"; + +interface RootLayoutProps { + children: React.ReactNode; +} + +export default function RootLayout({ children }: RootLayoutProps) { + return ( + <> + + {children} +