1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-04 20:55:19 +02:00

Refactor success toast and show appropriate messages

This commit is contained in:
Sean Morley 2024-04-11 18:18:35 +00:00
parent 53f7f90dbc
commit af07ea29ef
2 changed files with 6 additions and 7 deletions

View file

@ -4,6 +4,6 @@
<div class="toast toast-top toast-end z-50">
<div class="alert alert-info">
<span>Adventure {action} successfully!</span>
<span>{action}</span>
</div>
</div>

View file

@ -48,12 +48,10 @@
function showToast(action: string) {
toastAction = action;
isShowingToast = true;
console.log("showing toast");
setTimeout(() => {
isShowingToast = false;
toastAction = "";
console.log("hiding toast");
}, 3000);
}
@ -87,7 +85,7 @@
];
newName = ""; // Reset newName and newLocation after adding adventure
newLocation = "";
showToast("added");
showToast("Adventure added successfully!");
visitCount.update((n) => n + 1);
})
.catch((error) => {
@ -121,7 +119,7 @@
editName = "";
editLocation = "";
editCreated = "";
showToast("edited");
showToast("Adventure edited successfully!");
})
.catch((error) => {
console.error("Error:", error);
@ -155,6 +153,7 @@
console.log("Success:", data);
let url = window.location.origin + "/shared/" + key;
navigator.clipboard.writeText(url);
showToast("Link copied to clipboard!");
})
.catch((error) => {
console.error("Error:", error);
@ -180,7 +179,7 @@
console.log("Success:", data);
// remove adventure from array where id matches
adventures = [];
showToast("removed");
showToast("Adventure removed successfully!");
visitCount.set(0);
})
.catch((error) => {
@ -205,7 +204,7 @@
adventures = adventures.filter(
(adventure) => adventure.id !== event.detail,
);
showToast("removed");
showToast("Adventure removed successfully!");
visitCount.update((n) => n - 1);
})
.catch((error) => {