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

Add login functionality to Navbar component

This commit is contained in:
Sean Morley 2024-04-05 22:22:09 +00:00
parent 3ab2918ed2
commit cd11ce2d97
2 changed files with 11 additions and 1 deletions

View file

@ -1,4 +1,5 @@
<script lang="ts">
import { enhance } from "$app/forms";
import { visitCount } from "$lib/utils/stores/visitCountStore";
import { goto } from "$app/navigation";
import type { DatabaseUser } from "$lib/server/auth";
@ -12,6 +13,9 @@
async function goToFeatured() {
goto("/featured");
}
async function toToLogin() {
goto("/login");
}
let count = 0;
visitCount.subscribe((value) => {
@ -48,8 +52,13 @@
</div>
<div class="navbar-end flex justify-around md:justify-end mr-4">
<p>Adventures: {count}</p>
{#if !user}
<button class="btn btn-primary ml-4" on:click={toToLogin}>Login</button>
{/if}
{#if user}
<p>Hello {user.first_name}</p>
<form method="post" use:enhance>
<button class="btn btn-primary ml-4">Sign out</button>
</form>
{/if}
</div>
</div>