From 88f28dd1a0cf33204628d5342373a60089f39893 Mon Sep 17 00:00:00 2001
From: Kieran Klukas <92754843+kcoderhtml@users.noreply.github.com>
Date: Mon, 18 Dec 2023 12:52:57 -0500
Subject: [PATCH] feat: added error catching to notification
---
src/components/Email-Form.astro | 18 +++++++++++-------
src/components/Notification.astro | 6 ++++--
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/components/Email-Form.astro b/src/components/Email-Form.astro
index 527d078..24fd8ce 100644
--- a/src/components/Email-Form.astro
+++ b/src/components/Email-Form.astro
@@ -181,19 +181,23 @@
})
.then((response) => response.json())
.then((data) => {
- console.log("Success:", data);
- displayNotification(
- "Success!",
- "Thank you for signing up to our newsletter!" + "
" + data,
- );
+ if (data != "true") {
+ throw new Error(data);
+ } else {
+ console.log("Success:", data);
+ displayNotification(
+ "Success!",
+ "Thank you for signing up to our newsletter!",
+ );
+ }
})
.catch((error) => {
// Handle errors
console.error("Error:", error);
displayNotification(
"Error!",
- "There was an error signing you up to our newsletter. Please try again later." +
- "
" +
+ "There was an error signing you up to our newsletter." +
+ "
" +
error,
);
});
diff --git a/src/components/Notification.astro b/src/components/Notification.astro
index 06b43c1..48f7ecc 100644
--- a/src/components/Notification.astro
+++ b/src/components/Notification.astro
@@ -40,8 +40,8 @@
}
.progress-bar {
- background-color: var(--dl-color-gray-black);
- height: 24px;
+ background-color: var(--dl-color-purple-300);
+ height: 1rem;
width: 0;
border-radius: 4px;
}
@@ -64,7 +64,9 @@