lazharkarem / LaLocative

0 stars 0 forks source link

Add Reducer #22

Open lazharkarem opened 2 years ago

lazharkarem commented 2 years ago
const loginReducer = (prevState, action)=>{
  switch (action.type) {
    case 'RETRIEVE_TOKEN':
      return {
        ... prevState,
        isLoading:false,
      };
    case 'LOGIN':
      return {
        ... prevState,
        userName: action.id,
        userToken:action.token,
        isLoading:false,
      };
    case 'LOGOUT':
      return {
        ... prevState,
        userName: null,
        userToken: null,
        isLoading:false,
      };
    case 'REGISTER':
      return {
        ... prevState,
        userName: action.id,
        userToken:action.token,
        isLoading:false,
      };
  }