Skip to content

Commit

Permalink
Added Email on clicking Submit
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshitGarg24 committed Jun 3, 2024
1 parent 230f8a3 commit aec3204
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Pages/FeedbackForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function FeedbackPage() {
const [rating, setRating] = useState(null);
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [feedback, setFeedback] = useState("");

const handleRatingChange = (value) => {
setRating(value);
Expand All @@ -20,9 +21,21 @@ function FeedbackPage() {
setEmail(e.target.value);
};

const handleFeedbackChange = (e) => {
setFeedback(e.target.value);
};

const handleRedirect = () => {
const subject = encodeURIComponent("Feedback and Suggestions for Improvement");
const body = encodeURIComponent(
`Name: ${name}\nEmail: ${email}\nRating: ${rating}\nFeedback: ${feedback}`
);
window.location.href = `mailto:[email protected]?subject=${subject}&body=${body}`;
};

const handleSubmit = (e) => {
e.preventDefault();
// Handle form submission
handleRedirect();
};

return (
Expand Down Expand Up @@ -110,6 +123,8 @@ function FeedbackPage() {
<textarea
id="feedback"
rows="6"
value={feedback}
onChange={handleFeedbackChange}
className="block w-full text-lg text-gray-900 dark:text-white bg-gray-100 dark:bg-gray-700 rounded-lg shadow-sm border border-gray-300 dark:border-gray-600 focus:ring-primary-500 focus:border-primary-500 p-4 mb-4"
placeholder="Let us know how we can improve..."
required
Expand Down

0 comments on commit aec3204

Please sign in to comment.