Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(page loading): condition for more button #95

Merged
merged 5 commits into from
Feb 19, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.29

- fix more button issue in page loading component

## 2.1.28

- upgrade node-ip package (transitive dependency over @storybook/core-server) to remove CVE-2023-42282
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@catena-x/portal-shared-components",
"version": "2.1.28",
"version": "2.1.29",
"description": "Catena-X Portal Shared Components",
"author": "Catena-X Contributors",
"license": "Apache-2.0",
Expand Down
4 changes: 3 additions & 1 deletion src/components/basic/Table/PageLoadingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const PageLoadingTable = function <Row, Args>({
reload={refetch}
{...props}
/>
{items.length > 0 && hasMore && (
{items.length > 0 && hasMore ? (
<Box
sx={{
width: '100%',
Expand All @@ -150,6 +150,8 @@ export const PageLoadingTable = function <Row, Args>({
>
<LoadMoreButton label={loadLabel || 'load more'} onClick={nextPage} />
</Box>
) : (
<></>
)}
</>
)
Expand Down
5 changes: 2 additions & 3 deletions src/components/basic/Table/components/Helper/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ export interface PageDataRows {

export const hasMorePages = (data: PageDataProps) => {
return (
(data.page && data.totalPages && data?.page < data?.totalPages - 1) ??
(data?.meta && data.meta.page < data.meta.totalPages - 1)
data?.meta && data.meta.page < data.meta.totalPages - 1
)
}

export const getMaxRows = (data: PageDataRows) => {
return data?.totalElements ?? data?.meta?.totalElements ?? 0
return data?.meta?.totalElements ?? 0
}
Loading