Skip to content
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
3 changes: 1 addition & 2 deletions backend/models/Feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ const Schema = mongoose.Schema;

const FeedbackSchema = new Schema({
userId: {
type: String,
required: true
type: String
},
rating: {
type: Number,
Expand Down
17 changes: 9 additions & 8 deletions backend/routes/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -139,6 +142,18 @@ function App() {
<Route path="/leetcode/:leetUser" element={<LeetCode />} />
<Route path="/feedback" element={<FeedbackReviewPage />} />
</Routes>
<ToastContainer
position="bottom-right"
autoClose={5000}
hideProgressBar={false}
newestOnTop={false}
closeOnClick
rtl={false}
pauseOnFocusLoss
draggable
pauseOnHover
theme="dark"
/>
</TimerProvider>
);
}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/Components/feedback/FeedbackController.jsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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.");
}
};

Expand Down
16 changes: 15 additions & 1 deletion frontend/src/Components/feedback/FeedbackPopup.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect ,useState } from "react";
import {
Dialog,
DialogContent,
Expand Down Expand Up @@ -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: "" });
Expand Down
25 changes: 24 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions package.json

This file was deleted.