Add log page, update database schema, and API endpoint for user visits

This commit is contained in:
Sean Morley
2024-04-06 12:54:17 +00:00
parent 1b9edeb61f
commit ea79fd2d76
8 changed files with 245 additions and 11 deletions

View File

@@ -0,0 +1,13 @@
import { redirect } from "@sveltejs/kit";
import type { PageServerLoad } from "./$types";
export const load: PageServerLoad = async (event) => {
if (!event.locals.user) {
return redirect(302, "/login");
}
const response = await event.fetch("/api/visits");
const result = await response.json();
return {
result,
};
};

View File

@@ -1,4 +1,6 @@
<script lang="ts">
let adventures: Adventure[] = [];
export let data;
import AdventureCard from "$lib/components/AdventureCard.svelte";
import type { Adventure } from "$lib/utils/types";
import {
@@ -27,8 +29,6 @@
let editLocation: string = "";
let editCreated: string = "";
let adventures: Adventure[] = [];
let isShowingToast: boolean = false;
let toastAction: string = "";
@@ -62,6 +62,7 @@
onMount(async () => {
adventures = getAdventures();
console.log(data.result);
});
function triggerRemoveAdventure(event: { detail: number }) {
@@ -177,7 +178,7 @@
<div
class="grid xl:grid-cols-3 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1 gap-4 mt-4 content-center auto-cols-auto ml-6 mr-6"
>
{#each adventures as adventure (adventure.id)}
{#each data.result.adventures as adventure (adventure.id)}
<AdventureCard
type="mylog"
id={adventure.id}