-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented new products search by name
- Loading branch information
Showing
11 changed files
with
109 additions
and
116 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file added
BIN
+36.6 KB
src/frontend/.yarn/cache/use-debounce-npm-10.0.0-04f7df41a1-b0fd28112a.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 14 additions & 36 deletions
50
src/frontend/src/features/products/components/ProductsFilterAppliedParams.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/frontend/src/features/products/components/SearchByName.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import SearchIcon from '@mui/icons-material/Search'; | ||
import { TextField, InputAdornment } from '@mui/material'; | ||
import { useState, type FC, type ChangeEventHandler, useEffect } from 'react'; | ||
import { useDebounce } from 'use-debounce'; | ||
import { useAppDispatch } from 'src/store'; | ||
import { validateProductName } from 'src/utils/validation'; | ||
import { productSearchNameChanged } from '../store'; | ||
|
||
const SearchByName: FC = () => { | ||
const [query, setQuery] = useState(''); | ||
const [debouncedQuery] = useDebounce(query, 500); | ||
const dispatch = useAppDispatch(); | ||
|
||
useEffect(() => { | ||
if (debouncedQuery === '' || validateProductName(debouncedQuery)) { | ||
dispatch(productSearchNameChanged(debouncedQuery)); | ||
} | ||
}, [debouncedQuery, dispatch]); | ||
|
||
const handleQueryChange: ChangeEventHandler<HTMLInputElement> = event => { | ||
setQuery(event.target.value); | ||
}; | ||
|
||
return ( | ||
<TextField | ||
size="small" | ||
placeholder="Search by name" | ||
value={query} | ||
onChange={handleQueryChange} | ||
InputProps={{ | ||
startAdornment: ( | ||
<InputAdornment position="start"> | ||
<SearchIcon /> | ||
</InputAdornment> | ||
), | ||
}} | ||
sx={theme => ({ | ||
minWidth: '200px', | ||
width: '100%', | ||
[theme.breakpoints.up('sm')]: { | ||
width: '200px', | ||
}, | ||
})} | ||
/> | ||
); | ||
}; | ||
|
||
export default SearchByName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters