Files
edr-platform/RESTART_BOOKING_IMPLEMENTATION.md
2026-06-03 15:36:37 +03:00

2.5 KiB

Nationality Mismatch Restart Booking - IMPLEMENTED

Changes Made

File: edr-passenger-web/portal/src/app/booking/passengers/page.tsx

Changes:

  1. Added clearBooking to the imported hooks from useBookingStore
  2. Updated the "Restart Booking" button click handler to:
    • Clear the entire booking state using clearBooking()
    • Perform a full page reload to /booking/search using window.location.href
    • Added visual feedback with ExternalLink icon

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:

  1. Warning card displays with ⚠️ icon
  2. User clicks "Restart Booking" button
  3. Button action triggers:
    • State Clearing: All booking data is cleared from Zustand store and localStorage:
      • searchCriteria
      • selectedSchedule
      • passengers
      • seatHold
      • bookingId
      • pnr
      • selectedPaymentMethod
      • createAccount
      • passengerId
    • Full Page Reload: Browser navigates to /booking/search with full page reload (not client-side navigation)
    • Visual Feedback: ExternalLink icon indicates external/full navigation action

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.href triggers full page reload (unlike router.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