diff --git a/src/app/events/page.tsx b/src/app/events/page.tsx index afc2f1b..c34b63b 100644 --- a/src/app/events/page.tsx +++ b/src/app/events/page.tsx @@ -1,18 +1,18 @@ -import Calendar from "@/components/events/Calendar"; +// import Calendar from "@/components/events/Calendar"; type Params = { month: string | null; year: string | null; }; export default function Events({ searchParams }: { searchParams: Params }) { - const today = new Date(); - const month = parseInt(searchParams.month || today.getMonth().toString()); - const year = parseInt(searchParams.year || today.getFullYear().toString()); + // const today = new Date(); + // const month = parseInt(searchParams.month || today.getMonth().toString()); + // const year = parseInt(searchParams.year || today.getFullYear().toString()); return (
- + {/* */}
); diff --git a/src/components/events/Calendar.tsx b/src/components/events/Calendar.tsx index f6c99e2..dc7f241 100644 --- a/src/components/events/Calendar.tsx +++ b/src/components/events/Calendar.tsx @@ -1,93 +1,93 @@ -"use client"; +// "use client"; -import Link from "next/link"; -import CalendarBody from "./CalendarBody"; -import { useEffect, useState } from "react"; -import type { Event } from "@/lib/types"; +// import Link from "next/link"; +// import CalendarBody from "./CalendarBody"; +// import { useEffect, useState } from "react"; +// import type { Event } from "@/lib/types"; -type Props = { - month: number; - year: number; -}; +// type Props = { +// month: number; +// year: number; +// }; -const monthNames = [ - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December", -]; +// const monthNames = [ +// "January", "February", "March", "April", "May", "June", +// "July", "August", "September", "October", "November", "December", +// ]; -function changeMonth(amt: "inc" | "dec", { month, year }: { month: number; year: number }) { - if (amt === "inc") { - if (month === 11) return { month: 0, year: year + 1 }; - return { month: month + 1, year }; - } - if (month === 0) return { month: 11, year: year - 1 }; - return { month: month - 1, year }; -} +// function changeMonth(amt: "inc" | "dec", { month, year }: { month: number; year: number }) { +// if (amt === "inc") { +// if (month === 11) return { month: 0, year: year + 1 }; +// return { month: month + 1, year }; +// } +// if (month === 0) return { month: 11, year: year - 1 }; +// return { month: month - 1, year }; +// } -const Calendar = ({ month, year }: Props) => { - const [events, setEvents] = useState([]); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); +// const Calendar = ({ month, year }: Props) => { +// const [events, setEvents] = useState([]); +// const [loading, setLoading] = useState(true); +// const [error, setError] = useState(null); - useEffect(() => { - const fetchEvents = async (month: number, year: number) => { - const url = `/api/events?month=${month}&year=${year}`; // Use a relative URL - const res = await fetch(url, { - cache: "no-store", // Ensure fresh data - }); +// useEffect(() => { +// const fetchEvents = async (month: number, year: number) => { +// const url = `/api/events?month=${month}&year=${year}`; // Use a relative URL +// const res = await fetch(url, { +// cache: "no-store", // Ensure fresh data +// }); - if (!res.ok) { - throw new Error("Failed to fetch events"); - } +// if (!res.ok) { +// throw new Error("Failed to fetch events"); +// } - return res.json(); - }; +// return res.json(); +// }; - const getEvents = async () => { - try { - const events = await fetchEvents(month, year); - setEvents(events); - } catch (err) { - setError("Failed to fetch events"); - } finally { - setLoading(false); - } - }; +// const getEvents = async () => { +// try { +// const events = await fetchEvents(month, year); +// setEvents(events); +// } catch (err) { +// setError("Failed to fetch events"); +// } finally { +// setLoading(false); +// } +// }; - getEvents(); - }, [month, year]); +// getEvents(); +// }, [month, year]); - const nextParams = changeMonth("inc", { month, year }); - const prevParams = changeMonth("dec", { month, year }); +// const nextParams = changeMonth("inc", { month, year }); +// const prevParams = changeMonth("dec", { month, year }); - if (loading) return

Loading...

; - if (error) return

{error}

; +// if (loading) return

Loading...

; +// if (error) return

{error}

; - return ( -
-
- {`<`} - - {monthNames[month]} - - {`>`} -
- -
- ); -}; +// return ( +//
+//
+// {`<`} +// +// {monthNames[month]} +// +// {`>`} +//
+// +//
+// ); +// }; -export default Calendar; +// export default Calendar; diff --git a/src/components/events/CalendarBody.tsx b/src/components/events/CalendarBody.tsx index 8e2c2b2..1148293 100644 --- a/src/components/events/CalendarBody.tsx +++ b/src/components/events/CalendarBody.tsx @@ -1,60 +1,60 @@ -import EventComponent from "@/components/events/EventDays"; -import type { Event } from "@/lib/types.d.ts"; +// import EventComponent from "@/components/events/EventDays"; +// import type { Event } from "@/lib/types.d.ts"; -const daysOfWeek = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; +// const daysOfWeek = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; -type Props = { - year: number; - month: number; - events: Event[]; -}; +// type Props = { +// year: number; +// month: number; +// events: Event[]; +// }; -export default function CalendarBody({ year, month, events }: Props) { - const firstDayOfMonth = new Date(year, month, 1); - const lastDayOfMonth = new Date(year, month + 1, 0); +// export default function CalendarBody({ year, month, events }: Props) { +// const firstDayOfMonth = new Date(year, month, 1); +// const lastDayOfMonth = new Date(year, month + 1, 0); - const firstDayIndex = firstDayOfMonth.getDay(); - const lastDayIndex = lastDayOfMonth.getDay(); - const lastDay = lastDayOfMonth.getDate(); +// const firstDayIndex = firstDayOfMonth.getDay(); +// const lastDayIndex = lastDayOfMonth.getDay(); +// const lastDay = lastDayOfMonth.getDate(); - const daysInMonth = Array.from({ length: lastDay }, (_, i) => i + 1); +// const daysInMonth = Array.from({ length: lastDay }, (_, i) => i + 1); - return ( -
- {daysOfWeek.map((day) => ( -
- {day} -
- ))} - {Array.from({ length: firstDayIndex }).map((_, i) => ( -
- ))} - {daysInMonth.map((day) => ( -
-

- {day} -

-
- {events.map((event) => ( - - ))} -
-
- ))} - {Array.from({ length: 6 - lastDayIndex }).map((_, i) => ( -
- ))} -
- ); -} +// return ( +//
+// {daysOfWeek.map((day) => ( +//
+// {day} +//
+// ))} +// {Array.from({ length: firstDayIndex }).map((_, i) => ( +//
+// ))} +// {daysInMonth.map((day) => ( +//
+//

+// {day} +//

+//
+// {events.map((event) => ( +// +// ))} +//
+//
+// ))} +// {Array.from({ length: 6 - lastDayIndex }).map((_, i) => ( +//
+// ))} +//
+// ); +// } diff --git a/src/components/events/EventDays.tsx b/src/components/events/EventDays.tsx index 3edf912..9c74165 100644 --- a/src/components/events/EventDays.tsx +++ b/src/components/events/EventDays.tsx @@ -1,37 +1,37 @@ -"use client"; +// "use client"; -import { useEffect, useState } from "react"; -import type { Event } from "@/lib/types.d.ts"; +// import { useEffect, useState } from "react"; +// import type { Event } from "@/lib/types.d.ts"; -type Props = { - event: Event; - day: number; - month: number; -}; +// type Props = { +// event: Event; +// day: number; +// month: number; +// }; -const EventComponent = ({ event, day, month }: Props) => { - const [localStartDate, setLocalStartDate] = useState(null); +// const EventComponent = ({ event, day, month }: Props) => { +// const [localStartDate, setLocalStartDate] = useState(null); - useEffect(() => { - if (event.start) { - const localDate = new Date(event.start); - setLocalStartDate(localDate); - } - }, [event]); +// useEffect(() => { +// if (event.start) { +// const localDate = new Date(event.start); +// setLocalStartDate(localDate); +// } +// }, [event]); - if ( - !localStartDate || - localStartDate.getDate() !== day || - localStartDate.getMonth() !== month - ) { - return null; - } +// if ( +// !localStartDate || +// localStartDate.getDate() !== day || +// localStartDate.getMonth() !== month +// ) { +// return null; +// } - return ( -
- {event.title} -
- ); -}; +// return ( +//
+// {event.title} +//
+// ); +// }; -export default EventComponent; +// export default EventComponent;