feat(report-user) Gatsby /user/:username/report-user

This commit is contained in:
Bouncey
2018-09-07 13:32:38 +01:00
committed by Stuart Taylor
parent a9c948679e
commit c5c4f3aa41
6 changed files with 222 additions and 61 deletions

View File

@@ -0,0 +1,29 @@
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, '/');
}
export function createReportUserSaga(types) {
return [
takeEvery(types.reportUser, reportUserSaga),
takeEvery(types.reportUserComplete, acceptCompleteSaga)
];
}