Refactor database schema, remove unused SQL files, and update components

This commit is contained in:
Sean Morley
2024-04-26 23:09:39 +00:00
parent 08579289a6
commit 9837cc4e64
7 changed files with 23 additions and 300 deletions

View File

@@ -1,21 +0,0 @@
import { db } from "$lib/db/db.server";
import { userPlannedAdventures } from "$lib/db/schema";
import { eq } from "drizzle-orm";
import type { LayoutServerLoad } from "../$types";
import { redirect } from "@sveltejs/kit";
export const load: LayoutServerLoad = async (event) => {
if (event.locals.user) {
let plannedAdventures = await db
.select()
.from(userPlannedAdventures)
.where(eq(userPlannedAdventures.userId, event.locals.user.id));
return {
user: event.locals.user,
isServerSetup: event.locals.isServerSetup,
plannedAdventures,
};
} else {
return redirect(302, "/login");
}
};

View File

@@ -1,31 +0,0 @@
<script lang="ts">
import { page } from "$app/stores";
import type { Adventure } from "$lib/utils/types";
import { onMount } from "svelte";
import AdventureCard from "$lib/components/AdventureCard.svelte";
let plannedAdventures: Adventure[] = [];
onMount(async () => {
plannedAdventures = $page.data.plannedAdventures;
console.log(plannedAdventures);
});
</script>
<h1 class="font-extrabold text-center text-4xl">My Planned Adventures</h1>
<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 plannedAdventures as adventure (adventure.id)}
<AdventureCard
type="planner"
id={adventure.id}
name={adventure.name}
location={adventure.location}
activityTypes={adventure.activityTypes}
description={adventure?.description}
date={adventure?.date}
/>
{/each}
</div>