Files
classroomio/apps/dashboard/src/routes/org/[slug]/+layout.svelte
T

52 lines
1.4 KiB
Svelte
Raw Normal View History

2025-11-01 15:49:29 +01:00
<script lang="ts">
import { page } from '$app/state';
2024-04-07 06:08:34 +01:00
import { goto } from '$app/navigation';
import * as Sidebar from '@cio/ui/base/sidebar';
import { Skeleton } from '@cio/ui/base/skeleton';
import { currentOrg } from '$lib/utils/store/org';
import { AppHeader } from '$lib/features/ui';
import { VerifyEmailModal } from '$lib/features/onboarding/components';
import { OrgSidebar } from '$lib/features/ui/sidebar/org-sidebar/index.js';
import AddOrgModal from '$lib/components/Org/AddOrgModal/AddOrgModal.svelte';
2024-04-07 06:08:34 +01:00
2025-11-01 15:49:29 +01:00
let { data, children } = $props();
2024-04-07 06:08:34 +01:00
2025-11-01 15:49:29 +01:00
function redirect(siteName: string) {
if (!siteName) return;
2025-11-01 15:49:29 +01:00
const newUrl = page.url.pathname.replace('*', siteName);
goto(newUrl + page.url.search);
2024-04-07 06:08:34 +01:00
}
2025-11-01 15:49:29 +01:00
$effect(() => {
data.orgName === '*' && redirect($currentOrg.siteName);
});
2023-12-13 09:02:52 +03:00
</script>
<AddOrgModal />
2024-04-19 05:45:48 +01:00
2024-03-22 06:30:24 +01:00
<VerifyEmailModal />
2024-04-19 05:45:48 +01:00
<Sidebar.Provider>
<OrgSidebar />
<Sidebar.Inset>
<AppHeader />
<div class="container mx-auto flex max-w-6xl flex-1 flex-col gap-4 p-4 pt-0">
{#if data.orgName === '*'}
<div class="grid auto-rows-min gap-4 md:grid-cols-3">
<Skeleton class="aspect-video rounded-xl" />
<Skeleton class="aspect-video rounded-xl" />
<Skeleton class="aspect-video rounded-xl" />
</div>
<Skeleton class="h-[50vh] w-full rounded-xl" />
{:else}
{@render children?.()}
{/if}
</div>
</Sidebar.Inset>
</Sidebar.Provider>