use a toast instead of alerting
This commit is contained in:
parent
af219e69bb
commit
78af91e971
@ -17,7 +17,7 @@ const upload = async () => {
|
|||||||
|
|
||||||
if (!paste || paste.trim() === "") {
|
if (!paste || paste.trim() === "") {
|
||||||
pasteInput.focus();
|
pasteInput.focus();
|
||||||
alert("Your paste is empty!");
|
toast("Please enter a paste to upload.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +35,16 @@ const upload = async () => {
|
|||||||
window.location.href = "/" + data.id;
|
window.location.href = "/" + data.id;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error:", 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 -->
|
<!-- TailwindCSS -->
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<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>
|
</head>
|
||||||
<body class="bg-neutral-900 text-white">
|
<body class="bg-neutral-900 text-white">
|
||||||
<div class="p-3 h-screen w-screen relative">
|
<div class="p-3 h-screen w-screen relative">
|
||||||
|
Reference in New Issue
Block a user