diff --git a/pandamarket/sprint5/src/App.js b/pandamarket/sprint5/src/App.js index 38b126fc..37b4e22c 100644 --- a/pandamarket/sprint5/src/App.js +++ b/pandamarket/sprint5/src/App.js @@ -14,6 +14,7 @@ function App() { const [sortedItems, setSortedItems] = useState([]); const [sortedPageSize, setSortedPageSize] = useState(10); const [favoritePageSize, setFavoritePageSize] = useState(4); + const [searchItem, setSearchItem] = useState(''); const loadFavorite = async () => { let pageSize; @@ -24,7 +25,7 @@ function App() { setFavoritePageSize(pageSize); - const response = await getProduct(1, pageSize, 'favorite'); + const response = await getProduct(1, favoritePageSize, 'favorite'); setFavoriteItems(response.list); } @@ -37,10 +38,14 @@ function App() { setSortedPageSize(pageSize); - const response = await getProduct(1, pageSize, sort); + const response = await getProduct(1, sortedPageSize, sort, searchItem); setSortedItems(response.list); } + const handleSearch = (e) => { + setSearchItem(e.target.value); + } + useEffect(() => { const handleResize = () => { setScreenWidth(window.innerWidth); @@ -50,14 +55,14 @@ function App() { loadFavorite(); loadSorted(); - }, [screenWidth, sort]); + }, [screenWidth, sort, searchItem]); return (
{label}