|
6 | 6 | import errorStore from '$lib/errorStore'; |
7 | 7 | import { getProfilePicture } from '$lib/functions'; |
8 | 8 | import {dark} from '$lib/darkMode.svelte'; |
| 9 | + import { page } from '$app/stores'; |
9 | 10 |
|
10 | 11 | let navHeight = 2; |
11 | 12 | let { data, children } = $props(); |
|
32 | 33 | } |
33 | 34 |
|
34 | 35 | let user = $derived(data.user); |
| 36 | + let role = $derived(data.role); |
35 | 37 | let session = $derived(data.session); |
| 38 | + let pathname = $derived($page.url.pathname); |
36 | 39 | </script> |
37 | 40 |
|
38 | 41 | <link |
|
50 | 53 |
|
51 | 54 | <AppBar.Headline> |
52 | 55 | {#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> |
55 | 75 | {/if} |
56 | 76 | </AppBar.Headline> |
57 | 77 |
|
|
99 | 119 |
|
100 | 120 | </AppBar> |
101 | 121 | </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"> |
107 | 130 | {#await $errorStore.json()} |
108 | | - <h3 class="h3">"Loading..."</h3> |
| 131 | + <p class="text-base">{$errorStore.status} {$errorStore.statusText}</p> |
109 | 132 | {: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> |
111 | 134 | {:catch parsingError} |
112 | | - <h3 class="h3">Error in response: {parsingError}</h3> |
| 135 | + <p class="text-base">Error in response: {parsingError}</p> |
113 | 136 | {/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> |
119 | 143 | </div> |
120 | 144 | </aside> |
121 | 145 | </div> |
|
0 commit comments