VSN-1976/ Changing logic of state to handle Auto-refrech after personalisation
Replace boolean refresh mechanism with reliable timestamp-based trigger
This merge request replaces the previous boolean-based refresh system (refreshSlots) with a more reliable timestamp trigger (refreshTrigger). The old mechanism was causing synchronization issues where the parent component did not always detect updates triggered from the child form, resulting in inconsistent data refresh after saving a trip.
Removed refreshSlots and setRefreshSlots props.
Added a new timestamp-based trigger: refreshTrigger and setRefreshTrigger.
Updated the parent component (DriverSchedule) to refresh data whenever the trigger value changes.
Updated TrajetPlanningForm to call setRefreshTrigger(Date.now()) after a successful save.
Simplified the parent useEffect by removing boolean reset logic, eliminating race conditions.
Improved synchronization between form actions and schedule data reloading.
The boolean refresh flag could be reset too early during async operations, causing missed updates and inconsistent schedule reloading. Using a timestamp ensures each trigger is unique and guarantees the parent always reacts correctly.
Reliable and deterministic data refresh
No more race conditions
Better separation of concerns between parent and child
Improved stability in planning updates