Add InfoModal component and update Navbar component

This commit is contained in:
Sean Morley
2024-04-10 18:25:53 +00:00
parent 818ab5239d
commit f7fc46caac
5 changed files with 95 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
<script lang="ts">
export let data;
console.log(data.result);
import { goto } from "$app/navigation";
import AdventureCard from "$lib/components/AdventureCard.svelte";
import { visitCount } from "$lib/utils/stores/visitCountStore.js";
import type { Adventure } from "$lib/utils/types.js";
@@ -10,8 +11,8 @@
count = value;
});
function add(event: CustomEvent<{ name: string; location: string }>) {
fetch("/api/visits", {
async function add(event: CustomEvent<{ name: string; location: string }>) {
const response = await fetch("/api/visits", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -22,7 +23,12 @@
created: "",
}),
});
visitCount.update((n) => n + 1);
if (response.status === 401) {
goto("/login");
} else {
visitCount.update((n) => n + 1);
}
}
</script>