-
Notifications
You must be signed in to change notification settings - Fork 4
fix: pagination visibility based on totalCount #929
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
Conversation
c59a8a5 to
4ef041d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes pagination control visibility by basing it on the total item count rather than the number of pages. When users set a page size larger than the total number of items, pagination controls now appropriately hide. The PR also removes the unused usePagination hook and its tests.
Key changes:
- Implemented new visibility logic for
PaginationControlbased ontotalCount - Updated list components to pass
totalCountto pagination controls - Removed unused
usePaginationhook and associated tests
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/components/Common/PaginationControl/PaginationControl.tsx | Added visibility logic using totalCount instead of totalPages |
| src/components/Common/PaginationControl/PaginationControlTypes.ts | Added optional totalCount prop to PaginationControlProps |
| src/components/Common/PaginationControl/PaginationControl.test.tsx | Added comprehensive tests for pagination visibility scenarios |
| src/components/Employee/EmployeeList/EmployeeList.tsx | Extracted and passed totalCount from response headers |
| src/components/Employee/EmployeeList/List.tsx | Forwarded totalCount to pagination control |
| src/components/Employee/EmployeeList/useEmployeeList.ts | Added totalCount to context type |
| src/components/Contractor/ContractorList/index.tsx | Added totalCount to pagination props |
| src/components/Company/Locations/LocationsList/LocationsList.tsx | Extracted and passed totalCount from response headers |
| src/components/Company/Locations/LocationsList/List.tsx | Forwarded totalCount to pagination control |
| src/components/Company/Locations/LocationsList/useLocationsList.ts | Added totalCount to context type |
| src/components/Payroll/PayrollConfiguration/PayrollConfiguration.tsx | Extracted and passed totalCount from response headers |
| src/hooks/usePagination/usePagination.ts | Removed unused hook |
| src/hooks/usePagination/usePagination.test.ts | Removed tests for unused hook |
| src/hooks/usePagination/index.ts | Removed export file for unused hook |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
serikjensen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
| return render( | ||
| <ThemeProvider> | ||
| <ComponentsProvider value={defaultComponents}> | ||
| <PaginationControl {...basePaginationProps} {...props} /> | ||
| </ComponentsProvider> | ||
| </ThemeProvider>, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend to update this to renderWithProviders instead, that'll give you the needed providers out of the box
- Add totalCount prop to PaginationControlProps - Update PaginationControl to show/hide based on total items: - Hide when totalCount is 0 (empty state) - Hide when totalCount <= 5 (minimum page size) - Show when totalCount > 5 (user can adjust page size) - Show when totalCount undefined (fallback) - Pass totalCount from x-total-count header in all list components - Remove unused usePagination hook
4ef041d to
e2482d5
Compare
Summary
Fixes payroll pagination behavior based on test fest feedback where pagination options would disappear when setting a per-page amount larger than the number of people on the payroll.
Changes
PaginationControl visibility logic:
totalCountis 0 (empty state)totalCount<= 5 (minimum page size - no pagination needed)totalCount> 5 (user may want to adjust page size)totalCountis undefined (fallback to always showing when server doesn't provide count)Updates to list components:
totalCountfromx-total-countheader to PaginationControl in:Cleanup:
usePaginationhookTesting
Added unit tests for PaginationControl visibility logic covering all scenarios.