Skip to content

Commit

Permalink
Merge pull request #22 from nico-iaco/feature/itemSearch
Browse files Browse the repository at this point in the history
Added search component with item search feature
  • Loading branch information
nico-iaco authored Oct 10, 2022
2 parents 6feaf51 + 08182e7 commit 6e68e61
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions src/page/itemDashboard/ItemDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,29 @@ import {Item} from "../../model/item";
import {useNavigate} from "react-router-dom";
import {getAllItems} from "../../api/itemApis";
import {setCurrentItem} from "../../action/Action";
import {AppBar, Box, Button, Container, Grid, List, Toolbar, Typography} from "@mui/material";
import {
AppBar,
Box,
Button,
Container,
FormControl,
Grid,
IconButton,
InputAdornment,
InputLabel,
List,
OutlinedInput,
Toolbar,
Typography
} from "@mui/material";
import {ItemRowComponent} from "../../component/ItemRowComponent";
import {Add} from "@mui/icons-material";
import {Add, Search} from "@mui/icons-material";
import {Fab} from "react-tiny-fab";

export const ItemDashboardPage = (props: any) => {
const dispatch = useDispatch();
const [itemList, setItemList] = useState<Item[]>([])
const [search, setSearch] = useState("");
const navigate = useNavigate();
useEffect(() => {
getAllItems()
Expand Down Expand Up @@ -54,9 +69,32 @@ export const ItemDashboardPage = (props: any) => {
</Box>
</Grid>
<Container className="container">
<Grid item xs={8}>
<FormControl variant="outlined" fullWidth>
<InputLabel htmlFor="outlined-adornment-search">Search</InputLabel>
<OutlinedInput
id="outlined-adornment-search"
type={'text'}
value={search}
onChange={(event) => setSearch(event.target.value)}
endAdornment={
<InputAdornment position="end">
<IconButton
edge="end"
>
<Search/>
</IconButton>
</InputAdornment>
}
label="Password"
/>
</FormControl>
</Grid>
<Grid item xs={8}>
<List className="list-container">
{itemList.map(item => {
{itemList
.filter(value => search === "" || (value.name.toLowerCase().includes(search.toLowerCase()) || value.barcode.includes(search)))
.map(item => {
return <ItemRowComponent
key={item.id}
id={item.id}
Expand Down

0 comments on commit 6e68e61

Please sign in to comment.