From 3a4726305d15d4028473a408a3a5cb93bb16343a Mon Sep 17 00:00:00 2001 From: Marco Gallegos Date: Fri, 21 Nov 2025 15:57:17 -0600 Subject: [PATCH] feat: Update notification form to collect name and phone and submit data via webhook, replacing Firebase email submission. --- index.html | 22 +++++++++------ js/firebase_configuration.js | 54 ------------------------------------ js/form_submission.js | 40 ++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 63 deletions(-) delete mode 100644 js/firebase_configuration.js create mode 100644 js/form_submission.js diff --git a/index.html b/index.html index d5cf15b..d398814 100644 --- a/index.html +++ b/index.html @@ -92,16 +92,19 @@ -
-
-
- - - -
+
+
+
+ + + +
-
+ + +
+

@@ -134,6 +137,7 @@ + diff --git a/js/firebase_configuration.js b/js/firebase_configuration.js deleted file mode 100644 index 10736fd..0000000 --- a/js/firebase_configuration.js +++ /dev/null @@ -1,54 +0,0 @@ -// Initialize Firebase -function validateEmail(email) { - var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - return re.test(String(email).toLowerCase()); -} - -var config = { - apiKey: "", - authDomain: "", - databaseURL: "", - projectId: "", - storageBucket: "", - messagingSenderId: "" -}; -firebase.initializeApp(config); -var db = firebase.firestore(); -db.settings({ - timestampsInSnapshots: true -}); - -$(document).ready(function () { - - $('#notifs-form-btn').click(function (e) { - var is_present = false; - email = $('#notifs-form-input').val(); - if (validateEmail(email)) { - db.collection('Emails').get().then(function (qs) { - qs.forEach(function (element) { - if (element.data()['ID'] == email) { - is_present = true; - } - }); - - if (is_present == false) { - db.collection("Emails").add({ - 'ID': email, - }) - .then(function (docRef) { - console.log("Document written with ID: ", docRef.id); - $("#notifs-form-btn").text("Notified!"); - }) - .catch(function (error) { - console.error("Error adding document: ", error); - }); - } - }); - - } - else { - alert('Invalid Email'); - } - }); - -}); \ No newline at end of file diff --git a/js/form_submission.js b/js/form_submission.js new file mode 100644 index 0000000..76f7109 --- /dev/null +++ b/js/form_submission.js @@ -0,0 +1,40 @@ +$(document).ready(function () { + + $('#notifs-form-btn').click(function (e) { + var name = $('#notifs-form-name').val(); + var phone = $('#notifs-form-phone').val(); + + if (name && phone) { + var data = { + name: name, + phone: phone + }; + + $.ajax({ + url: 'https://flows.soul23.cloud/webhook/Ul6upjlKqQQ79rDgd8XKOm', + type: 'POST', + contentType: 'application/json', + data: JSON.stringify(data), + success: function (response) { + console.log("Webhook sent successfully", response); + $("#notifs-form-btn").text("gracias :)"); + $("#notifs-form-btn").prop("disabled", true); + alert("¡Gracias! Hemos recibido tus datos."); + }, + error: function (xhr, status, error) { + console.error("Error sending webhook", error); + var errorMessage = "Hubo un error al enviar tus datos."; + if (xhr.responseJSON && xhr.responseJSON.message) { + errorMessage += "\n" + xhr.responseJSON.message; + } else if (xhr.responseText) { + errorMessage += "\n" + xhr.responseText; + } + alert(errorMessage); + } + }); + } else { + alert('jejeje, lo haremos mas fácil en el futuro'); + } + }); + +}); \ No newline at end of file