diff --git a/components/reports/ReportForm.js b/components/reports/ReportForm.js index 50bc119..736d422 100644 --- a/components/reports/ReportForm.js +++ b/components/reports/ReportForm.js @@ -46,6 +46,7 @@ export default function ReportForm({ shiftId, existingItem, onDone }) { const initialDate = getFormattedDate(new Date()); const { data: session, status } = useSession() const [publisherId, setPublisher] = useState(null); + const [allDay, setAllDay] = useState(false); useEffect(() => { if (session) { setPublisher(session.user.id); @@ -88,7 +89,11 @@ export default function ReportForm({ shiftId, existingItem, onDone }) { const handleSubmit = async (e) => { e.preventDefault(); item.publisher = { connect: { id: publisherId } }; - item.shift = { connect: { id: parseInt(item.shiftId) } }; + if (allDay) { + delete item.shift; + } else { + item.shift = { connect: { id: parseInt(item.shiftId) } }; + } item.date = new Date(item.date); item.type = ReportType.Report; delete item.publisherId; @@ -117,6 +122,15 @@ export default function ReportForm({ shiftId, existingItem, onDone }) { } } + const handleCheckboxChange = (event) => { + setAllDay(event.target.checked); + + // Set shiftId to null if the checkbox is checked + if (event.target.checked) { + handleChange({ target: { name: 'shiftId', value: null } }); + } + }; + return (