From e5830bc6e02e864dcc32222d4a9e0e21cbcdcd84 Mon Sep 17 00:00:00 2001 From: Kris Forbes Date: Sun, 11 Jan 2026 20:03:29 -0500 Subject: [PATCH] feat(frontend): automate day type selection and remove manual input --- .../src/components/TimeEntry/EntryForm.jsx | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) 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 }) => {
- +
)}