mirror of
https://github.com/dylanbenzi/yellowbird.git
synced 2026-11-27 01:07:01 +00:00
cleaned up code prior to calendar migration to db data
This commit is contained in:
@@ -20,7 +20,7 @@ const page = async () => {
|
||||
const endDate = addDays(startDate, 41);
|
||||
|
||||
const getEventArray = await getEvents(startDate, endDate);
|
||||
// console.log(getEventArray);
|
||||
console.log(getEventArray);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col w-full h-full gap-4">
|
||||
@@ -57,7 +57,7 @@ const page = async () => {
|
||||
</Card>
|
||||
</div>
|
||||
<div className="w-full h-full flex gap-4">
|
||||
<MonthCalendar />
|
||||
<MonthCalendar events={getEventArray} />
|
||||
<Day />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,8 +20,9 @@ import { Tabs, TabsList, TabsTrigger } from "../ui/tabs";
|
||||
import { Button } from "../ui/button";
|
||||
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
|
||||
import { dates, week } from "../../../public/MockData/Calendar";
|
||||
import { Event } from "@/db/db_calls";
|
||||
|
||||
const MonthCalendar = () => {
|
||||
const MonthCalendar = (props: { events: Event[] }) => {
|
||||
const startDate = startOfWeek(startOfMonth(new Date("2024-09-22")));
|
||||
const endDate = addDays(startDate, 41);
|
||||
const today = new Date();
|
||||
|
||||
+5
-29
@@ -42,10 +42,10 @@ export const syncUsers = async ({
|
||||
}
|
||||
};
|
||||
|
||||
export interface EventArray {
|
||||
date?: string;
|
||||
events?: Event[];
|
||||
}
|
||||
// export interface EventArray {
|
||||
// date?: string;
|
||||
// events?: Event[];
|
||||
// }
|
||||
|
||||
export interface Event {
|
||||
id: string;
|
||||
@@ -63,9 +63,7 @@ export interface Event {
|
||||
}
|
||||
|
||||
export const getEvents = async (startDate: Date, endDate: Date) => {
|
||||
const eventArray: EventArray[] = [];
|
||||
|
||||
const events: Event[] = await db
|
||||
const eventArray: Event[] = await db
|
||||
.select()
|
||||
.from(EventsTable)
|
||||
.where(
|
||||
@@ -76,27 +74,5 @@ export const getEvents = async (startDate: Date, endDate: Date) => {
|
||||
)
|
||||
.orderBy(asc(EventsTable.datetime));
|
||||
|
||||
events.forEach((e) => {
|
||||
const UTCDate = e.datetime;
|
||||
const localDate = UTCDate.toLocaleString("en-US", {
|
||||
timeZone: "America/New_York",
|
||||
});
|
||||
console.log(new Date(localDate));
|
||||
});
|
||||
|
||||
// console.log(events);
|
||||
|
||||
for (let d = startDate; d <= endDate; d.setDate(d.getDate() + 1)) {
|
||||
const eventsByDay: Event[] = [];
|
||||
|
||||
events.forEach((e) => {
|
||||
if (isSameDay(e.datetime, d)) {
|
||||
eventsByDay.push(e);
|
||||
}
|
||||
|
||||
eventArray.push({ "date": d.toString(), events: eventsByDay });
|
||||
});
|
||||
}
|
||||
|
||||
return eventArray;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user