Frontend School

Interactive Multi-Stage Booking Progress Tracker

Machine Coding
hard

Interactive Multi-Stage Booking Progress Tracker

Hard
React
TypeScript
UI Components
State Management
Progress Bar

Overview

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.

What you need to do / Task

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:

  1. Display Stages: Render a series of stages, each with a title and an optional icon.
  2. Manage State: Internally manage the current active stage based on user interaction or external updates.
  3. Visual Feedback: Clearly distinguish between 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.
  4. Interactivity: Allow users to click on 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.
  5. Dynamic Updates: Be able to receive updates to the initialCurrentStageId prop (e.g., from external actions like 'Next'/'Previous' buttons) and re-render accordingly.
  6. Progress Connectors: Implement visual connectors between stages that indicate the flow and completion status.

UI/UX expectations

  • Layout: Stages should be displayed horizontally, with clear visual separation and connectors.
  • Stage Elements: Each stage should ideally show its title and an icon (if provided). For completed stages, the icon might change to a checkmark.
  • Visual States:
    • 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.
  • Interactions: Clickable stages should have a pointer cursor and a subtle hover effect. Disabled stages should have a 'not-allowed' cursor.
  • Accessibility: While not a primary focus for the 45-minute scope, consider semantic HTML elements where appropriate (e.g., buttons for interactive stages).

Acceptance criteria

  • All stages from the input data are rendered with their respective titles and optional icons.
  • The 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.
  • Clicking an interactive stage correctly updates the current active stage in the component's state and triggers the onStageChange callback.
  • The visual connectors between stages correctly reflect the progress path (e.g., connections to completed stages are also 'completed' in style).
  • The component correctly re-renders and updates its internal currentActiveStageId state when the initialCurrentStageId prop changes externally.

Constraints

Constraints & assumptions

  • Input Data: The component will receive an array of Stage objects. Each Stage has an id, title, and optionally icon (ReactNode/JSX.Element) and disabled (boolean).
  • Stage Status Derivation: The 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.
  • Disabling Stages: A stage can be explicitly marked as disabled: true in the input data, which makes it non-interactive regardless of its upcoming status.
  • Environment: React (functional components, hooks) and TypeScript.
  • No Backend: All state changes and "navigation" are simulated purely within the React component's state.
  • Time Budget: Focus on core functionality and clean UI implementation within ~45 minutes.

Out of scope

  • Advanced routing solutions (e.g., React Router integration).
  • Complex animations or transitions beyond basic CSS hover effects.
  • Deep accessibility features (e.g., full keyboard navigation, ARIA live regions).
  • Full responsiveness for all possible screen sizes and stage counts (basic horizontal layout is sufficient).

What interviewers evaluate

  • Component Architecture: How well the ProgressBar component is structured, its reusability, and separation of concerns.
  • State Management: Effective and efficient use of React state and props to manage the active stage and dynamic updates.
  • UI/UX Fidelity: Accuracy in rendering different derived stage states, interactivity, and visual feedback as per requirements.
  • Problem-Solving: Handling edge cases like disabled stages, first/last stage rendering, and dynamic data changes.
  • Code Quality: Readability, maintainability, use of TypeScript, and adherence to React best practices.

Loading editor...