Nettoyage des erreurs du formulaire de création d'utilisateur
This commit is contained in:
parent
e76c728e13
commit
7bc10ae2b9
|
@ -1,4 +1,4 @@
|
||||||
import { CREATE_USER_FAILURE } from '../actions/user.actions';
|
import { CREATE_USER_FAILURE, CREATE_USER_REQUEST, CREATE_USER_SUCCESS } from '../actions/user.actions';
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
byId: {},
|
byId: {},
|
||||||
|
@ -7,12 +7,23 @@ const initialState = {
|
||||||
|
|
||||||
export function usersReducer(state = initialState, action) {
|
export function usersReducer(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
|
case CREATE_USER_REQUEST:
|
||||||
|
return handleCreateUserRequest(state, action);
|
||||||
case CREATE_USER_FAILURE:
|
case CREATE_USER_FAILURE:
|
||||||
return handleCreateUserFailure(state, action);
|
return handleCreateUserFailure(state, action);
|
||||||
|
case CREATE_USER_SUCCESS:
|
||||||
|
return handleCreateUserSuccess(state, action);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleCreateUserRequest(state, action) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
createUserForm: { errorCode: null }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function handleCreateUserFailure(state, { error }) {
|
function handleCreateUserFailure(state, { error }) {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
@ -21,4 +32,11 @@ function handleCreateUserFailure(state, { error }) {
|
||||||
errorCode: error.code,
|
errorCode: error.code,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCreateUserSuccess(state, action) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
createUserForm: { errorCode: null }
|
||||||
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue