Skip to content

Commit fcf3ba0

Browse files
committed
fix(admin-ui): add attribute slice actions
1 parent 82047a1 commit fcf3ba0

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

admin-ui/app/redux/features/attributesSlice.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import unionBy from 'lodash/unionBy'
44

55
const initialState = {
66
items: [],
7-
loading: false
7+
loading: false,
8+
initLoading: true
89
}
910

1011
const attributesSlice = createSlice({
@@ -20,11 +21,14 @@ const attributesSlice = createSlice({
2021
if (data) {
2122
state.items = unionBy(data.entries, state.items, 'displayName')
2223
}
24+
},
25+
toggleInitAttributeLoader: (state, action) => {
26+
state.initLoading = action.payload
2327
}
2428
}
2529
})
2630

27-
export const { getAttributesRoot, getAttributesResponseRoot } =
31+
export const { getAttributesRoot, getAttributesResponseRoot, toggleInitAttributeLoader } =
2832
attributesSlice.actions
2933

3034
export default attributesSlice.reducer

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { call, all, put, fork, takeLatest, select } from 'redux-saga/effects'
22
import { isFourZeroOneError, addAdditionalData } from 'Utils/TokenController'
33
import {
4-
getAttributesResponseRoot
4+
getAttributesResponseRoot,
5+
toggleInitAttributeLoader
56
} from '../features/attributesSlice'
67
import { getAPIAccessToken } from 'Redux/features/authSlice'
78
import { postUserAction } from 'Redux/api/backend-api'
@@ -28,6 +29,9 @@ function* newFunction() {
2829

2930
export function* getAttributesRoot({ payload }) {
3031
const audit = yield* initAudit()
32+
if(payload.init) {
33+
yield put(toggleInitAttributeLoader(true))
34+
}
3135
try {
3236
addAdditionalData(audit, FETCH, PERSON_SCHEMA, payload)
3337
const attributeApi = yield* newFunction()
@@ -40,6 +44,8 @@ export function* getAttributesRoot({ payload }) {
4044
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
4145
yield put(getAPIAccessToken(jwt))
4246
}
47+
} finally {
48+
yield put(toggleInitAttributeLoader(false))
4349
}
4450
}
4551

0 commit comments

Comments
 (0)