Skip to content

Commit

Permalink
Merge pull request #26 from adipai/refactor-branch
Browse files Browse the repository at this point in the history
Resolved errors in email notifier
  • Loading branch information
ananya173147 authored Oct 15, 2023
2 parents 0323ba9 + a4eae4f commit 8480380
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/recommenderapp/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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) {
Expand All @@ -191,4 +207,5 @@ $(document).ready(function () {
},
});
});

});
9 changes: 9 additions & 0 deletions src/recommenderapp/templates/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ <h1>Thanks!! Your response was stored.</h1>
</form>
</div>
</div>

<!-- Add the "Email sent successfully!" message here -->
<div
id="emailSentSuccess"
style="display: none; position: absolute; top: 80px; left: 50%; transform: translateX(-50%);"
>
<h3>Email sent successfully!</h3>
</div>

</body>
<script
src="https://code.jquery.com/jquery-3.5.1.min.js"
Expand Down

0 comments on commit 8480380

Please sign in to comment.