| @@ -6,6 +6,7 @@ import React, { | |||||
| MouseEvent, | MouseEvent, | ||||
| SetStateAction, | SetStateAction, | ||||
| useCallback, | useCallback, | ||||
| useEffect, | |||||
| useMemo, | useMemo, | ||||
| useState, | useState, | ||||
| } from "react"; | } from "react"; | ||||
| @@ -201,7 +202,11 @@ function SearchResults<T extends ResultWithId>({ | |||||
| const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
| const [page, setPage] = React.useState(0); | const [page, setPage] = React.useState(0); | ||||
| const [rowsPerPage, setRowsPerPage] = React.useState(10); | const [rowsPerPage, setRowsPerPage] = React.useState(10); | ||||
| useEffect(() => { | |||||
| setPage(0); | |||||
| }, [items]); | |||||
| /// this | /// this | ||||
| const handleChangePage: TablePaginationProps["onPageChange"] = ( | const handleChangePage: TablePaginationProps["onPageChange"] = ( | ||||
| _event, | _event, | ||||
| @@ -205,6 +205,7 @@ const Shop: React.FC = () => { | |||||
| // SearchBox onSearch will call this | // SearchBox onSearch will call this | ||||
| const handleSearch = (inputs: Record<string, string>) => { | const handleSearch = (inputs: Record<string, string>) => { | ||||
| setFilters(inputs); | setFilters(inputs); | ||||
| setPagingController((prev) => ({ ...prev, pageNum: 1 })); | |||||
| const params: Record<string, string> = {}; | const params: Record<string, string> = {}; | ||||
| Object.entries(inputs || {}).forEach(([k, v]) => { | Object.entries(inputs || {}).forEach(([k, v]) => { | ||||
| if (v != null && String(v).trim() !== "") params[k] = String(v).trim(); | if (v != null && String(v).trim() !== "") params[k] = String(v).trim(); | ||||