Add log page, update database schema, and API endpoint for user visits
This commit is contained in:
13
src/routes/log/+page.server.ts
Normal file
13
src/routes/log/+page.server.ts
Normal 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,
|
||||
};
|
||||
};
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user