import {ActionType} from 'constants';

const initialState = {
  data: undefined,
  userToken: undefined,
};

export default (state = initialState, action) => {
  let newState = {...state};
  switch (action.type) {
    case ActionType.SIGN_IN:
      newState.userToken = action.payload.token;
      newState.data = action.payload.user;
      return newState;
    case ActionType.SIGN_OUT:
      newState.userToken = undefined;
      newState.data = undefined;
      return newState;
    default:
      return state;
  }
};
