From 7bc10ae2b913ac37d6d7dfefad6506d1801e7a74 Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 26 Mar 2020 11:21:43 +0100 Subject: [PATCH] =?UTF-8?q?Nettoyage=20des=20erreurs=20du=20formulaire=20d?= =?UTF-8?q?e=20cr=C3=A9ation=20d'utilisateur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/reducers/users.reducers.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/frontend/src/reducers/users.reducers.js b/frontend/src/reducers/users.reducers.js index dba3c20..dd45963 100644 --- a/frontend/src/reducers/users.reducers.js +++ b/frontend/src/reducers/users.reducers.js @@ -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 = { byId: {}, @@ -7,12 +7,23 @@ const initialState = { export function usersReducer(state = initialState, action) { switch(action.type) { + case CREATE_USER_REQUEST: + return handleCreateUserRequest(state, action); case CREATE_USER_FAILURE: return handleCreateUserFailure(state, action); + case CREATE_USER_SUCCESS: + return handleCreateUserSuccess(state, action); } return state; } +function handleCreateUserRequest(state, action) { + return { + ...state, + createUserForm: { errorCode: null } + }; +} + function handleCreateUserFailure(state, { error }) { return { ...state, @@ -21,4 +32,11 @@ function handleCreateUserFailure(state, { error }) { errorCode: error.code, } }; +} + +function handleCreateUserSuccess(state, action) { + return { + ...state, + createUserForm: { errorCode: null } + }; } \ No newline at end of file