@@ -27,8 +27,10 @@ const JansConfigApi = require('jans_config_api')
27
27
import { initAudit } from '../../../../app/redux/sagas/SagaUtils'
28
28
import {
29
29
getUserResponse ,
30
- usersLoading ,
31
- redirectToListPage ,
30
+ updateUserResponse ,
31
+ deleteUserResponse ,
32
+ changeUserPasswordResponse ,
33
+ createUserResponse ,
32
34
getUsers ,
33
35
} from '../actions/UserActions'
34
36
import { postUserAction } from '../../../../app/redux/api/backend-api'
@@ -47,12 +49,9 @@ export function* createUserSaga({ payload }) {
47
49
addAdditionalData ( audit , FETCH , API_USERS , payload )
48
50
const userApi = yield * newFunction ( )
49
51
const data = yield call ( userApi . createUsers , payload )
50
- if ( data ) {
51
- yield put ( redirectToListPage ( true ) )
52
- }
53
- yield put ( usersLoading ( false ) )
52
+ yield put ( createUserResponse ( data ) )
54
53
} catch ( e ) {
55
- yield put ( usersLoading ( false ) )
54
+ yield put ( createUserResponse ( null ) )
56
55
if ( isFourZeroOneError ( e ) ) {
57
56
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
58
57
yield put ( getAPIAccessToken ( jwt ) )
@@ -65,12 +64,9 @@ export function* updateUserSaga({ payload }) {
65
64
addAdditionalData ( audit , FETCH , API_USERS , payload )
66
65
const userApi = yield * newFunction ( )
67
66
const data = yield call ( userApi . updateUsers , payload )
68
- if ( data ) {
69
- yield put ( redirectToListPage ( true ) )
70
- }
71
- yield put ( usersLoading ( false ) )
67
+ yield put ( updateUserResponse ( data ) )
72
68
} catch ( e ) {
73
- yield put ( usersLoading ( false ) )
69
+ yield put ( updateUserResponse ( null ) )
74
70
if ( isFourZeroOneError ( e ) ) {
75
71
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
76
72
yield put ( getAPIAccessToken ( jwt ) )
@@ -83,10 +79,10 @@ export function* changeUserPasswordSaga({ payload }) {
83
79
try {
84
80
addAdditionalData ( audit , FETCH , API_USERS , payload )
85
81
const userApi = yield * newFunction ( )
86
- yield call ( userApi . changeUserPassword , payload )
87
- yield put ( usersLoading ( false ) )
82
+ const data = yield call ( userApi . changeUserPassword , payload )
83
+ yield put ( changeUserPasswordResponse ( data ) )
88
84
} catch ( e ) {
89
- yield put ( usersLoading ( false ) )
85
+ yield put ( changeUserPasswordResponse ( null ) )
90
86
if ( isFourZeroOneError ( e ) ) {
91
87
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
92
88
yield put ( getAPIAccessToken ( jwt ) )
@@ -101,10 +97,9 @@ export function* getUsersSaga({ payload }) {
101
97
const userApi = yield * newFunction ( )
102
98
const data = yield call ( userApi . getUsers )
103
99
yield put ( getUserResponse ( data ) )
104
- yield put ( usersLoading ( false ) )
105
100
yield call ( postUserAction , audit )
106
101
} catch ( e ) {
107
- yield put ( usersLoading ( false ) )
102
+ yield put ( getUserResponse ( null ) )
108
103
if ( isFourZeroOneError ( e ) ) {
109
104
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
110
105
yield put ( getAPIAccessToken ( jwt ) )
@@ -117,11 +112,11 @@ export function* deleteUserSaga({ payload }) {
117
112
try {
118
113
addAdditionalData ( audit , FETCH , API_USERS , payload )
119
114
const userApi = yield * newFunction ( )
120
- yield call ( userApi . deleteUser , payload )
115
+ const data = yield call ( userApi . deleteUser , payload )
121
116
yield put ( getUsers ( { } ) )
122
- yield put ( usersLoading ( false ) )
117
+ yield put ( deleteUserResponse ( data ) )
123
118
} catch ( e ) {
124
- yield put ( usersLoading ( false ) )
119
+ yield put ( deleteUserResponse ( null ) )
125
120
if ( isFourZeroOneError ( e ) ) {
126
121
const jwt = yield select ( ( state ) => state . authReducer . userinfo_jwt )
127
122
yield put ( getAPIAccessToken ( jwt ) )
0 commit comments