Interactive Multi-Stage Booking Progress Tracker
Booking complex travel itineraries often involves multiple steps, from selecting flights/hotels to passenger details and payment. Users can find lengthy forms daunting and may drop off if they lose track of their progress or cannot easily navigate between sections. This problem focuses on building a robust, interactive multi-stage progress tracker component that clearly indicates the user's current position, completed steps, and upcoming stages, significantly enhancing the booking experience and reducing drop-offs.
Your primary task is to develop a reusable ProgressBar React component that visualizes the user's progress through a predefined sequence of stages. The component must:
current active stage based on user interaction or external updates.completed, current, upcoming, and disabled stages using distinct visual styles. These states must be derived based on the currentActiveStageId and each stage's disabled property.completed stages to revisit them, and on upcoming stages (if not explicitly disabled) to advance to them. Simulate this navigation by updating the current active stage.initialCurrentStageId prop (e.g., from external actions like 'Next'/'Previous' buttons) and re-render accordingly.Current: Prominently highlighted (e.g., distinct background, border, or text color).Completed: Visually distinct, indicating successful completion (e.g., checkmark icon, different background/text color). These should be clickable.Upcoming: Standard appearance, indicating it's yet to be reached. These should be clickable unless disabled.Disabled: Greyed out or visually muted, indicating it's not currently accessible or clickable. Cursor should be not-allowed.current stage is visually highlighted and distinct from other stages based on the initialCurrentStageId prop.Completed stages are visually distinct and interactive (clickable to become the current stage).Upcoming stages are visually distinct and interactive (clickable to become the current stage) unless explicitly disabled.Disabled stages are visually distinct, non-interactive (not clickable), and display a not-allowed cursor on hover.current active stage in the component's state and triggers the onStageChange callback.completed stages are also 'completed' in style).currentActiveStageId state when the initialCurrentStageId prop changes externally.Constraints
Stage objects. Each Stage has an id, title, and optionally icon (ReactNode/JSX.Element) and disabled (boolean).ProgressBar component is responsible for deriving the completed, current, or upcoming status for each stage based on the provided initialCurrentStageId and its position in the stages array.disabled: true in the input data, which makes it non-interactive regardless of its upcoming status.ProgressBar component is structured, its reusability, and separation of concerns.Loading editor...