← 返回 instacart 的题目列表Implement Search and Filter UI for a Library Management Table
类型:online_judge
Problem: Implement Search and Filtering for a Library Management Table
You are working on an existing library/book management application. The frontend has a long books table, and users complain that it is hard to find the books they need.
Implement a search and filtering feature on the books list page.
Functional Requirements
Add the following controls above the books table:
A text search input
Search by title, author, or ISBN.
Search should be case-insensitive.
Empty input should not filter text fields.
Two dropdown filters
Dropdown 1: filter by book status, such as All, Available, Borrowed, Reserved.
Dropdown 2: filter by category, such as All, Fiction, Non-fiction, Science, History.
Selecting All means no filtering on that field.
Table behavior
The table should display only books matching all active filters.
If no books match, show an empty state such as No books found.
Results should update immediately when the user changes the search input or dropdowns.
Testing Requirements
Add full test coverage:
Unit tests for filtering logic, case-insensitive search, and empty input handling.
Component tests for typing in the search box and selecting dropdown values.
Integration tests for loading data and applying combined filters.
Constraints
Implement this inside the existing project; do not rewrite the application.
Reuse existing components, styling, and data-fetching logic where possible.
Filtering may be client-side, or server-side if the backend already supports query parameters.
Assume up to several thousand books on one page.
Example
Input
Books: [Dune/Fiction/Available, Clean Code/Non-fiction/Borrowed], filters: search='dune', status='All', category='All'
Output
Only Dune is displayed.