Frontend School

Interactive Flight Schedule Table

Machine Coding
easy

Interactive Flight Schedule Table

Easy
React
TypeScript
Data Table
Sorting
Filtering
UI

Overview

As a leading travel booking platform, Ixigo prioritizes providing users with clear, efficient, and interactive ways to explore travel options. A core component of our user experience is the display of flight schedules. This problem challenges you to build a foundational interactive flight data table that allows users to easily sort and filter flight information, mimicking a crucial aspect of our platform.

What you need to do / Task

Your goal is to build a React component that displays a list of flight details in a table format, incorporating essential user interaction features:

  1. Display Flight Data: Render a responsive HTML table to display the provided mock flight data. Each flight object will include properties such as flightNumber, origin, destination, departureTime, arrivalTime, price, and airline.
  2. Implement Sorting: Enable users to sort the flight data by price and departureTime. Clicking on the respective column headers should toggle the sort order between ascending, descending, and potentially an unsorted or default state.
  3. Implement Filtering: Provide a text input field above the table. As the user types, the table should dynamically filter flights based on a case-insensitive partial match against the airline name.
  4. Combine Interactions: Ensure that both sorting and filtering functionalities can be applied simultaneously. For instance, a user should be able to filter by an airline and then sort the filtered results by price.

UI/UX expectations

  • The primary display should be an HTML <table> element.
  • Column headers for sortable fields (e.g., 'Price', 'Departure Time') should visually indicate their sortability (e.g., with a pointer cursor).
  • When a column is actively sorted, there should be a visual indicator (e.g., an arrow icon ▲/▼ next to the header) showing the current sort direction.
  • A clearly visible text input field for filtering should be positioned above the table.
  • Basic styling should be applied to ensure readability and a clean layout, making the table and input elements distinct and user-friendly.

Acceptance criteria

  • [ ] The table correctly displays all initial flight data rows and columns.
  • [ ] Clicking the 'Price' column header correctly sorts flights by price (ascending -> descending -> initial/ascending cycle).
  • [ ] Clicking the 'Departure Time' column header correctly sorts flights by departure time (ascending -> descending -> initial/ascending cycle).
  • [ ] The filter input field dynamically filters the displayed flights by airline name (case-insensitive, partial match).
  • [ ] Sorting and filtering functionalities work together seamlessly; filtering applies first, then sorting applies to the filtered dataset.
  • [ ] The application is functional and free of console errors or warnings.

Constraints

Constraints & assumptions

  • You will be provided with a static array of mock flight data directly within the App.tsx file. No API calls are required.
  • The solution should be built using React with TypeScript.
  • Focus on functional components and React Hooks for state management.
  • Styling can be minimal; prioritize functionality and clear UI over elaborate design. You are not expected to use any external UI component libraries.
  • The dataset size will be small (e.g., 10-20 flight records); performance optimizations for very large datasets are not required.
  • All departureTime and arrivalTime values are valid date strings or timestamps that can be reliably compared.

Out of scope

  • Backend integration or any form of data persistence.
  • Pagination for the table.
  • Advanced accessibility features beyond semantic HTML.
  • Complex form validation or error handling for user input.
  • Unit or integration testing.

What interviewers evaluate

  • Correctness and Completeness: Does the solution correctly implement all required features, including sorting logic, filtering logic, and their combined interaction?
  • Code Structure and Readability: How well is the code organized? Is it modular, clean, and easy to understand? Effective use of React components and patterns.
  • TypeScript Proficiency: Appropriate and effective use of TypeScript for defining interfaces, types, and ensuring type safety throughout the application.
  • UI/UX Implementation: Does the user interface meet the specified expectations for layout, interactivity, and visual feedback for sorting?
  • Problem-Solving Approach: The candidate's ability to break down the problem into manageable parts and integrate different features coherently.

Loading editor...