This commit is contained in:
2024-10-03 17:16:15 +05:00
parent cb3d3e5ab4
commit ba69acf1ad
3 changed files with 12 additions and 18 deletions
+10 -3
View File
@@ -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<boolean>(false);
const [slot, setSlot] = useState<number>();
@@ -35,7 +42,7 @@ function Schedule({ slots, events }: Props) {
}
function handleChangeStartAt(startAt: Date) {
setStartAt(startAt);
setStartAt(setDate(startAt, getDate(selectedDay)));
}
function handleChangeDuration(duration: number) {
+1 -15
View File
@@ -29,7 +29,7 @@ function Timeline({
}: Props) {
const [pressed, setPressed] = useState(false);
const [startPosY, setStartPosY] = useState<number>();
const [currentPosY, setCurrentPosY] = useState<number>();
const [, setCurrentPosY] = useState<number>();
const ref = useRef<HTMLDivElement>(null);
const [startAt, setStartAt] = useState<string>();
const [duration, setDuration] = useState<number>(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));
+1
View File
@@ -438,6 +438,7 @@ function DashboardPage() {
{selectedBuild?.sessionLimit && scheduledSessions && (
<Schedule
selectedDay={selectedDay}
slots={selectedBuild.sessionLimit}
events={scheduledSessions}
/>