relative page routing seems functional

This commit is contained in:
Carter 2024-12-10 14:20:22 -06:00
parent 84d06d9783
commit 05f7765f82
4 changed files with 73 additions and 32 deletions

View file

@ -11,6 +11,7 @@ import PageContainer from "./PageContainer";
import { useMobile } from "hooks";
import { useLocation, useNavigate } from "react-router-dom";
import { or } from "utils/types";
import { getContextKeys, getContextTypes } from "pbHelpers/Context";
const useStyles = makeStyles((theme: Theme) => {
return ({
@ -30,7 +31,7 @@ export default function Devices() {
const location = useLocation();
const deviceAPI = useDeviceAPI();
const [limit, setLimit] = useState(10);
const [offset, setOffset] = useState(0);
const [page, setPage] = useState(0);
const [order, ] = useState<"asc" | "desc">("asc");
const [orderBy, ] = useState("name");
const [search, setSearch] = useState("");
@ -47,7 +48,21 @@ export default function Devices() {
};
const loadDevices = () => {
deviceAPI.list(limit, offset*limit, order, orderBy, search).then(resp => {
deviceAPI.list(
limit,
page*limit,
order,
orderBy,
search,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
getContextKeys(),
getContextTypes()
).then(resp => {
setDevices(resp.data.devices)
setTotal(resp.data.total)
})
@ -55,7 +70,7 @@ export default function Devices() {
useEffect(() => {
loadDevices()
}, [limit, offset, order, orderBy, search])
}, [limit, page, order, orderBy, search])
const handleChange = (event: any) => {
setLimit(event.target.value);
@ -102,8 +117,8 @@ export default function Devices() {
columns={columns()}
total={total}
pageSize={limit}
page={offset}
setPage={setOffset}
page={page}
setPage={setPage}
handleRowsPerPageChange={handleChange}
onRowClick={toDevice}
setSearchText={setSearch}