1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-02 19:55:18 +02:00

chore: Update UserAvatar component to use button for profile navigation

This commit is contained in:
Sean Morley 2024-06-13 17:13:39 +00:00
parent 6fd360a9d0
commit fc8a162aa9
3 changed files with 46 additions and 1 deletions

View file

@ -30,7 +30,7 @@
<!-- svelte-ignore a11y-missing-attribute -->
<!-- svelte-ignore a11y-missing-attribute -->
<p class="text-lg ml-4 font-bold">Hi, {user.first_name} {user.last_name}</p>
<li><a>Profile</a></li>
<li><button on:click={() => goto("/profile")}>Profile</button></li>
<li><button on:click={navToLog}>My Log</button></li>
<li><button on:click={navToSettings}>User Settings</button></li>
{#if user.role == "admin"}

View file

@ -0,0 +1,11 @@
import { redirect } from "@sveltejs/kit";
import type { PageServerLoad, RequestEvent } from "../$types";
export const load: PageServerLoad = async (event: RequestEvent) => {
if (!event.locals.user) {
return redirect(302, "/login");
}
return {
user: event.locals.user,
};
};

View file

@ -0,0 +1,34 @@
<script lang="ts">
import type { PageData } from "./$types";
export let data: PageData;
</script>
<!--
// v0 by Vercel.
// https://v0.dev/t/EtPnDdQYcbn
-->
<!--
// v0 by Vercel.
// https://v0.dev/t/DYwTru570WN
-->
{#if data.user.icon}
<div class="avatar flex items-center justify-center">
<div class="w-24 rounded">
<img src={data.user.icon} class="w-24 rounded-full" />
</div>
</div>
{/if}
<h1 class="text-center text-4xl font-bold">
{data.user.first_name}, {data.user.last_name}
</h1>
<p class="text-center text-lg mt-2">{data.user.username}</p>
<p class="ml-1 text-lg text-center mt-4">Member Since</p>
<div class="flex items-center justify-center text-center">
<iconify-icon icon="mdi:calendar" class="text-2xl"></iconify-icon>
<p class="ml-1 text-xl">{data.user.signup_date.toDateString()}</p>
</div>