From 3958c1566f4c5fac2964da3bf41c6b0558f95c72 Mon Sep 17 00:00:00 2001 From: kmanish527 Date: Wed, 29 Oct 2025 11:42:37 +0530 Subject: [PATCH 1/2] feedback popup update --- backend/models/Feedback.js | 3 +-- backend/routes/feedback.js | 17 +++++++------ frontend/src/App.jsx | 15 +++++++++++ .../feedback/FeedbackController.jsx | 5 ++-- .../src/Components/feedback/FeedbackPopup.jsx | 16 +++++++++++- package-lock.json | 25 ++++++++++++++++++- package.json | 3 ++- 7 files changed, 69 insertions(+), 15 deletions(-) diff --git a/backend/models/Feedback.js b/backend/models/Feedback.js index 0faaa6b..9f7494f 100644 --- a/backend/models/Feedback.js +++ b/backend/models/Feedback.js @@ -3,8 +3,7 @@ const Schema = mongoose.Schema; const FeedbackSchema = new Schema({ userId: { - type: String, - required: true + type: String }, rating: { type: Number, diff --git a/backend/routes/feedback.js b/backend/routes/feedback.js index 00f3121..b926540 100644 --- a/backend/routes/feedback.js +++ b/backend/routes/feedback.js @@ -19,16 +19,17 @@ router.post('/', auth, async (req, res) => { return res.status(400).json({ message: 'Please provide feedback with at least 10 characters' }); } - // Create a new feedback instance - const newFeedback = new Feedback({ - userId: req.user.id, +    const feedbackData = { rating, comment, - category: category || 'other', - isAnonymous: isAnonymous || false - }); - - // Save the feedback to the database + category: category || "other", + isAnonymous: isAnonymous || false, + }; + + if (!feedbackData.isAnonymous) { + feedbackData.userId = req.user.id; + } + const newFeedback = new Feedback(feedbackData); await newFeedback.save(); res.json({ success: true, message: 'Feedback submitted successfully' }); diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index b14df54..e5ae97d 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -30,6 +30,9 @@ import LeetCode from "./Components/DashBoard/LeetCode"; import FloatingSupportButton from "./Components/ui/Support"; import FeedbackReviewPage from "./Components/feedback/FeedbackReviewPage"; +import 'react-toastify/dist/ReactToastify.css'; +import { ToastContainer } from 'react-toastify'; + function Home() { const [showTop, setShowTop] = useState(false); @@ -139,6 +142,18 @@ function App() { } /> } /> + ); } diff --git a/frontend/src/Components/feedback/FeedbackController.jsx b/frontend/src/Components/feedback/FeedbackController.jsx index 3e8b53c..a6b66fe 100644 --- a/frontend/src/Components/feedback/FeedbackController.jsx +++ b/frontend/src/Components/feedback/FeedbackController.jsx @@ -1,6 +1,7 @@ import React, { useEffect, useRef } from "react"; import FeedbackPopup from "./FeedbackPopup"; import { useFeedback } from "../../context/FeedbackContext"; +import { toast } from 'react-toastify'; const FEEDBACK_INTERVAL_DAYS = 5; // Number of days between feedback prompts const FEEDBACK_STORAGE_KEY = "devSync_feedback_state"; @@ -125,11 +126,11 @@ export default function FeedbackController({ user }) { ); // Show success message - alert("Thank you for your feedback!"); + toast.success("Thank you for your feedback!"); } catch (error) { console.error("Error submitting feedback:", error); - alert("Failed to submit feedback. Please try again later."); + toast.success("Failed to submit feedback. Please try again later."); } }; diff --git a/frontend/src/Components/feedback/FeedbackPopup.jsx b/frontend/src/Components/feedback/FeedbackPopup.jsx index f0f1f52..82cffb0 100644 --- a/frontend/src/Components/feedback/FeedbackPopup.jsx +++ b/frontend/src/Components/feedback/FeedbackPopup.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect ,useState } from "react"; import { Dialog, DialogContent, @@ -29,6 +29,20 @@ export default function FeedbackPopup({ open, onOpenChange, onSubmit, userInfo } const [isAnonymous, setIsAnonymous] = useState(false); const [errors, setErrors] = useState({ rating: "", comment: "" }); + const resetForm = () => { + setRating(0); + setComment(""); + setCategory("other"); + setIsAnonymous(false); + setErrors({ rating: "", comment: "" }); + }; + + useEffect(() => { + if (open) { + resetForm(); + } + }, [open]); + const handleRatingChange = (value) => { setRating(value); if (errors.rating) setErrors({ ...errors, rating: "" }); diff --git a/package-lock.json b/package-lock.json index cd51095..126ff2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "@pinecone-database/pinecone": "^6.1.2", "cors": "^2.8.5", "dotenv": "^17.2.3", - "node-fetch": "^3.3.2" + "node-fetch": "^3.3.2", + "react-toastify": "^11.0.5" } }, "node_modules/@octokit/auth-token": { @@ -181,6 +182,15 @@ "integrity": "sha512-q6tR3RPqIB1pMiTRMFcZwuG5T8vwp+vUvEG0vuI6B+Rikh5BfPp2fQ82c925FOs+b0lcFQ8CFrL+KbilfZFhOQ==", "license": "Apache-2.0" }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/cors": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", @@ -313,6 +323,19 @@ "node": ">=0.10.0" } }, + "node_modules/react-toastify": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-11.0.5.tgz", + "integrity": "sha512-EpqHBGvnSTtHYhCPLxML05NLY2ZX0JURbAdNYa6BUkk+amz4wbKBQvoKQAB0ardvSarUBuY4Q4s1sluAzZwkmA==", + "license": "MIT", + "dependencies": { + "clsx": "^2.1.1" + }, + "peerDependencies": { + "react": "^18 || ^19", + "react-dom": "^18 || ^19" + } + }, "node_modules/universal-user-agent": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz", diff --git a/package.json b/package.json index 1276f84..7c17d88 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "@pinecone-database/pinecone": "^6.1.2", "cors": "^2.8.5", "dotenv": "^17.2.3", - "node-fetch": "^3.3.2" + "node-fetch": "^3.3.2", + "react-toastify": "^11.0.5" } } From 465bb29201dd7aedaa1523aa4970407f9edb18c4 Mon Sep 17 00:00:00 2001 From: K MANISH <126870907+kmanish527@users.noreply.github.com> Date: Wed, 29 Oct 2025 22:23:52 +0530 Subject: [PATCH 2/2] Delete package.json --- package.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 package.json diff --git a/package.json b/package.json deleted file mode 100644 index 7c17d88..0000000 --- a/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "dependencies": { - "@octokit/rest": "^22.0.0", - "@pinecone-database/pinecone": "^6.1.2", - "cors": "^2.8.5", - "dotenv": "^17.2.3", - "node-fetch": "^3.3.2", - "react-toastify": "^11.0.5" - } -}