Add visit count functionality to Navbar and Log page

This commit is contained in:
Sean Morley
2024-04-10 17:47:20 +00:00
parent ae5e77f670
commit bc0e1b4db2
5 changed files with 59 additions and 7 deletions

View File

@@ -19,6 +19,7 @@
import mapDrawing from "$lib/assets/adventure_map.svg";
import EditModal from "$lib/components/EditModal.svelte";
import { generateRandomString } from "$lib";
import { visitCount } from "$lib/utils/stores/visitCountStore";
let newName = "";
let newLocation = "";
@@ -37,6 +38,11 @@
adventures = data.result.adventures;
});
let count = 0;
visitCount.subscribe((value) => {
count = value;
});
function showToast(action: string) {
toastAction = action;
isShowingToast = true;
@@ -80,6 +86,7 @@
newName = ""; // Reset newName and newLocation after adding adventure
newLocation = "";
showToast("added");
visitCount.update((n) => n + 1);
})
.catch((error) => {
console.error("Error:", error);
@@ -183,6 +190,7 @@
(adventure) => adventure.id !== event.detail,
);
showToast("removed");
visitCount.update((n) => n - 1);
})
.catch((error) => {
console.error("Error:", error);