Skip to content

Commit 326632f

Browse files
committed
fix: rounding to full hours when move entry from midnight
1 parent 24a3be3 commit 326632f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

apps/frontend/src/components/questionnaire/calendar/EntryCalendar.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import interactionPlugin from "@fullcalendar/interaction";
33
import timeGridPlugin from "@fullcalendar/timegrid";
44
import { DateSelectArg, EventChangeArg, EventInput } from "@fullcalendar/core";
55
import { Button, Modal, useDisclosure, useMantineTheme } from "@quassel/ui";
6-
import { GapsPerDay, getDateFromTimeAndWeekday, getTime, groupByWeekday, isSame } from "@quassel/utils";
6+
import { GapsPerDay, getDateFromTimeAndWeekday, getNext, getTime, groupByWeekday, isSame } from "@quassel/utils";
77
import { QuestionnaireEntry } from "./QuestionnaireEntry";
88
import { components } from "../../../api.gen";
99
import { EntityForm, EntryFormValues } from "./EntryForm";
@@ -154,10 +154,13 @@ export function EntryCalendar({
154154
open();
155155
};
156156

157-
const handleEventChange = ({ event }: EventChangeArg) => {
158-
const { id, start, end } = event;
157+
const handleEventChange = ({ event: { id, start, end } }: EventChangeArg) => {
159158
if (!start || !end) return;
160159

160+
if (end.getMinutes() === 59 && end.getHours() < 23) {
161+
end = getNext("hour", end);
162+
}
163+
161164
const startTime = getTime(start) < C.calendar.minTime ? C.calendar.minTime : getTime(start);
162165
const endTime = isSame("day", start, end) ? getTime(end) : C.calendar.maxTime;
163166

0 commit comments

Comments
 (0)