Skip to content

Commit

Permalink
fix: reset pagination to page 1 when location changes (#7043)
Browse files Browse the repository at this point in the history
* Fix: Reset pagination to page 1 when location changes

Ensure the currentPageNumber is reset to 1 whenever the location parameter changes to avoid issues where no data is found and the table and pagination components disappear.

* changelog updated
  • Loading branch information
tareq89 committed Jun 7, 2024
1 parent 66011d2 commit 545229b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
- Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016)
- Fix Check for valid date to handle incomplete marriage declarations [#7017](https://github.com/opencrvs/opencrvs-core/issues/7017)
- Fix French translation missing for relationship to informant when trying to correct record, print and issue record [#6341] (https://github.com/opencrvs/opencrvs-core/issues/6341)
- Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893)
- Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016)
- Fix Reset pagination to default page (1) when location changes in UserList [#6481](https://github.com/opencrvs/opencrvs-core/issues/6481)
- Fix client modal glitches on integrations page [#7002](https://github.com/opencrvs/opencrvs-core/issues/7002)
- Fix "Print and issue to groom|bride" is added to a different variable [#7066](https://github.com/opencrvs/opencrvs-core/pull/7066)
- Fix Removed duplicateTrackingId check in createDuplicateTask method [#7081](https://github.com/opencrvs/opencrvs-core/pull/7081)
- Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893)
- Fix Reset pagination to default page (1) when location changes in UserList [#6481](https://github.com/opencrvs/opencrvs-core/issues/6481)
- Fix client modal glitches on integrations page [#7002] (https://github.com/opencrvs/opencrvs-core/issues/7002)

## Refactor

Expand Down
6 changes: 5 additions & 1 deletion packages/client/src/views/SysAdmin/Team/user/UserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ import { getLocalizedLocationName } from '@client/utils/locationUtils'
import { HOME } from '@client/navigation/routes'

const DEFAULT_FIELD_AGENT_LIST_SIZE = 10
const DEFAULT_PAGE_NUMBER = 1

const { useState } = React

const UserTable = styled(BodyContent)`
Expand Down Expand Up @@ -269,7 +271,8 @@ function UserListComponent(props: IProps) {
selectedUser: null
})

const [currentPageNumber, setCurrentPageNumber] = useState<number>(1)
const [currentPageNumber, setCurrentPageNumber] =
useState<number>(DEFAULT_PAGE_NUMBER)
const recordCount = DEFAULT_FIELD_AGENT_LIST_SIZE * currentPageNumber
const searchedLocation: ILocation | undefined = offlineOffices.find(
({ id }) => locationId === id
Expand Down Expand Up @@ -633,6 +636,7 @@ function UserListComponent(props: IProps) {
selectedLocationId={locationId}
onChangeLocation={(locationId) => {
props.goToTeamUserList(locationId)
setCurrentPageNumber(DEFAULT_PAGE_NUMBER)
}}
requiredLocationTypes={'CRVS_OFFICE'}
/>
Expand Down

0 comments on commit 545229b

Please sign in to comment.