mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
2.5 KiB
2.5 KiB
Nationality Mismatch Restart Booking - IMPLEMENTED
Changes Made
File: edr-passenger-web/portal/src/app/booking/passengers/page.tsx
Changes:
- Added
clearBookingto the imported hooks fromuseBookingStore - Updated the "Restart Booking" button click handler to:
- Clear the entire booking state using
clearBooking() - Perform a full page reload to
/booking/searchusingwindow.location.href - Added visual feedback with
ExternalLinkicon
- Clear the entire booking state using
Before:
onClick={() => router.push('/booking/search')}
After:
onClick={() => {
clearBooking();
window.location.href = '/booking/search';
}}
className="btn-primary w-full flex items-center justify-center gap-2"
>
<ExternalLink className="w-5 h-5" />
Restart Booking
</button>
Behavior
When user encounters a nationality mismatch error:
- Warning card displays with ⚠️ icon
- User clicks "Restart Booking" button
- Button action triggers:
- State Clearing: All booking data is cleared from Zustand store and localStorage:
searchCriteriaselectedSchedulepassengersseatHoldbookingIdpnrselectedPaymentMethodcreateAccountpassengerId
- Full Page Reload: Browser navigates to
/booking/searchwith full page reload (not client-side navigation) - Visual Feedback: ExternalLink icon indicates external/full navigation action
- State Clearing: All booking data is cleared from Zustand store and localStorage:
Benefits
✅ Complete State Reset: Ensures all booking data is cleared, preventing stale data issues ✅ Fresh Start: Full page reload ensures clean state on search page ✅ Clear UX: ExternalLink icon visually indicates a reload action ✅ No Residual Data: Prevents any leftover booking information from previous attempt ✅ Consistent User Flow: Forces fresh search criteria entry
Technical Details
- Uses
useBookingStore().clearBooking()from Zustand store window.location.hreftriggers full page reload (unlikerouter.push()which is client-side navigation)- All booking state is reset to initial values defined in store
- localStorage is automatically cleared due to Zustand's persist middleware
Testing Checklist
- Login with account that has nationality A
- Search for passenger with nationality B
- Verify nationality mismatch error appears
- Click "Restart Booking" button
- Verify page reloads to search page
- Verify booking store is completely cleared
- Verify search page shows default/empty state
- Verify user can perform new search