Created
January 11, 2023 14:11
-
-
Save jhaashutosh/b7b94408decc157349d4a613240a9f01 to your computer and use it in GitHub Desktop.
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
import { | |
USER_LOGIN_FAIL, | |
USER_LOGIN_REQUEST, | |
USER_LOGIN_SUCCESS, | |
USER_LOGOUT, | |
USER_PROFILE_FAIL, | |
USER_PROFILE_REQUEST, | |
USER_PROFILE_RESET, | |
USER_PROFILE_SUCCESS, | |
USER_REGISTER_FAIL, | |
USER_REGISTER_REQUEST, | |
USER_REGISTER_SUCCESS, | |
USER_UPDATE_PROFILE_FAIL, | |
USER_UPDATE_PROFILE_REQUEST, | |
USER_UPDATE_PROFILE_RESET, | |
USER_UPDATE_PROFILE_SUCCESS, | |
} from "../constants/userConstants"; | |
export const userLoginReducer = (state = {}, action) => { | |
switch (action.type) { | |
case USER_LOGIN_REQUEST: | |
return { loading: true }; | |
case USER_LOGIN_SUCCESS: | |
return { loading: false, userInfo: action.payload }; | |
case USER_LOGIN_FAIL: | |
return { loading: false, error: action.payload }; | |
case USER_LOGOUT: | |
return {}; | |
default: | |
return state; | |
} | |
}; | |
export const userRegisterReducer = (state = {}, action) => { | |
switch (action.type) { | |
case USER_REGISTER_REQUEST: | |
return { loading: true }; | |
case USER_REGISTER_SUCCESS: | |
return { loading: false, userInfo: action.payload }; | |
case USER_REGISTER_FAIL: | |
return { loading: false, error: action.payload }; | |
default: | |
return state; | |
} | |
}; | |
export const userProfileReducer = (state = {}, action) => { | |
switch (action.type) { | |
case USER_PROFILE_REQUEST: | |
return { loading: true }; | |
case USER_PROFILE_SUCCESS: | |
return { loading: false, user: action.payload }; | |
case USER_PROFILE_FAIL: | |
return { loading: false, error: action.payload }; | |
case USER_PROFILE_RESET: | |
return {}; | |
default: | |
return state; | |
} | |
}; | |
export const userUpdateProfileReducer = (state = {}, action) => { | |
switch (action.type) { | |
case USER_UPDATE_PROFILE_REQUEST: | |
return { loading: true }; | |
case USER_UPDATE_PROFILE_SUCCESS: | |
return { loading: false, success: true, userInfo: action.payload }; | |
case USER_UPDATE_PROFILE_FAIL: | |
return { loading: false, error: action.payload }; | |
case USER_UPDATE_PROFILE_RESET: | |
return {}; | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment