Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
feat: added error catching to notification
Browse files Browse the repository at this point in the history
  • Loading branch information
taciturnaxolotl committed Dec 18, 2023
1 parent c1f6d25 commit 88f28dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 11 additions & 7 deletions src/components/Email-Form.astro
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,23 @@
})
.then((response) => response.json())
.then((data) => {
console.log("Success:", data);
displayNotification(
"Success!",
"Thank you for signing up to our newsletter!" + "<br>" + 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." +
"<br>" +
"There was an error signing you up to our newsletter." +
"<br/><br/>" +
error,
);
});
Expand Down
6 changes: 4 additions & 2 deletions src/components/Notification.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -64,7 +64,9 @@

<div class="notification" id="notification">
<h2 id="notification-title"></h2>
<br/>
<p id="notification-message"></p>
<br/>
<!-- progress bar -->
<div class="progress" id="notification-progress">
<div class="progress-bar" id="notification-progress-bar" style="height:24px;width:1%"></div>
Expand Down

0 comments on commit 88f28dd

Please sign in to comment.