Files
freeCodeCamp/client/src/redux/report-user-saga.js
Tom c52c36e51e fix: add report user button back to profile pages (#36926)
* fix: add report user button back to profile pages

* fix: make local redirect to signin work

* fix: redirect to learn instead of homepage

* fix: change from gatsby Link to the helper component Link

* feat: add tests for profile report and settings buttons

* Update client/src/client-only-routes/ShowUser.js

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* Update client/src/client-only-routes/ShowUser.js

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* Update client/src/client-only-routes/ShowUser.js

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* Update client/src/client-only-routes/ShowUser.js

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* Update client/src/client-only-routes/ShowUser.js

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2019-10-05 00:28:16 -07:00

30 lines
767 B
JavaScript

import { call, put, takeEvery } from 'redux-saga/effects';
import { navigate } from 'gatsby';
import { reportUserComplete, reportUserError } from './';
import { createFlashMessage } from '../components/Flash/redux';
import { postReportUser } from '../utils/ajax';
function* reportUserSaga({ payload }) {
try {
const { data: response } = yield call(postReportUser, payload);
yield put(reportUserComplete());
yield put(createFlashMessage(response));
} catch (e) {
yield put(reportUserError(e));
}
}
function* acceptCompleteSaga() {
yield call(navigate, '/learn');
}
export function createReportUserSaga(types) {
return [
takeEvery(types.reportUser, reportUserSaga),
takeEvery(types.reportUserComplete, acceptCompleteSaga)
];
}