mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
fix(reservations): clear editingReservation after successful save
When a reservation was saved, only setShowReservationModal(false) was called. The modal's useEffect watches [reservation, isOpen, ...], so flipping isOpen to false re-ran the effect with the stale editingReservation (old assignment_id), resetting the form to the pre-edit state during the closing animation. Users perceived this as the value reverting after save. Calling setEditingReservation(null) immediately after the close mirrors the existing onClose handler and prevents the stale-prop form reset.
This commit is contained in:
@@ -642,6 +642,7 @@ export default function TripPlannerPage(): React.ReactElement | null {
|
||||
const r = await tripActions.updateReservation(tripId, editingReservation.id, { ...data, day_id: selectedDayId || null })
|
||||
toast.success(t('trip.toast.reservationUpdated'))
|
||||
setShowReservationModal(false)
|
||||
setEditingReservation(null)
|
||||
if (data.type === 'hotel') {
|
||||
accommodationsApi.list(tripId).then(d => setTripAccommodations(d.accommodations || [])).catch(() => {})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user