diff --git a/package.json b/package.json index c8173d5..5a29d87 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "tsx": "^4.15.5" }, "devDependencies": { - "@types/node": "^20", + "@types/node": "^20.14.6", "@types/react": "^18", "@types/react-dom": "^18", "autoprefixer": "^10.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 94e76f1..7ebb583 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -122,7 +122,7 @@ dependencies: devDependencies: '@types/node': - specifier: ^20 + specifier: ^20.14.6 version: 20.14.6 '@types/react': specifier: ^18 diff --git a/src/app/calendar/page.tsx b/src/app/calendar/page.tsx index 551af1f..c6d2e7e 100644 --- a/src/app/calendar/page.tsx +++ b/src/app/calendar/page.tsx @@ -6,22 +6,20 @@ import { CardHeader, CardTitle, } from "@/components/ui/card"; +import { getAllEvents } from "@/db/db_calls"; import { addDays, startOfMonth, startOfWeek } from "date-fns"; import { Metadata } from "next"; import React from "react"; -// export const metadata: Metadata = { -// title: "Calendar", -// }; +export const metadata: Metadata = { + title: "Calendar", +}; const page = async () => { const startDate = startOfWeek(startOfMonth(new Date("2024-06-19"))); const endDate = addDays(startDate, 41); - // const getEventArray = await getMonthEvents(6, 2024); - // console.log(getEventArray); - - // const events = await getMonthEvents(startDate, endDate); + const events = await getAllEvents(); // console.log(events); return ( @@ -60,7 +58,7 @@ const page = async () => {
{/* */} - +
diff --git a/src/components/calendar/Calendar.tsx b/src/components/calendar/Calendar.tsx index f1cbbe8..140d8c7 100644 --- a/src/components/calendar/Calendar.tsx +++ b/src/components/calendar/Calendar.tsx @@ -29,7 +29,7 @@ import Month from "./Month"; import Week from "./Week"; interface CalendarProps { - events?: Event[]; + events: Event[]; } const Calendar = ({ events }: CalendarProps) => { @@ -106,7 +106,9 @@ const Calendar = ({ events }: CalendarProps) => { - {calendarView == "month" && } + {calendarView == "month" && ( + + )} {calendarView == "week" && } diff --git a/src/components/calendar/EventList.tsx b/src/components/calendar/EventList.tsx index b458e77..75780af 100644 --- a/src/components/calendar/EventList.tsx +++ b/src/components/calendar/EventList.tsx @@ -2,13 +2,15 @@ import { Event } from "@/db/db_calls"; import { getTime, isSameDay, isSameMonth } from "date-fns"; import React from "react"; import CalendarItem from "./CalendarItem"; +import { format } from "date-fns-tz"; interface EventListProps { date: Date; events: Event[]; + monthYear: string; } -const EventList = ({ date, events }: EventListProps) => { +const EventList = ({ date, events, monthYear }: EventListProps) => { const eventsForDate = events.filter((event) => isSameDay(event.datetime, date) ); @@ -18,11 +20,13 @@ const EventList = ({ date, events }: EventListProps) => { {eventsForDate.length < 4 ? eventsForDate.map((event, eventkey: number) => ( { { +const Month = ({ monthYear, events }: MonthProps) => { const days: Date[] = []; const sevenDays = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]; - const startDate = startOfWeek(startOfMonth(new Date("2024-06-19"))); + const startDate = startOfWeek(startOfMonth(new Date(monthYear))); const endDate = addDays(startDate, 41); for (let d = startDate; d <= endDate; d.setDate(d.getDate() + 1)) { @@ -50,7 +51,7 @@ const Month = async ({ monthYear }: MonthProps) => { className={cn( // isWeekend(item.date) ? "bg-muted" : "", isSunday(item) ? "border border-l-0" : "border", - isSameMonth(item, new Date()) ? "" : "bg-muted", + isSameMonth(item, monthYear) ? "" : "bg-muted", "border-neutral-700 flex flex-col border-b-0 border-r-0" )} > @@ -66,7 +67,7 @@ const Month = async ({ monthYear }: MonthProps) => { })}

- {/* */} + {/*
{item.events.length < 4 ? item.events.map((event: any, eventkey: number) => ( diff --git a/src/db/db_calls.ts b/src/db/db_calls.ts index 3e163db..9cfa6ec 100644 --- a/src/db/db_calls.ts +++ b/src/db/db_calls.ts @@ -79,7 +79,7 @@ export const getEvents = cache(async (startDate: Date, endDate: Date) => { }); export const getAllEvents = async () => { - const allEvents = await db.select().from(EventsTable); + const allEvents: Event[] = await db.select().from(EventsTable); return allEvents; };