Skip to content

Commit 62e6614

Browse files
authored
Merge pull request #353 from openscript-ch/324-problems-with-adjusting-caregiver-settings-at-the-end-of-the-day
324 problems with adjusting caregiver settings at the end of the day
2 parents 5025e5f + 458ede5 commit 62e6614

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.changeset/spicy-peaches-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@quassel/frontend": patch
3+
---
4+
5+
Prevent dragging event over the calendar limits

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ import { useStore } from "@nanostores/react";
1313
import { EventImpl } from "@fullcalendar/core/internal";
1414
import styles from "./EntryCalendar.module.css";
1515
import { $layout } from "../../../stores/layout";
16+
import { C } from "../../../configuration";
1617

1718
const calendarBaseConfig: FullCalendar["props"] = {
1819
allDaySlot: false,
1920
headerToolbar: false,
20-
slotMinTime: { hour: 5 },
21-
slotMaxTime: { hour: 23 },
21+
slotMinTime: C.calendar.minTime,
22+
slotMaxTime: C.calendar.maxTime,
2223
slotDuration: { hour: 1 },
2324
firstDay: 1,
2425
locale: "de",
@@ -149,9 +150,14 @@ export function EntryCalendar({
149150

150151
const handleEventChange = ({ event }: EventChangeArg) => {
151152
const { id, start, end } = event;
153+
if (!start || !end) return;
154+
155+
const startTime = getTime(start) < C.calendar.minTime ? C.calendar.minTime : getTime(start);
156+
const endTime = isSame("day", start, end) ? getTime(end) : C.calendar.maxTime;
157+
152158
setEvents(events.map((e) => (e.id === id ? { ...e, start: start!, end: end! } : e)));
153159

154-
onUpdateEntry(parseInt(id), { startedAt: getTime(start!), endedAt: getTime(end!), weekday: start!.getDay() });
160+
onUpdateEntry(parseInt(id), { startedAt: startTime, endedAt: endTime, weekday: start!.getDay() });
155161
};
156162

157163
const handleOnSave = async (entry: EntryFormValues) => {

apps/frontend/src/configuration.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ export const C = {
1212
ui: {
1313
maxDropdownHeight: 800,
1414
},
15+
calendar: {
16+
minTime: "05:00",
17+
maxTime: "23:00",
18+
},
1519
};

0 commit comments

Comments
 (0)