Frontend School

Booking Event Timeline Component

Machine Coding
hard

Booking Event Timeline Component

Hard
React
Frontend
UI
State Management
Timeline

Overview

At OYO, understanding the lifecycle of a booking is critical for customer support, operations, and analytics. A comprehensive timeline view helps our teams quickly grasp the history of a booking, from confirmation to check-out, including any issues or modifications. This problem challenges you to build a robust and interactive timeline component to visualize these events.

What you need to do / Task

Your goal is to create a BookingTimeline React component that displays a series of chronological events related to a specific booking.

  1. Event Display: Render a list of events, each showing its type (e.g., "Booking Confirmed"), a concise title, and its timestamp.
  2. Date Grouping: Group events visually by their date. Events occurring today should be under a "Today" heading, yesterday under "Yesterday", and older events under an "Earlier" heading.
  3. Interactive Details: Each event should be clickable. Upon clicking, it should expand to reveal additional details (e.g., a longer description, specific data points), and collapse when clicked again.
  4. Event Filtering: Implement a filtering mechanism (e.g., a set of buttons or a dropdown) that allows users to filter events by their category (e.g., BOOKING, PAYMENT, GUEST, SUPPORT, SYSTEM). The filter should be persistent until changed.
  5. "Jump to Latest" Functionality: Include a floating button, visible when the user scrolls down, that allows them to quickly jump back to the most recent events at the top of the timeline.

UI/UX expectations

  • Layout: The timeline should be vertically oriented. Each event should be clearly distinguishable. Date groupings should have clear headings.
  • Interactions: Filtering should be intuitive. Expanding/collapsing events should be smooth. The "Jump to Latest" button should be easily discoverable and responsive to scroll position.
  • Accessibility: Ensure filter controls are keyboard navigable. Expanded content should be accessible.

Acceptance criteria

  • The component correctly renders all provided events in chronological order (most recent first).
  • Events are accurately grouped under "Today", "Yesterday", and "Earlier" headings based on their timestamp.
  • Clicking an event toggles the visibility of its detailed information.
  • The filtering mechanism correctly filters events based on the selected category.
  • A "Jump to Latest" button appears when the user scrolls down and, when clicked, scrolls the view to the top of the timeline.
  • The component is responsive enough to be usable on typical desktop and mobile screen sizes.

Constraints

Constraints & assumptions

  • You will be provided with a mock dataset of TimelineEvent objects.
  • The component should be built using React.js (functional components and hooks).
  • Styling can be done using plain CSS or CSS modules. No heavy UI libraries are allowed.
  • Assume a reasonable number of events (e.g., up to 100-200) for performance considerations within the given time.
  • Timestamps will be valid ISO 8601 strings.
  • The TimelineEvent type and mock data will be provided in /App.tsx.

Out of scope

  • Backend integration or API calls. All data is mock data.
  • Deep internationalization (i18n) beyond basic date formatting.
  • Complex animations or transitions beyond simple expand/collapse.
  • Advanced error handling or loading states.

What interviewers evaluate

  • Architectural Design: How well the component is structured, organized, and how state is managed.
  • Core Functionality: Correct and robust implementation of all required features (timeline, grouping, filtering, interaction).
  • Code Quality: Readability, maintainability, use of appropriate React patterns, and TypeScript type safety.
  • UI/UX Implementation: Adherence to UI/UX expectations, responsiveness, and basic accessibility considerations.

Loading editor...