Skip to content

Commit 5747e44

Browse files
committed
fix(admin-ui): limit user to fetch
1 parent 7423e9f commit 5747e44

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

admin-ui/app/redux/api/UserApi.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ export default class UserApi {
33
this.api = api
44
}
55

6-
getUsers = () => {
6+
getUsers = (opts) => {
77
return new Promise((resolve, reject) => {
8-
this.api.getUser({}, (error, data) => {
8+
this.api.getUser(opts, (error, data) => {
99
this.handleResponse(error, reject, resolve, data)
1010
})
1111
})

admin-ui/app/redux/sagas/UserSaga.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function* getUsersSaga({ payload }) {
2828
try {
2929
addAdditionalData(audit, FETCH, API_USERS, payload)
3030
const userApi = yield* newFunction()
31-
const data = yield call(userApi.getUsers)
31+
const data = yield call(userApi.getUsers, payload.action)
3232
yield put(updateUserResponse(data))
3333
yield put(UMupdateUserLoading(false))
3434
yield call(postUserAction, audit)

admin-ui/app/routes/Dashboards/DashboardPage.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,14 @@ const useStyles = makeStyles(() => ({
256256
},
257257
}))
258258

259-
function DashboardPage({ statData, permissions, clients, loading, dispatch }) {
259+
function DashboardPage({
260+
statData,
261+
permissions,
262+
clients,
263+
loading,
264+
users,
265+
dispatch,
266+
}) {
260267
const { t } = useTranslation()
261268
const [startDate, setStartDate] = useState(subMonths(new Date(), 3))
262269
const [endDate, setEndDate] = useState(new Date())
@@ -280,8 +287,16 @@ function DashboardPage({ statData, permissions, clients, loading, dispatch }) {
280287
}, [isMobile])
281288

282289
useEffect(() => {
283-
dispatch(getUsers())
290+
let userOptions = {
291+
limit: 3,
292+
}
293+
setTimeout(() => {
294+
dispatch(getUsers(userOptions))
295+
}, 1000)
284296
}, [])
297+
useEffect(() => {
298+
console.log('abcd', users)
299+
}, [users])
285300

286301
useEffect(() => {
287302
let count = 0
@@ -659,6 +674,7 @@ const mapStateToProps = (state) => {
659674
loading: state.mauReducer.loading,
660675
clients: state.initReducer.clients,
661676
permissions: state.authReducer.permissions,
677+
users: state.userReducer.items,
662678
}
663679
}
664680

0 commit comments

Comments
 (0)