v0.10.4 fix event date/time functions

This commit is contained in:
2026-03-21 09:22:02 -04:00
parent 596fd0f969
commit f60730d0a5
5 changed files with 58 additions and 21 deletions

View File

@@ -253,17 +253,22 @@ export default function MobileEventForm({ event, eventTypes, userGroups, selecte
finally { setSavingType(false); }
};
// When start date changes, match end date
useEffect(() => { if(!event) setEd(sd); }, [sd]);
// When type or start time changes, auto-set end time
// When start date or start time changes, update end date/time to maintain duration
useEffect(() => {
if(!sd||!st) return;
const typ = localTypes.find(t=>t.id===Number(typeId));
const dur = typ?.default_duration_hrs||1;
const start = buildISO(sd,st);
if(start && !event) { setEd(toDateIn(addHours(start,dur))); setEt(toTimeIn(addHours(start,dur))); }
}, [typeId, st]);
if(!start) return;
if(event) {
// Editing: only sync end date when start date changes, preserve manual end time
setEd(toDateIn(addHours(start, 0)));
} else {
// New event: always auto-set end to start + duration
setEd(toDateIn(addHours(start,dur)));
setEt(toTimeIn(addHours(start,dur)));
}
}, [sd, st, typeId]);
const handle = async () => {
if(!title.trim()) return toast('Title required','error');