import { NavigationActions } from 'react-navigation';

export default {
  namespace: 'login',
  state: {
    name: '',
    password: '',
  },
  reducers: {
    setName(state, { payload }) {
      return {
        ...state,
        name: payload,
      };
    },
    setPassword(state, { payload }) {
      return {
        ...state,
        password: payload,
      };
    },
  },
  effects: {
    *login(ignored, { put }) {
      yield put(NavigationActions.navigate({
        routeName: 'Main',
      }));
    },
  },
};
