(req, res)
| 2 | const { sendMailToAdmin } = require('../sendFeedbackToAdmin'); |
| 3 | |
| 4 | const submitFeedback = async (req, res) => { |
| 5 | // Extract data from the request body |
| 6 | const { |
| 7 | Name, |
| 8 | Email, |
| 9 | Subject, |
| 10 | Date, // Correctly match the field from frontend |
| 11 | Device, // Correctly match the field from frontend |
| 12 | Priority, // Correctly match the field from frontend |
| 13 | Suggestions, |
| 14 | Feedback, |
| 15 | Rating |
| 16 | } = req.body; |
| 17 | |
| 18 | |
| 19 | const feedbackData = { |
| 20 | name: Name, |
| 21 | email: Email, |
| 22 | subject: Subject, |
| 23 | dateOfVisit: Date, // Match the frontend field |
| 24 | deviceUsed: Device, // Match the frontend field |
| 25 | priorityLevel: Priority, // Match the frontend field |
| 26 | suggestions: Suggestions, |
| 27 | feedback: Feedback, |
| 28 | rating: Rating, |
| 29 | }; |
| 30 | |
| 31 | sendMailToAdmin(feedbackData) |
| 32 | |
| 33 | |
| 34 | try { |
| 35 | const feed = new FeedbackForm(feedbackData); |
| 36 | await feed.save(); |
| 37 | res.status(200).json({ status: 200, message: 'feedback form submitted successfully.' }); |
| 38 | } catch (error) { |
| 39 | console.error("Error in submitting feedback form:", error); |
| 40 | res.status(500).json({ error: "Feedback form not submitted successfully." }); |
| 41 | } |
| 42 | }; |
| 43 | |
| 44 | module.exports = { |
| 45 | submitFeedback, |
nothing calls this directly
no test coverage detected