1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-31 02:39:38 +02:00

Add navigation to World Travel page and create server load function for country regions

This commit is contained in:
Sean Morley 2024-04-12 00:12:55 +00:00
parent d190222573
commit 8a8a118309
3 changed files with 32 additions and 2 deletions

View file

@ -20,9 +20,12 @@
async function toToLogin() {
goto("/login");
}
async function toToSignup() {
async function goToSignup() {
goto("/signup");
}
async function goToWorldTravel() {
goto("/worldtravel");
}
let count = 0;
@ -67,6 +70,10 @@
<button class="btn btn-primary my-2 md:my-0 md:mr-4" on:click={goToLog}
>My Log</button
>
<button
class="btn btn-primary my-2 md:my-0 md:mr-4"
on:click={goToWorldTravel}>World Tavel Log</button
>
{/if}
<button class="btn btn-primary my-2 md:my-0" on:click={goToFeatured}
>Featured</button
@ -82,7 +89,7 @@
<div class="navbar-end flex justify-around md:justify-end mr-4">
{#if !user}
<button class="btn btn-primary ml-4" on:click={toToLogin}>Login</button>
<button class="btn btn-primary ml-4" on:click={toToSignup}>Signup</button>
<button class="btn btn-primary ml-4" on:click={goToSignup}>Signup</button>
{/if}
{#if user}

View file

@ -0,0 +1,16 @@
// server laod function
import { db } from '$lib/db/db.server.js';
import { worldTravelCountryRegions } from '$lib/db/schema.js';
import { eq } from 'drizzle-orm';
export async function load({ params }) {
const { countrycode } = params;
let data = await db
.select()
.from(worldTravelCountryRegions)
.where(eq(worldTravelCountryRegions.country_code, countrycode))
console.log(data)
return {
regions : data,
};
}

View file

@ -0,0 +1,7 @@
<script lang="ts">
export let data;
</script>
{#each data.regions as region}
<p>{region.name}</p>
{/each}