Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,15 @@ export const ApiListTableCards = ({
/>
) : (
<>
<div style={{ marginTop: "2rem" }}>
<div style={{ margin: "1rem auto 2rem" }}>
<Pagination
pageNumber={pageNumber}
setPageNumber={setPageNumber}
pageMax={Math.ceil(apis?.count / defaultPageSize)}
/>
</div>

<div>
{layout === TLayout.table ? (
<ApisTable
apis={apis}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ export const ProductsTableCards = ({
</div>
) : (
<>
<div style={{ marginTop: "2rem" }}>
<div style={{ margin: "1rem auto 2rem" }}>
<Pagination pageNumber={pageNumber} setPageNumber={setPageNumber} pageMax={Math.ceil(products?.count / defaultPageSize)} />
</div>

<div>
{layout === TLayout.table ? (
<ProductsTable products={products.value} getReferenceUrl={getReferenceUrl} />
) : (
Expand Down
14 changes: 12 additions & 2 deletions src/components/utils/react/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ export const Pagination = ({ pageNumber, setPageNumber, ...props }: TPaginationP
<Stack horizontal tokens={{childrenGap: ".5rem"}}>
<Stack.Item>
<Button appearance="transparent" onClick={() => setPageNumber(1)} disabled={pageNumber === 1} icon={<ChevronDoubleLeft16Regular />}/>
<Button appearance="transparent" onClick={() => setPageNumber(prev => prev - 1)} disabled={pageNumber === 1} icon={<ChevronLeft16Regular />}/>
<Button
appearance="transparent"
onClick={() => setPageNumber(prev => prev - 1)}
disabled={pageNumber === 1}
icon={<ChevronLeft16Regular />}
>
Previous
</Button>
</Stack.Item>

{"pageMax" in props && Array.from({length: props.pageMax}, (_, i) => i + 1).map(e => (
Expand All @@ -39,7 +46,10 @@ export const Pagination = ({ pageNumber, setPageNumber, ...props }: TPaginationP
onClick={() => setPageNumber(prev => prev + 1)}
disabled={"pageMax" in props ? pageNumber === props.pageMax : !props.hasNextPage}
icon={<ChevronRight16Regular/>}
/>
iconPosition="after"
>
Next
</Button>
{"pageMax" in props && (
<Button appearance="transparent" onClick={() => setPageNumber(props.pageMax)} disabled={pageNumber === props.pageMax} icon={<ChevronDoubleRight16Regular />}/>
)}
Expand Down