Skip to content

Conversation

@jeffredodd
Copy link
Contributor

@jeffredodd jeffredodd commented Jan 8, 2026

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:

  • Hide when totalCount is 0 (empty state)
  • Hide when totalCount <= 5 (minimum page size - no pagination needed)
  • Show when totalCount > 5 (user may want to adjust page size)
  • Show when totalCount is undefined (fallback to always showing when server doesn't provide count)

Updates to list components:

  • Pass totalCount from x-total-count header to PaginationControl in:
    • EmployeeList
    • ContractorList
    • LocationsList
    • PayrollConfiguration

Cleanup:

  • Removed unused usePagination hook

Testing

Added unit tests for PaginationControl visibility logic covering all scenarios.

@jeffredodd jeffredodd force-pushed the jdj/payroll-total-count-fix branch from c59a8a5 to 4ef041d Compare January 8, 2026 18:20
@jeffredodd jeffredodd marked this pull request as ready for review January 8, 2026 18:26
Copilot AI review requested due to automatic review settings January 8, 2026 18:26
Copy link
Contributor

Copilot AI left a 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 PaginationControl based on totalCount
  • Updated list components to pass totalCount to pagination controls
  • Removed unused usePagination hook 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.

Copy link
Member

@serikjensen serikjensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Comment on lines +21 to +27
return render(
<ThemeProvider>
<ComponentsProvider value={defaultComponents}>
<PaginationControl {...basePaginationProps} {...props} />
</ComponentsProvider>
</ThemeProvider>,
)
Copy link
Member

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
@jeffredodd jeffredodd force-pushed the jdj/payroll-total-count-fix branch from 4ef041d to e2482d5 Compare January 8, 2026 19:03
@jeffredodd jeffredodd enabled auto-merge (squash) January 8, 2026 19:03
@jeffredodd jeffredodd merged commit 9cad161 into main Jan 8, 2026
6 checks passed
@jeffredodd jeffredodd deleted the jdj/payroll-total-count-fix branch January 8, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants