Unverified Commit bb71bd70 authored by Paul Kaplan's avatar Paul Kaplan Committed by GitHub

Merge pull request #2190 from paulkaplan/move-report-to-api

Use the proper API route for reporting projects
parents 95d088f5 85f13935
...@@ -657,7 +657,7 @@ module.exports.reportComment = (projectId, commentId, topLevelCommentId, token) ...@@ -657,7 +657,7 @@ module.exports.reportComment = (projectId, commentId, topLevelCommentId, token)
}); });
}); });
module.exports.reportProject = (id, jsonData) => (dispatch => { module.exports.reportProject = (id, jsonData, token) => (dispatch => {
dispatch(module.exports.setFetchStatus('report', module.exports.Status.FETCHING)); dispatch(module.exports.setFetchStatus('report', module.exports.Status.FETCHING));
// scratchr2 will fail if no thumbnail base64 string provided. We don't yet have // scratchr2 will fail if no thumbnail base64 string provided. We don't yet have
// a way to get the actual project thumbnail in www/gui, so for now just submit // a way to get the actual project thumbnail in www/gui, so for now just submit
...@@ -667,11 +667,12 @@ module.exports.reportProject = (id, jsonData) => (dispatch => { ...@@ -667,11 +667,12 @@ module.exports.reportProject = (id, jsonData) => (dispatch => {
'0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=' '0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII='
}); });
api({ api({
host: '', uri: `/proxy/projects/${id}/report`,
uri: `/site-api/projects/all/${id}/report/`, authentication: token,
withCredentials: true,
method: 'POST', method: 'POST',
json: jsonData, useCsrf: true,
useCsrf: true json: jsonData
}, (err, body, res) => { }, (err, body, res) => {
if (err || res.statusCode !== 200) { if (err || res.statusCode !== 200) {
dispatch(module.exports.setFetchStatus('report', module.exports.Status.ERROR)); dispatch(module.exports.setFetchStatus('report', module.exports.Status.ERROR));
......
...@@ -199,7 +199,7 @@ class Preview extends React.Component { ...@@ -199,7 +199,7 @@ class Preview extends React.Component {
this.setState({addToStudioOpen: false}); this.setState({addToStudioOpen: false});
} }
handleReportSubmit (formData) { handleReportSubmit (formData) {
this.props.reportProject(this.state.projectId, formData); this.props.reportProject(this.state.projectId, formData, this.props.user.token);
} }
handlePopState () { handlePopState () {
const path = window.location.pathname.toLowerCase(); const path = window.location.pathname.toLowerCase();
...@@ -612,8 +612,8 @@ const mapDispatchToProps = dispatch => ({ ...@@ -612,8 +612,8 @@ const mapDispatchToProps = dispatch => ({
setLovedStatus: (loved, id, username, token) => { setLovedStatus: (loved, id, username, token) => {
dispatch(previewActions.setLovedStatus(loved, id, username, token)); dispatch(previewActions.setLovedStatus(loved, id, username, token));
}, },
reportProject: (id, formData) => { reportProject: (id, formData, token) => {
dispatch(previewActions.reportProject(id, formData)); dispatch(previewActions.reportProject(id, formData, token));
}, },
setOriginalInfo: info => { setOriginalInfo: info => {
dispatch(previewActions.setOriginalInfo(info)); dispatch(previewActions.setOriginalInfo(info));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment