Migrate shared UI and backend components
This commit is contained in:
1 parent
64d22d0aac
commit
ac08be0248
16 files changed
+236
-395
No files matched your search
@@ -1,12 +1,27 @@
|
||||
<script>
|
||||
import { page } from '$app/state';
|
||||
import { AppShell as SharedAppShell, ProfileDialog } from '@gabriel20xx/shared-code/web-ui';
|
||||
import { Tooltip } from 'bits-ui';
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import AuthPage from '$lib/features/auth/AuthPage.svelte';
|
||||
import { createAuthStore } from '$lib/features/auth/auth.svelte.js';
|
||||
import SettingsDialog from './SettingsDialog.svelte';
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
const auth = createAuthStore();
|
||||
const navItems = [
|
||||
{ href: '/', label: 'Overview' },
|
||||
{ href: '/about', label: 'About' },
|
||||
];
|
||||
let settingsOpen = $state(false);
|
||||
let credentialsOpen = $state(false);
|
||||
|
||||
async function saveProfile(input) {
|
||||
await auth.updateCredentials({
|
||||
newUsername: input.username.trim() || undefined,
|
||||
newEmail: input.email.trim() || undefined,
|
||||
newPassword: input.password || undefined,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<Tooltip.Provider delayDuration={300}>
|
||||
@@ -19,11 +34,27 @@
|
||||
{:else if !auth.status || auth.status.setupRequired || !auth.status.authenticated}
|
||||
<AuthPage setupRequired={auth.status?.setupRequired ?? true} />
|
||||
{:else}
|
||||
<div class="flex min-h-screen flex-col">
|
||||
<Header />
|
||||
<main class="flex min-w-0 flex-1 flex-col">
|
||||
<SharedAppShell
|
||||
brand="CollabTable"
|
||||
currentPath={page.url.pathname}
|
||||
{navItems}
|
||||
theme="system"
|
||||
username={auth.status.username ?? ''}
|
||||
onLogout={() => auth.logout()}
|
||||
onProfile={() => (credentialsOpen = true)}
|
||||
onSettings={() => (settingsOpen = true)}
|
||||
>
|
||||
{#snippet children()}
|
||||
{@render children?.()}
|
||||
</main>
|
||||
</div>
|
||||
{/snippet}
|
||||
</SharedAppShell>
|
||||
{/if}
|
||||
</Tooltip.Provider>
|
||||
|
||||
<SettingsDialog bind:open={settingsOpen} />
|
||||
<ProfileDialog
|
||||
bind:open={credentialsOpen}
|
||||
currentUsername={auth.status?.username ?? ''}
|
||||
currentEmail={auth.status?.email ?? ''}
|
||||
onSave={saveProfile}
|
||||
/>
|
||||
Reference in new issue
Block a user