From a4eae4fda07ab4cc3681a4ff2d4b1895e8008c77 Mon Sep 17 00:00:00 2001 From: rishi2019194 <58341663+rishi2019194@users.noreply.github.com> Date: Sun, 15 Oct 2023 19:55:54 -0400 Subject: [PATCH] Resolved error for sending multiple email notifications and added email sent success msg --- src/recommenderapp/static/script.js | 21 +++++++++++++++++++-- src/recommenderapp/templates/success.html | 9 +++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/recommenderapp/static/script.js b/src/recommenderapp/static/script.js index 9c24a404f..b410dc5b2 100644 --- a/src/recommenderapp/static/script.js +++ b/src/recommenderapp/static/script.js @@ -170,9 +170,19 @@ $(document).ready(function () { }); $("#notifyButton").click(function () { - data = JSON.parse(localStorage.getItem("fbData")); + var data = JSON.parse(localStorage.getItem("fbData")); + + if (!data) { + alert("No feedback data found. Please provide feedback."); + return; + } + var emailString = $("#emailField").val(); data.email = emailString; + + // Remove the "emailSent" flag to allow sending the email again + localStorage.removeItem("emailSent"); + $.ajax({ type: "POST", url: "/sendMail", @@ -182,7 +192,13 @@ $(document).ready(function () { cache: false, data: JSON.stringify(data), success: function (response) { - localStorage.removeItem("fbData"); + // localStorage.removeItem("fbData"); + $("#emailSentSuccess").show(); + // Hide the success message after 5 seconds (5000 milliseconds) + setTimeout(function () { + $("#emailSentSuccess").fadeOut("slow"); + }, 2000); + console.log("Email sent successfully!") console.log(response); }, error: function (error) { @@ -191,4 +207,5 @@ $(document).ready(function () { }, }); }); + }); diff --git a/src/recommenderapp/templates/success.html b/src/recommenderapp/templates/success.html index 94c48ad91..9993a69d6 100644 --- a/src/recommenderapp/templates/success.html +++ b/src/recommenderapp/templates/success.html @@ -65,6 +65,15 @@

Thanks!! Your response was stored.

+ + + +