@@ -862,14 +862,16 @@ const ReservationUnit = ({
862862 console . warn ( "not reservable because: " , reason ) ;
863863 }
864864
865- const [ storedReservation , setStoredReservation , _removeStoredReservation ] =
865+ const [ storedReservation , setStoredReservation ] =
866866 useLocalStorage < PendingReservation > ( "reservation" ) ;
867867 const storeReservationForLogin = useCallback ( ( ) => {
868868 if ( reservationUnit . pk != null && focusSlot != null ) {
869869 const { start, end } = focusSlot ?? { } ;
870+ // NOTE the only place where we use ISO strings since they are always converted to Date objects
871+ // another option would be to refactor storaged reservation to use Date objects
870872 setStoredReservation ( {
871- begin : toUIDate ( start ) ,
872- end : toUIDate ( end ) ,
873+ begin : start . toISOString ( ) ,
874+ end : end . toISOString ( ) ,
873875 price : undefined ,
874876 reservationUnitPk : reservationUnit . pk ?? 0 ,
875877 } ) ;
@@ -900,17 +902,18 @@ const ReservationUnit = ({
900902 } , [ ] ) ;
901903
902904 useEffect ( ( ) => {
903- const start = storedReservation ?. begin
904- ? new Date ( storedReservation . begin )
905- : null ;
906- const end = storedReservation ?. end ? new Date ( storedReservation . end ) : null ;
907-
908- if ( start && end ) {
909- handleCalendarEventChange ( {
910- start,
911- end,
912- } as CalendarEvent < ReservationNode > ) ;
905+ const { begin, end } = storedReservation ?? { } ;
906+ if ( begin == null || end == null ) {
907+ return ;
913908 }
909+
910+ const beginDate = new Date ( begin ) ;
911+ const endDate = new Date ( end ) ;
912+
913+ handleCalendarEventChange ( {
914+ start : beginDate ,
915+ end : endDate ,
916+ } ) ;
914917 // eslint-disable-next-line react-hooks/exhaustive-deps
915918 } , [ storedReservation ?. begin , storedReservation ?. end ] ) ;
916919
0 commit comments