UserForm: ajout retour de validation d'API
This commit is contained in:
24
frontend/src/reducers/users.reducers.js
Normal file
24
frontend/src/reducers/users.reducers.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { CREATE_USER_FAILURE } from "../actions/user.actions";
|
||||
|
||||
const initialState = {
|
||||
byId: {},
|
||||
createUserForm: { errorCode: null },
|
||||
};
|
||||
|
||||
export function usersReducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case CREATE_USER_FAILURE:
|
||||
return handleCreateUserFailure(state, action);
|
||||
};
|
||||
return state;
|
||||
}
|
||||
|
||||
function handleCreateUserFailure(state, { error }) {
|
||||
return {
|
||||
...state,
|
||||
createUserForm: {
|
||||
...state.createUserForm,
|
||||
errorCode: error.code,
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user