Overview
Bigbasket store managers need an efficient and interactive dashboard to monitor product inventory across various categories. This tool is crucial for quickly identifying low-stock items, popular products, or products needing immediate attention to maintain optimal stock levels and ensure customer satisfaction. Your task is to build a core part of this dashboard: a dynamic product inventory table that supports client-side sorting and filtering.
What you need to do / Task
Your primary goal is to develop a functional and user-friendly product inventory table using React and TypeScript, incorporating the following features:
- Display Product Data: Render a table displaying product information, including
id, name, category, price, stock, and lastUpdated.
- Client-Side Sorting: Implement sorting functionality for the
name, price, stock, and category columns. Clicking a column header should toggle between ascending, descending, and no sort (or reset to default for that column).
- Product Name Search: Add an input field above the table to allow users to search for products by their
name. The search should be case-insensitive and filter results as the user types.
- Category Filtering: Implement a dropdown (or multi-select) filter to allow users to view products belonging to specific
category/categories. The filter should update the table dynamically.
- Combined Functionality: Ensure that sorting and filtering can be applied simultaneously and work correctly together.
- Empty States: Gracefully handle scenarios where no products match the current filters or search criteria.
UI/UX expectations
- Layout: A clean, tabular layout for displaying product information. Controls for search and filter should be positioned clearly above the table.
- Interactions:
- Table headers should be clickable to trigger sorting. Provide a visual indicator (e.g., an arrow icon or text) for the current sort direction (ascending/descending).
- Search input should update results in real-time as the user types.
- Category filter should update results upon selection.
- Responsiveness: The table should be reasonably responsive on a standard desktop browser viewport (e.g., not break layout on slight resizing).
- Accessibility: Basic accessibility considerations for interactive elements (e.g., keyboard navigability for input/select, appropriate semantic HTML).
Acceptance criteria
- The table successfully displays all mock product data initially.
- Clicking a sortable column header correctly sorts the products in ascending, then descending order, and resets.
- Typing into the product name search input accurately filters the product list (case-insensitive).
- Selecting a category from the filter dropdown correctly displays only products from that category.
- Applying both search and category filters, followed by sorting, yields the correct, combined result set.
- An appropriate message is displayed when no products match the active filters or search.
- The user interface is intuitive, functional, and free of console errors.