Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove passThroughFeedback #1298

Merged
merged 8 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions src/app/controllers/admin-forms.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,6 @@ function makeModule(connection) {
}
return next()
},
/**
* Submit feedback when previewing forms
* Preview feedback is not stored
* @param {Object} req - Express request object
* @param {Object} res - Express response object
*/
passThroughFeedback: function (req, res) {
if (
!req.params ||
!('formId' in req.params) ||
!req.body ||
!('rating' in req.body) ||
!('comment' in req.body)
) {
return res
.status(StatusCodes.BAD_REQUEST)
.json({ message: 'Form feedback data not passed in' })
} else {
return res
.status(StatusCodes.OK)
.json({ message: 'Successfully received feedback' })
}
},
/**
* Pass through save new Submission object to db
* Simply create and pass forward a submissions object w/o saving to db
Expand Down
13 changes: 0 additions & 13 deletions src/app/routes/admin-forms.server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,9 @@ module.exports = function (app) {
* @returns {FeedbackResponse.model} 200 - form feedback was saved
* @security OTP
*/
/**
* On preview, mock sending of feedback
* @route POST /{formId}/adminform/feedback
* @group forms - endpoints to serve forms
* @param {string} formId.path.required - the form id
* @param {Feedback.model} feedback.body.required - the user's feedback
* @consumes application/json
* @produces application/json
* @returns {string} 400 - form feedback was malformed
* @returns {string} 200 - form feedback was received
*/

app
.route('/:formId([a-fA-F0-9]{24})/adminform/feedback')
.get(withUserAuthentication, AdminFormController.handleGetFormFeedbacks)
.post(authActiveForm(PermissionLevel.Read), adminForms.passThroughFeedback)

/**
* Count the number of feedback for a form
Expand Down
25 changes: 13 additions & 12 deletions src/public/modules/forms/services/form-feedback.client.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ function FormFeedback($q, $http) {
const feedbackAdminUrl = '/:formId/adminform/feedback'
let feedbackService = {
postFeedback: function (params, body) {
karrui marked this conversation as resolved.
Show resolved Hide resolved
let resUrl = fixParamsToUrl(
params,
body.isPreview ? feedbackAdminUrl : resourceUrl,
)
let deferred = $q.defer()
$http.post(resUrl, body).then(
function () {
deferred.resolve('Successfully posted feedback.')
},
function (_errorResponse) {
deferred.reject('Failed to post feedback.')
},
)
if (body.isPreview) {
deferred.resolve('Successfully posted feedback.')
} else {
let resUrl = fixParamsToUrl(params, resourceUrl)
$http.post(resUrl, body).then(
function () {
deferred.resolve('Successfully posted feedback.')
},
function (_errorResponse) {
deferred.reject('Failed to post feedback.')
},
)
}
return deferred.promise
},
getFeedback: function (params) {
Expand Down