import { AsyncStorage } from 'react-native';
import { NavigationActions } from 'react-navigation';

export default {
  namespace: 'welcome',
  state: { },
  reducers: {},
  effects: {
    *init(ignored, { put, call }) {
      const token = yield call(AsyncStorage.getItem, 'token');
      if (!token) {
        yield put(NavigationActions.navigate({
          routeName: 'Login',
        }));
      } else {
        yield put(NavigationActions.navigate({
          routeName: 'Main',
        }));
      }
    },
  },
};
