-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): add more details to user profile page #1213
- Loading branch information
1 parent
cbaf8b2
commit b8580c8
Showing
14 changed files
with
232 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createSlice } from '@reduxjs/toolkit' | ||
import reducerRegistry from 'Redux/reducers/ReducerRegistry' | ||
|
||
const initialState = { | ||
profileDetails: null, | ||
loading: false, | ||
} | ||
|
||
const profileDetailsSlice = createSlice({ | ||
name: 'profileDetails', | ||
initialState, | ||
reducers: { | ||
checkIsLoadingDetails: (state, action) => { | ||
state.loading = action.payload | ||
}, | ||
setUserProfileDetails: (state, action) => { | ||
state.profileDetails = action.payload | ||
}, | ||
getProfileDetails: () => {} | ||
}, | ||
}) | ||
|
||
export const { checkIsLoadingDetails, getProfileDetails, setUserProfileDetails } = | ||
profileDetailsSlice.actions | ||
|
||
export default profileDetailsSlice.reducer | ||
reducerRegistry.register('profileDetailsReducer', profileDetailsSlice.reducer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { all, call, fork, put, select, takeLatest } from 'redux-saga/effects' | ||
import { isFourZeroOneError, addAdditionalData } from 'Utils/TokenController' | ||
import { FETCH } from '../../audit/UserActionType' | ||
import { getAPIAccessToken } from 'Redux/features/authSlice' | ||
import { API_USERS } from 'Plugins/user-management/redux/audit/Resources' | ||
import UserApi from 'Plugins/user-management/redux/api/UserApi' | ||
import { initAudit } from 'Redux/sagas/SagaUtils' | ||
import { postUserAction } from 'Redux/api/backend-api' | ||
import { setUserProfileDetails } from 'Redux/features/ProfileDetailsSlice' | ||
import { getProfileDetails, checkIsLoadingDetails } from '../features/ProfileDetailsSlice' | ||
const JansConfigApi = require('jans_config_api') | ||
import { getClient } from 'Redux/api/base' | ||
|
||
function* newFunction() { | ||
const token = yield select((state) => state.authReducer.token.access_token) | ||
const issuer = yield select((state) => state.authReducer.issuer) | ||
const api = new JansConfigApi.ConfigurationUserManagementApi( | ||
getClient(JansConfigApi, token, issuer) | ||
) | ||
return new UserApi(api) | ||
} | ||
|
||
function* getProfileDetailsWorker({ payload }) { | ||
const audit = yield* initAudit() | ||
try { | ||
yield put(checkIsLoadingDetails(true)) | ||
addAdditionalData(audit, FETCH, API_USERS, payload) | ||
const userApi = yield* newFunction() | ||
const data = yield call(userApi.getUsers, payload) | ||
yield put(setUserProfileDetails(data?.entries?.[0])) | ||
yield call(postUserAction, audit) | ||
} catch (e) { | ||
yield put(setUserProfileDetails(null)) | ||
if (isFourZeroOneError(e)) { | ||
const jwt = yield select((state) => state.authReducer.userinfo_jwt) | ||
yield put(getAPIAccessToken(jwt)) | ||
} | ||
} finally { | ||
yield put(checkIsLoadingDetails(false)) | ||
} | ||
} | ||
|
||
//watcher sagas | ||
export function* getProfileDetailsWatcher() { | ||
yield takeLatest(getProfileDetails.toString(), getProfileDetailsWorker) | ||
} | ||
|
||
export default function* rootSaga() { | ||
yield all([fork(getProfileDetailsWatcher)]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.