use a toast instead of alerting
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m1s
Publish Docker Image / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 59s

This commit is contained in:
Lee 2024-06-02 14:24:05 +01:00
parent af219e69bb
commit 78af91e971
2 changed files with 16 additions and 2 deletions

@ -17,7 +17,7 @@ const upload = async () => {
if (!paste || paste.trim() === "") {
pasteInput.focus();
alert("Your paste is empty!");
toast("Please enter a paste to upload.");
return;
}
@ -35,6 +35,16 @@ const upload = async () => {
window.location.href = "/" + data.id;
} catch (error) {
console.error("Error:", error);
alert(`${error.message || "An error occurred while uploading the paste."}`);
toast(`${error.message || "An error occurred while uploading the paste."}`);
}
};
const toast = (message, duration = 3000) => {
Toastify({
text: message,
duration: duration,
close: true,
gravity: "bottom",
position: "right",
}).showToast();
};

@ -9,6 +9,10 @@
<!-- TailwindCSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Toastify -->
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
</head>
<body class="bg-neutral-900 text-white">
<div class="p-3 h-screen w-screen relative">