Skip to content

Commit 6447aef

Browse files
committed
fix navigation bar + error
1 parent e1f0d71 commit 6447aef

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

src/routes/+layout.svelte

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import errorStore from '$lib/errorStore';
77
import { getProfilePicture } from '$lib/functions';
88
import {dark} from '$lib/darkMode.svelte';
9+
import { page } from '$app/stores';
910
1011
let navHeight = 2;
1112
let { data, children } = $props();
@@ -32,7 +33,9 @@
3233
}
3334
3435
let user = $derived(data.user);
36+
let role = $derived(data.role);
3537
let session = $derived(data.session);
38+
let pathname = $derived($page.url.pathname);
3639
</script>
3740

3841
<link
@@ -50,8 +53,25 @@
5053

5154
<AppBar.Headline>
5255
{#if user?.username}
53-
<button type="button" class="text-xl" onclick={() => {window.location.href = "/trips"}}>Trips</button>
54-
<span class="divider-vertical h-3"></span>
56+
<div class="inline-flex items-center">
57+
<button
58+
type="button"
59+
class={`px-4 py-1.5 text-sm font-semibold rounded-md hover:bg-surface-200-800 ${pathname.startsWith('/trips') ? 'underline underline-offset-4' : ''}`}
60+
onclick={() => {window.location.href = "/trips"}}
61+
>
62+
Trips
63+
</button>
64+
{#if role?.canCreateUser}
65+
<span class="mx-2 h-5 w-px bg-surface-400/60"></span>
66+
<button
67+
type="button"
68+
class={`px-4 py-1.5 text-sm font-semibold rounded-md hover:bg-surface-200-800 ${pathname.startsWith('/createUser') ? 'underline underline-offset-4' : ''}`}
69+
onclick={() => {window.location.href = "/createUser"}}
70+
>
71+
Create User
72+
</button>
73+
{/if}
74+
</div>
5575
{/if}
5676
</AppBar.Headline>
5777

@@ -99,23 +119,27 @@
99119

100120
</AppBar>
101121
</div>
102-
{#if $errorStore.status && $errorStore.status != 200}
103-
<div class="md:container md:mx-auto flex flex-row flex flex-col pt-3 rounded-t-3xl">
104-
<aside class="alert preset-tonal-warning border border-warning-500 text-warning-500">
105-
<div class="material-symbols-outlined">warning</div>
106-
<div class="alert-message">
122+
{#if $errorStore.status >= 400}
123+
<div class="md:container md:mx-auto px-3 pt-3">
124+
<aside class="alert preset-tonal-warning border border-warning-600 text-warning-900 dark:border-warning-500 dark:text-warning-200 rounded-2xl flex items-stretch gap-3">
125+
<div class="flex items-center self-stretch px-3">
126+
<span class="material-symbols-outlined leading-none" style="font-size: 4.5rem;">warning</span>
127+
</div>
128+
<div class="flex-1 flex flex-col">
129+
<div class="alert-message">
107130
{#await $errorStore.json()}
108-
<h3 class="h3">"Loading..."</h3>
131+
<p class="text-base">{$errorStore.status} {$errorStore.statusText}</p>
109132
{:then parsed}
110-
<h3 class="h3">{$errorStore.status} {$errorStore.statusText}: {parsed.message}</h3>
133+
<p class="text-base">{$errorStore.status} {$errorStore.statusText}: {parsed.message}</p>
111134
{:catch parsingError}
112-
<h3 class="h3">Error in response: {parsingError}</h3>
135+
<p class="text-base">Error in response: {parsingError}</p>
113136
{/await}
114-
</div>
115-
<div class="alert-actions">
116-
<button class="btn preset-filled-warning-500" onclick={resetError}>
117-
<span>Ok</span>
118-
</button>
137+
</div>
138+
<div class="alert-actions mt-2 flex justify-end pr-2 pb-2">
139+
<button class="btn preset-filled-warning-500" onclick={resetError}>
140+
<span>Ok</span>
141+
</button>
142+
</div>
119143
</div>
120144
</aside>
121145
</div>

0 commit comments

Comments
 (0)