*logout({ payload }, { call, put }) { destroyToken() yield put({ type: 'save', payload: { user: null, isAuthenticated: false }}); yield put(routerRedux.push('/')); }
*update({ payload }, { call, put }) { const result = yield call(userService.update, payload.user); yield put({ type: 'save', payload: { user: result.data.user, isAuthenticated: true }}); yield put(routerRedux.push('/')); }
componentWillReceiveProps(nextProps) { if (nextProps.redirectTo) { // this.context.router.replace(nextProps.redirectTo); store.dispatch(push(nextProps.redirectTo)); this.props.onRedirect(); } }
componentWillReceiveProps(nextProps) { console.log(nextProps); console.log(this.context.router); // You don't have to do this check first, but it can help prevent an unneeded render if (nextProps.processing !== this.props.processing && nextProps.processing === false) { // this.props.history.push({ // pathname: "/result" // }); console.log("navigating"); this.props.dispatch(routerActions.push("/result")); } }
*register({ payload }, { call, put }) { const result = yield call(userService.register, payload); yield put({ type: 'save', payload: { user: result.data.user, isAuthenticated: true }}); saveToken(result.data.user.token); yield put(routerRedux.push('/')); }
const mapDispatchToProps = dispatch => bindActionCreators({ goBack: routerActions.goBack, goHome: () => routerActions.push('/'), }, dispatch)
*create({ payload }, { put, call }) { const result = yield call(articlesService.create, payload.article) yield put({ type: 'save', payload: payload.article}) yield put(routerRedux.push(`/article/${result.data.article.slug}`)); }
*del({ payload }, { call, put }) { yield call(articlesService.del, payload.slug); yield put({ type: 'save', payload: { article: null } }); yield put(routerRedux.push('/')); }
*logout(_, { put }) { yield put({ type: 'changeLoginStatus', payload: { status: false, currentAuthority: 'guest', }, }); reloadAuthorized(); yield put( routerRedux.push({ pathname: '/user/login', search: stringify({ redirect: window.location.href, }), }) ); }
*update({ payload }, { put, call }) { yield call(articlesService.update, payload) yield put({ type: 'save', payload: payload.article}) yield put(routerRedux.push(`/article/${payload.slug}`)); }
*submitStepForm({ payload }, { call, put }) { yield call(produceCode, payload); yield put({ type: 'saveStepFormData', payload, }); yield put(routerRedux.push('/form/step-form/result')); }
*login({ payload }, { call, put }) { const result = yield call(userService.login, payload); yield put({ type: 'save', payload: { user: result.data.user, isAuthenticated: true }}); saveToken(result.data.user.token); yield put(routerRedux.push('/')); }
*submitStepForm({ payload }, { call, put }) { yield call(produceCode, payload); yield put({ type: 'saveStepFormData', payload, }); yield put(routerRedux.push('/form/step-form/result')); }
*logout(_, { put }) { yield put({ type: 'changeLoginStatus', payload: { status: false, currentAuthority: 'guest', }, }); reloadAuthorized(); yield put( routerRedux.push({ pathname: '/user/login', search: stringify({ redirect: window.location.href, }), }) ); }