Skip to content

Commit

Permalink
FEATURE: Filter document types to find them quicker (closes #157).
Browse files Browse the repository at this point in the history
  • Loading branch information
Koffi8009 authored and benel committed Jun 11, 2024
1 parent 1e1453e commit 8db04da
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion frontend/src/components/Type.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@ export function TypeBadge({ type, addClassName }) {

function TypeList({ typeSelected, handleUpdate }) {
const types = useContext(TypesContext);
const [searchTerm, setSearchTerm] = useState('');

const filteredTypes = types.filter(type =>
type.doc.type_name.toLowerCase().includes(searchTerm.toLowerCase())
);
return (
<>
<h6 style={{ textAlign: 'left' }}>Select a type</h6>
<input
type="text"
id="searchType"
placeholder="Filter types..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
style={{ marginBottom: '10px', width: '100%', padding: '5px' }}
/>
<ListGroup style={{ textAlign: 'center', paddingTop: 0, paddingBottom: 20 }}>
{types.map((type, index) =>
{filteredTypes.map((type, index) =>
<ListGroup.Item action
key={index}
style={{ backgroundColor: type === typeSelected ? 'grey' : '' }}
Expand Down

0 comments on commit 8db04da

Please sign in to comment.