Skip to content

Commit

Permalink
removed email modal (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
filopedraz authored Nov 4, 2024
1 parent 64b3072 commit 42dfe78
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 332 deletions.
53 changes: 0 additions & 53 deletions _static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,3 @@ function getCookie(cname) {
}
return "";
}

document.addEventListener('DOMContentLoaded', function() {
// Show the email modal if the user has not entered their email
let modal = document.getElementById('email-modal');
let emailCookie = getCookie("email");
let emailInput = document.getElementById("email-input");
let body = document.body
if (emailCookie === false || emailCookie === "" || emailCookie === null) {
modal.style.display = 'flex';
emailInput.value = "";
body.style.overflow = "hidden";
}
emailInput.focus()

// When user click Enter, click the submit button
emailInput.addEventListener("keypress", function(event) {
if (event.key === "Enter") {
event.preventDefault();
document.getElementById("email-submit").click();
}
});

// Handle form submission
const form = document.getElementById('email-form');
form.addEventListener('submit', async function(event) {
event.preventDefault();
const formData = new FormData(form);
const email = formData.get('email');
if (!email) return;
try {
const response = await fetch('https://state-of-open-source-ai.vercel.app/api/add-member', {
method: 'POST',
body: JSON.stringify({ email }),
headers: {
'Content-Type': 'application/json',
},
});

const responseData = await response.json();

if (response.ok) {
let modal = document.getElementById('email-modal');
modal.style.display = 'none';
setCookie("email", emailInput.value, 365); // might fail if cookies disabled
} else {
document.querySelector('.email-error').textContent = responseData.error || 'An unexpected error occurred. Please enter a valid email.';
}
} catch (error) {
console.error('Error:', error);
document.querySelector('.email-error').textContent = 'An unexpected error occurred. Please try again.';
}
});
});
2 changes: 0 additions & 2 deletions backend/.gitignore

This file was deleted.

62 changes: 0 additions & 62 deletions backend/api/add-member.js

This file was deleted.

15 changes: 0 additions & 15 deletions backend/package.json

This file was deleted.

200 changes: 0 additions & 200 deletions backend/pnpm-lock.yaml

This file was deleted.

0 comments on commit 42dfe78

Please sign in to comment.