feat(layout): mount ConfirmDialog in root layout and provide confirm service
provideConfirmService() sets up context for the entire component tree. ConfirmDialog is mounted once at the bottom of the layout shell. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,9 +7,15 @@ import ThemeToggle from '$lib/components/ThemeToggle.svelte';
|
|||||||
import NotificationBell from '$lib/components/NotificationBell.svelte';
|
import NotificationBell from '$lib/components/NotificationBell.svelte';
|
||||||
import AppNav from './AppNav.svelte';
|
import AppNav from './AppNav.svelte';
|
||||||
import UserMenu from './UserMenu.svelte';
|
import UserMenu from './UserMenu.svelte';
|
||||||
|
import ConfirmDialog from '$lib/components/ConfirmDialog.svelte';
|
||||||
|
import { provideConfirmService } from '$lib/services/confirm.svelte.js';
|
||||||
|
|
||||||
let { children, data } = $props();
|
let { children, data } = $props();
|
||||||
|
|
||||||
|
// Provide the confirmation service to the entire component tree.
|
||||||
|
// ConfirmDialog below reads it via getConfirmService() and renders the <dialog>.
|
||||||
|
provideConfirmService();
|
||||||
|
|
||||||
const isAdmin = $derived(
|
const isAdmin = $derived(
|
||||||
data?.user?.groups?.some((g: { permissions: string[] }) => g.permissions.includes('ADMIN'))
|
data?.user?.groups?.some((g: { permissions: string[] }) => g.permissions.includes('ADMIN'))
|
||||||
);
|
);
|
||||||
@@ -70,4 +76,7 @@ const userInitials = $derived.by(() => {
|
|||||||
<main class={isAuthPage ? '' : 'py-6'}>
|
<main class={isAuthPage ? '' : 'py-6'}>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<!-- Shared confirmation dialog — used by getConfirmService() throughout the app -->
|
||||||
|
<ConfirmDialog />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user