Overview
At Swiggy, efficient management of orders is crucial for seamless operations. Restaurant partners and internal support teams rely on dashboards to quickly find, sort, and filter orders to address issues, track progress, or analyze performance. This problem simulates building a core component of such a dashboard: a dynamic order list table. Your task is to implement a client-side interactive table that allows users to sort orders and apply various filters, enhancing data visibility and operational efficiency.
What you need to do / Task
Your goal is to build a React component that displays a list of mock Swiggy orders in a table, with the following interactive features:
- Display Orders: Render all provided mock order data in a clear table format.
- Sortable Columns: Implement client-side sorting for the following columns:
Order ID (numeric, but string for 'SWG' prefix, so lexicographical comparison is fine initially)
Order Value (numeric)
Delivery Time (numeric, representing minutes)
Clicking a column header should sort the data in ascending order. Clicking the same header again should reverse the sort order (descending).
- Filter by Status: Add a dropdown filter that allows users to view orders based on their
status (e.g., "PENDING", "COMPLETED", "CANCELLED"). An "All" option should also be available to clear the status filter.
- Search by Customer Name: Implement a text input field that filters the orders dynamically as the user types, matching
customerName (case-insensitive, partial match).
- Combined Interactions: Ensure that sorting and filtering/searching can be applied simultaneously and correctly. For example, a user should be able to search for a customer, then sort the results by order value.
UI/UX expectations
- Table Layout: A standard HTML
<table> should be used, with distinct header and body sections.
- Sorting Indicators: Sortable column headers should visually indicate their sortable nature (e.g., via cursor change) and display the current sort direction (e.g., up/down arrow icons).
- Filter Controls:
- The status filter should be a
<select> dropdown element.
- The customer name search should be an
<input type="text"> element.
- Readability: Basic styling (e.g., borders, padding) to make the table and controls legible. Focus on functionality over pixel-perfect design.
Acceptance criteria
- The table renders all mock orders correctly upon initial load.
- Clicking the 'Order ID' column header sorts orders lexicographically in ascending order, then descending on a second click.
- Clicking the 'Order Value' column header sorts orders numerically in ascending order, then descending on a second click.
- Clicking the 'Delivery Time' column header sorts orders numerically in ascending order, then descending on a second click.
- Selecting a status from the dropdown (e.g., "COMPLETED") correctly filters the table to show only orders with that status.
- Typing into the customer name search box (e.g., "john") filters the table to show only orders where the customer name contains "john" (case-insensitive).
- All filters and sorts can be combined, and the resulting data reflects all active criteria correctly.