@@ -156,19 +156,35 @@ export interface BaseEventModalProps {
156156}
157157
158158/**
159- * Checks if the time has changed between initial values and current form data
159+ * Checks if the time has changed between initial values and current form data.
160+ * Compares the combined date (from scheduleDate) and time (from startTime/endTime).
160161 */
161162const hasTimeChanged = ( initialValues : Partial < EventFormValues > | undefined , currentData : EventFormValues ) : boolean => {
162- if ( ! initialValues ?. startTime || ! initialValues ?. endTime ) return false ;
163+ if ( ! initialValues ?. startTime || ! initialValues ?. endTime || ! initialValues ?. scheduleDate ) return false ;
164+
165+ // Combine scheduleDate with time portions for comparison (matches how we send to backend)
166+ const currentCombinedStart = new Date ( currentData . scheduleDate ) ;
167+ currentCombinedStart . setHours (
168+ currentData . startTime . getHours ( ) ,
169+ currentData . startTime . getMinutes ( ) ,
170+ currentData . startTime . getSeconds ( ) ,
171+ currentData . startTime . getMilliseconds ( )
172+ ) ;
173+
174+ const currentCombinedEnd = new Date ( currentData . scheduleDate ) ;
175+ currentCombinedEnd . setHours (
176+ currentData . endTime . getHours ( ) ,
177+ currentData . endTime . getMinutes ( ) ,
178+ currentData . endTime . getSeconds ( ) ,
179+ currentData . endTime . getMilliseconds ( )
180+ ) ;
163181
164182 const originalStartTime = new Date ( initialValues . startTime ) . getTime ( ) ;
165183 const originalEndTime = new Date ( initialValues . endTime ) . getTime ( ) ;
166- const currentStartTime = new Date ( currentData . startTime ) . getTime ( ) ;
167- const currentEndTime = new Date ( currentData . endTime ) . getTime ( ) ;
168184
169185 return (
170- originalStartTime !== currentStartTime ||
171- originalEndTime !== currentEndTime ||
186+ originalStartTime !== currentCombinedStart . getTime ( ) ||
187+ originalEndTime !== currentCombinedEnd . getTime ( ) ||
172188 initialValues . allDay !== currentData . allDay
173189 ) ;
174190} ;
@@ -484,10 +500,27 @@ const EventModal: React.FC<BaseEventModalProps> = ({
484500 payload . initialDateScheduled = data . scheduleDate ;
485501 } else if ( isEditMode && data . selectedScheduleSlotId ) {
486502 // For edit mode, populate editScheduleSlotArgs
503+ // Combine scheduleDate (date portion) with startTime/endTime (time portion)
504+ const combinedStartTime = new Date ( data . scheduleDate ) ;
505+ combinedStartTime . setHours (
506+ data . startTime . getHours ( ) ,
507+ data . startTime . getMinutes ( ) ,
508+ data . startTime . getSeconds ( ) ,
509+ data . startTime . getMilliseconds ( )
510+ ) ;
511+
512+ const combinedEndTime = new Date ( data . scheduleDate ) ;
513+ combinedEndTime . setHours (
514+ data . endTime . getHours ( ) ,
515+ data . endTime . getMinutes ( ) ,
516+ data . endTime . getSeconds ( ) ,
517+ data . endTime . getMilliseconds ( )
518+ ) ;
519+
487520 payload . editScheduleSlotArgs = {
488521 scheduleSlotId : data . selectedScheduleSlotId ,
489- newStartTime : data . startTime ,
490- newEndTime : data . endTime ,
522+ newStartTime : combinedStartTime ,
523+ newEndTime : combinedEndTime ,
491524 newAllDay : data . allDay ,
492525 editAllInSeries
493526 } ;
0 commit comments