Added a testing sign in method for Redux.

This commit is contained in:
Patrick Fic
2020-08-05 22:04:23 -07:00
parent 53360b1d5e
commit 481daac70c
8 changed files with 579 additions and 188 deletions

View File

@@ -1,4 +1,4 @@
// import UserActionTypes from "./user.types";
import UserActionTypes from "./user.types";
const INITIAL_STATE = {
currentUser: {
@@ -17,12 +17,6 @@ const INITIAL_STATE = {
const userReducer = (state = INITIAL_STATE, action) => {
switch (action.type) {
// case UserActionTypes.SET_LOCAL_FINGERPRINT:
// return { ...state, fingerprint: action.payload };
// case UserActionTypes.SET_INSTANCE_ID:
// return { ...state, conflict: false };
// case UserActionTypes.SET_INSTANCE_CONFLICT:
// return { ...state, conflict: true };
// case UserActionTypes.VALIDATE_PASSWORD_RESET_START:
// case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START:
// return {
@@ -42,47 +36,47 @@ const userReducer = (state = INITIAL_STATE, action) => {
// ...state,
// passwordreset: { ...state.passwordreset, success: true },
// };
// case UserActionTypes.SIGN_IN_SUCCESS:
// return {
// ...state,
// currentUser: action.payload,
// error: null,
// };
// case UserActionTypes.SIGN_OUT_SUCCESS:
// return {
// ...state,
// currentUser: { authorized: false },
// error: null,
// };
// case UserActionTypes.UNAUTHORIZED_USER:
// return {
// ...state,
// error: null,
// currentUser: { authorized: false },
// };
case UserActionTypes.SIGN_IN_SUCCESS:
return {
...state,
currentUser: action.payload,
error: null,
};
case UserActionTypes.SIGN_OUT_SUCCESS:
return {
...state,
currentUser: { authorized: false },
error: null,
};
case UserActionTypes.UNAUTHORIZED_USER:
return {
...state,
error: null,
currentUser: { authorized: false },
};
// case UserActionTypes.SET_USER_LANGUAGE:
// return {
// ...state,
// language: action.payload,
// };
// case UserActionTypes.UPDATE_USER_DETAILS_SUCCESS:
// return {
// ...state,
// currentUser: {
// ...state.currentUser,
// ...action.payload, //Spread current user details in.
// },
// };
case UserActionTypes.UPDATE_USER_DETAILS_SUCCESS:
return {
...state,
currentUser: {
...state.currentUser,
...action.payload, //Spread current user details in.
},
};
// case UserActionTypes.SET_SHOP_DETAILS:
// return { ...state, bodyshop: action.payload };
// case UserActionTypes.SIGN_IN_FAILURE:
// case UserActionTypes.SIGN_OUT_FAILURE:
// case UserActionTypes.EMAIL_SIGN_UP_FAILURE:
// return {
// ...state,
// error: action.payload,
// };
case UserActionTypes.SET_SHOP_DETAILS:
return { ...state, bodyshop: action.payload };
case UserActionTypes.SIGN_IN_FAILURE:
case UserActionTypes.SIGN_OUT_FAILURE:
case UserActionTypes.EMAIL_SIGN_UP_FAILURE:
return {
...state,
error: action.payload,
};
default:
return state;
}