diff --git a/client/src/components/Schedule.tsx b/client/src/components/Schedule.tsx index cbc14c5..9f4426e 100644 --- a/client/src/components/Schedule.tsx +++ b/client/src/components/Schedule.tsx @@ -2,7 +2,13 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { useEffect, useState } from "react"; import Timeline from "./Timeline"; -import { format, setHours, startOfDay } from "date-fns"; +import { + format, + getDate, + setDate, + setHours, + startOfDay, +} from "date-fns"; // import useEventStore from "../stores/useEventStore"; import Button from "./Button"; import CloseIcon from "./icons/CloseIcon"; @@ -12,11 +18,12 @@ import api from "../utils/api"; import useStore from "../stores/useStore"; interface Props { + selectedDay: Date; slots: number; events: any[]; } -function Schedule({ slots, events }: Props) { +function Schedule({ selectedDay, slots, events }: Props) { const { selectedBuild } = useStore(); const [draftMode, setDraftMode] = useState(false); const [slot, setSlot] = useState(); @@ -35,7 +42,7 @@ function Schedule({ slots, events }: Props) { } function handleChangeStartAt(startAt: Date) { - setStartAt(startAt); + setStartAt(setDate(startAt, getDate(selectedDay))); } function handleChangeDuration(duration: number) { diff --git a/client/src/components/Timeline.tsx b/client/src/components/Timeline.tsx index afc0f3a..649c0fc 100644 --- a/client/src/components/Timeline.tsx +++ b/client/src/components/Timeline.tsx @@ -29,7 +29,7 @@ function Timeline({ }: Props) { const [pressed, setPressed] = useState(false); const [startPosY, setStartPosY] = useState(); - const [currentPosY, setCurrentPosY] = useState(); + const [, setCurrentPosY] = useState(); const ref = useRef(null); const [startAt, setStartAt] = useState(); const [duration, setDuration] = useState(30); // min @@ -88,18 +88,6 @@ function Timeline({ onChangeDraftMode(true); } - useEffect(() => { - if (!startPosY) return; - - console.log("startPosY", startPosY); - }, [startPosY]); - - useEffect(() => { - if (!currentPosY) return; - - console.log("currentPosY", currentPosY); - }, [currentPosY]); - // useEffect(() => { // setTimelineEvents( // timelineEvents.filter((event: IEvent) => event.slot === slot) @@ -107,8 +95,6 @@ function Timeline({ // }, [timelineEvents]); useEffect(() => { - console.log("startAt", startAt); - if (!startAt) return; onChangeStartAt(new Date(startAt)); diff --git a/client/src/pages/DashboardPage.tsx b/client/src/pages/DashboardPage.tsx index 3faf970..72427f9 100644 --- a/client/src/pages/DashboardPage.tsx +++ b/client/src/pages/DashboardPage.tsx @@ -438,6 +438,7 @@ function DashboardPage() { {selectedBuild?.sessionLimit && scheduledSessions && (