Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 13x 24x 7x 4x 3x 48x | import { Typeahead } from "react-bootstrap-typeahead";
import "react-bootstrap-typeahead/css/Typeahead.css";
export default function MenuItemSearch({
results = [],
query = "",
onQueryChange,
onSelect,
isLoading = false,
error = null,
}) {
return (
<div data-testid="menu-item-search">
<Typeahead
id="menu-item-search-typeahead"
inputProps={{ "aria-label": "Search menu items" }}
minLength={2}
labelKey="name"
options={results}
filterBy={() => true}
clearButton
placeholder="Search menu items..."
emptyLabel="No matching menu items"
onInputChange={(value) => onQueryChange?.(value)}
onChange={(selected) => {
if (selected.length > 0) {
onSelect?.(selected[0]);
}
}}
renderMenuItemChildren={(item) => (
<div>
<div>{item.name}</div>
<small className="text-muted">
{item.diningCommonsName ?? item.diningCommonsCode}
</small>
</div>
)}
/>
{isLoading && <div role="status">Searching menu items...</div>}
{error && <div role="alert">Error searching menu items: {error}</div>}
{!isLoading && !error && query.trim() && results.length === 0 && (
<div role="status">No matching menu items found.</div>
)}
</div>
);
}
|