import {combineReducers} from 'redux';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {ActionType} from 'constants';

import AuthReducer from './auth-reducer';

const appReducer = combineReducers({
  auth: AuthReducer,
});

const rootReducer = (state, action) => {
  if (action.type === ActionType.SIGN_OUT) {
    AsyncStorage.removeItem('persist:root');
    state = undefined;
  }
  return appReducer(state, action);
};

export default rootReducer;
