refactor: simplify user API calls by removing pageSize parameter in multiple components
This commit is contained in:
+2
-2
@@ -89,11 +89,11 @@ export function RegionManageEntrySheet({ open, onClose, onSuccess, initial }: Re
|
||||
|
||||
Promise.all([
|
||||
regionsApi.list({ page: 1, pageSize: 200 }),
|
||||
usersApi.list({ page: 1, pageSize: 200 }),
|
||||
usersApi.list(),
|
||||
])
|
||||
.then(([r, u]) => {
|
||||
setRegionsList(getPaginatedItems(r).filter((x) => x.isActive))
|
||||
setAgencyUsers(getPaginatedItems(u).filter((x) => x.roleName === 'RegionalAgency'))
|
||||
setAgencyUsers(u.filter((x) => x.roleName === 'RegionalAgency'))
|
||||
})
|
||||
.catch((err) => toast.add({ title: 'Failed to load reference data', description: getApiError(err), type: 'error' }))
|
||||
}, [open, initial])
|
||||
|
||||
+2
-2
@@ -81,8 +81,8 @@ export function RegionManageListClient() {
|
||||
}, [fetchData])
|
||||
|
||||
useEffect(() => {
|
||||
usersApi.list({ page: 1, pageSize: 200 })
|
||||
.then((res) => setAgencyUsers(getPaginatedItems(res)))
|
||||
usersApi.list()
|
||||
.then((res) => setAgencyUsers(res))
|
||||
.catch(() => toast.add({ title: 'Failed to load users', type: 'error' }))
|
||||
}, [])
|
||||
|
||||
|
||||
+2
-2
@@ -45,13 +45,13 @@ export function RegionManagerDialog({ open, onClose, region }: RegionManagerDial
|
||||
setCurrent(null)
|
||||
Promise.all([
|
||||
regionsApi.getManager(region.id).catch(() => null), // 404 = no manager yet
|
||||
usersApi.list({ pageSize: 500 }),
|
||||
usersApi.list(),
|
||||
])
|
||||
.then(([manager, userRes]) => {
|
||||
if (cancelled) return
|
||||
setCurrent(manager)
|
||||
setSelected(manager?.userId ?? '')
|
||||
setCandidates(getPaginatedItems(userRes).filter((u) => u.isActive && u.roleName === MANAGER_ROLE))
|
||||
setCandidates(userRes.filter((u) => u.isActive && u.roleName === MANAGER_ROLE))
|
||||
})
|
||||
.catch((err) => toast.add({ title: 'Failed to load users', description: getApiError(err), type: 'error' }))
|
||||
.finally(() => !cancelled && setLoading(false))
|
||||
|
||||
@@ -46,8 +46,8 @@ export function RouteManageSheet({ open, onClose, route, onSuccess }: RouteManag
|
||||
setOwnerUserId(route.ownerUserId ?? '')
|
||||
setStoreFilter('')
|
||||
|
||||
usersApi.list({ page: 1, pageSize: 200 })
|
||||
.then((res) => setSalesReps(getPaginatedItems(res).filter((u) => u.roleName === 'SalesRep')))
|
||||
usersApi.list()
|
||||
.then((res) => setSalesReps(res.filter((u) => u.roleName === 'SalesRep')))
|
||||
.catch(() => toast.add({ title: 'Failed to load sales reps', type: 'error' }))
|
||||
|
||||
storesApi.list({ page: 1, pageSize: 200 })
|
||||
|
||||
@@ -46,10 +46,10 @@ export function RoutesClient() {
|
||||
}, [fetchData, page, pageSize])
|
||||
|
||||
useEffect(() => {
|
||||
usersApi.list({ page: 1, pageSize: 200 })
|
||||
usersApi.list()
|
||||
.then((res) => {
|
||||
const map: Record<string, string> = {}
|
||||
for (const u of getPaginatedItems(res)) map[u.id] = u.fullName
|
||||
for (const u of res) map[u.id] = u.fullName
|
||||
setUserNameById(map)
|
||||
})
|
||||
.catch(() => toast.add({ title: 'Failed to load users', type: 'error' }))
|
||||
|
||||
Reference in New Issue
Block a user