Skip to content

Commit

Permalink
Add button so that you can navigate directly to first page of table
Browse files Browse the repository at this point in the history
  • Loading branch information
erikaas24 committed Nov 7, 2024
1 parent b921d6f commit 503ba00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/pages/organization/OrgShop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Props = {
};
export const OrgProducts: React.FC<Props> = ({ organization }) => {
const theme = useTheme();
const limit = 100;
const limit = 5;
const [page, setPage] = useState(0);

const handlePageChange = (newValue: number) => {
Expand Down
20 changes: 12 additions & 8 deletions frontend/src/components/pages/orgs/TableStepper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KeyboardArrowLeft, KeyboardArrowRight } from "@mui/icons-material";
import { KeyboardArrowLeft, KeyboardArrowRight, KeyboardDoubleArrowLeft, KeyboardDoubleArrowRight } from "@mui/icons-material";
import { Button, Typography, Stack } from "@mui/material";
import { useTheme } from "@mui/material/styles";
import React from "react";
Expand All @@ -13,18 +13,22 @@ export const TableStepper: React.FC<Props> = ({ hasNextPage, page, handlePageCha
const theme = useTheme();
const nextPage = () => handlePageChange(page + 1);
const prevPage = () => handlePageChange(page > 0 ? page - 1 : 0);

// Check if there is a next page (if we received less than `limit` items)
//const hasNextPage = (data?.paginatedShopOrders && data.paginatedShopOrders.length < limit) ?? false;
const resetPage = () => handlePageChange(0)

return (
<Stack
sx={{ maxWidth: 300, flexGrow: 1, position: "static", flexDirection: "row", justifyContent: "space-between" }}
>
<Button size="small" onClick={prevPage} disabled={page === 0}>
{theme.direction === "rtl" ? <KeyboardArrowRight /> : <KeyboardArrowLeft />}
Back
</Button>
<Stack sx ={{flexDirection: "row"}}>
<Button size="small" onClick={resetPage} disabled={page === 0}>
{theme.direction === "rtl" ? <KeyboardDoubleArrowRight /> : <KeyboardDoubleArrowLeft />}
First
</Button>
<Button size="small" onClick={prevPage} disabled={page === 0}>
{theme.direction === "rtl" ? <KeyboardArrowRight /> : <KeyboardArrowLeft />}
Back
</Button>
</Stack>

<Typography>{page + 1}</Typography>

Expand Down

0 comments on commit 503ba00

Please sign in to comment.