/**
 * React Native Full App (https://store.enappd.com/product/react-native-full-app)
 *
 * Copyright © 2019-present Enappd. All rights reserved.
 *
 * This source code is licensed as per the terms found in the
 * LICENSE.md file in the root directory of this source tree.
 */
import { GET_PHONE_NUMBER, SET_VERIFICATION_CODE, LOGIN_USER } from "../types/Authentication";

const INITIAL_STATE: AuthenticationReducerState = {
    phoneNumber: '',
    verificationCode: '',
    userLoggedIn: false
  };

interface AuthenticationReducerState {
    phoneNumber: string;
    verificationCode: string;
    userLoggedIn: boolean;
}
  
  export default function (state = INITIAL_STATE, action:any): AuthenticationReducerState {
    switch (action.type) {
      case GET_PHONE_NUMBER:
        return { ...state, phoneNumber: action.payload };
      case SET_VERIFICATION_CODE:
        return { ...state, verificationCode: action.payload };
      case LOGIN_USER:
        return { ...state, userLoggedIn: action.payload };
      default :
        return state
    }
  };