diff --git a/frontend/src/components/TimeEntry/EntryForm.jsx b/frontend/src/components/TimeEntry/EntryForm.jsx index f9fd695..0583b37 100644 --- a/frontend/src/components/TimeEntry/EntryForm.jsx +++ b/frontend/src/components/TimeEntry/EntryForm.jsx @@ -39,12 +39,22 @@ const EntryForm = ({ onEntryAdded }) => { } }, [duration, type, dayType, entryMode]); + // Auto-detect Day Type based on Date + useEffect(() => { + if (!date) return; + // Parse date manually to avoid UTC conversion issues (use local noon) + const [y, m, d] = date.split('-').map(Number); + const checkDate = new Date(y, m - 1, d, 12, 0, 0); + const detected = detectDayType(checkDate); + setDayType(detected); + }, [date]); + useEffect(() => { if (entryMode === 'range' && type === 'standby') { const entries = generateStandbyEntries(date, dateEnd); let total = 0; entries.forEach(e => { - const banked = calculateBankedHours(e.duration, e.type, e.dayType); // Should handle 16->2, 24->3 (if formula is correct) + const banked = calculateBankedHours(e.duration, e.type, e.dayType); total += banked; }); setBulkPreview({ count: entries.length, totalHours: total }); @@ -228,16 +238,12 @@ const EntryForm = ({ onEntryAdded }) => {
- +
)}