2026-04-12 08:58:41 +01:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
|
import { resolve } from '$app/paths';
|
|
|
|
|
import type { Component } from 'svelte';
|
2025-12-22 02:36:48 +01:00
|
|
|
|
2026-04-12 08:58:41 +01:00
|
|
|
import { Spinner } from '@cio/ui/base/spinner';
|
|
|
|
|
import { SimpleLogoNav } from '@cio/ui/custom/simple-logo-nav';
|
|
|
|
|
import {
|
|
|
|
|
buildOrgLandingPageProps,
|
|
|
|
|
importThemeComponent,
|
|
|
|
|
normalizeLandingPageSettings
|
|
|
|
|
} from '$features/org/utils/landing-page';
|
2026-04-12 18:07:33 +01:00
|
|
|
import { basePath, globalStore } from '$lib/utils/store/app';
|
2026-04-12 08:58:41 +01:00
|
|
|
import { currentOrg } from '$lib/utils/store/org';
|
|
|
|
|
import { setTheme } from '$lib/utils/functions/theme';
|
|
|
|
|
import { t } from '$lib/utils/functions/translations';
|
|
|
|
|
import { user } from '$lib/utils/store/user';
|
|
|
|
|
import PageLoader from '$features/org/components/landing-page/page-loader.svelte';
|
|
|
|
|
|
|
|
|
|
let { data } = $props();
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
let ThemeComponent = $state<Component<any> | null>(null);
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
let DashboardEntry = $state<Component<any> | null>(null);
|
|
|
|
|
|
|
|
|
|
const pageTitle = $derived(
|
|
|
|
|
data.isOrgSite && data.org ? data.org.name : "ClassroomIO - The Course Platform That's Actually Easy To Use"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const authAction = $derived(
|
|
|
|
|
$user.isLoggedIn
|
|
|
|
|
? {
|
|
|
|
|
label: t.get($basePath === '/lms' || $basePath === '#' ? 'navigation.goto_lms' : 'navigation.goto_dashboard'),
|
|
|
|
|
href: resolve($basePath !== '#' ? $basePath : '/lms', {})
|
|
|
|
|
}
|
|
|
|
|
: {
|
|
|
|
|
label: t.get('navigation.login'),
|
|
|
|
|
href: '/login'
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const landingPageProps = $derived.by(() => {
|
|
|
|
|
if (!data.isOrgSite || !data.org) return null;
|
|
|
|
|
|
|
|
|
|
return buildOrgLandingPageProps(
|
|
|
|
|
data.org,
|
|
|
|
|
normalizeLandingPageSettings(data.org.landingpage),
|
|
|
|
|
data.courses,
|
|
|
|
|
data.hasMoreCourses,
|
|
|
|
|
authAction
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
|
const loadingIndicator = document.getElementById('app-loading-indicator');
|
|
|
|
|
if (loadingIndicator) {
|
|
|
|
|
loadingIndicator.style.display = 'none';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data.isOrgSite || !data.org) {
|
|
|
|
|
const mod = await import('./_dashboard-entry.svelte');
|
|
|
|
|
DashboardEntry = mod.default;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.locals?.user) {
|
|
|
|
|
user.set({
|
|
|
|
|
...$user,
|
|
|
|
|
isLoggedIn: true,
|
|
|
|
|
currentSession: data.locals.user
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$globalStore.orgSiteName = data.orgSiteName || '';
|
|
|
|
|
$globalStore.isOrgSite = true;
|
|
|
|
|
currentOrg.set(data.org);
|
|
|
|
|
setTheme(data.org.theme || 'blue');
|
|
|
|
|
|
|
|
|
|
const settings = normalizeLandingPageSettings(data.org.landingpage);
|
|
|
|
|
const mod = await importThemeComponent(settings.theme);
|
|
|
|
|
ThemeComponent = mod.default;
|
|
|
|
|
});
|
2026-04-12 18:07:33 +01:00
|
|
|
|
2021-07-28 22:29:23 +03:00
|
|
|
</script>
|
|
|
|
|
|
2021-07-31 23:21:39 +03:00
|
|
|
<svelte:head>
|
2026-04-12 08:58:41 +01:00
|
|
|
<title>{pageTitle}</title>
|
2021-07-31 23:21:39 +03:00
|
|
|
</svelte:head>
|
|
|
|
|
|
2026-04-12 08:58:41 +01:00
|
|
|
{#if data.isOrgSite && data.org}
|
|
|
|
|
{#if ThemeComponent && landingPageProps}
|
|
|
|
|
<ThemeComponent {...landingPageProps} />
|
|
|
|
|
{:else}
|
|
|
|
|
<PageLoader />
|
|
|
|
|
{/if}
|
|
|
|
|
{:else if DashboardEntry}
|
|
|
|
|
<DashboardEntry />
|
2025-12-22 02:36:48 +01:00
|
|
|
{:else}
|
|
|
|
|
<div class="m-2 flex h-screen w-screen flex-col items-center justify-center font-sans sm:m-0">
|
|
|
|
|
<SimpleLogoNav />
|
2025-12-02 09:54:38 +01:00
|
|
|
<Spinner class="size-14! text-blue-700!" />
|
2025-12-22 02:36:48 +01:00
|
|
|
</div>
|
|
|
|
|
{/if}
|