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-27 11:40:38 +01:00
|
|
|
import { appInitApi } from '$features/app/init.svelte';
|
2026-04-12 08:58:41 +01:00
|
|
|
import { Spinner } from '@cio/ui/base/spinner';
|
2026-04-27 11:40:38 +01:00
|
|
|
import { Button } from '@cio/ui/base/button';
|
|
|
|
|
import FrownIcon from '@lucide/svelte/icons/frown';
|
|
|
|
|
import { Empty } from '@cio/ui/custom/empty';
|
2026-04-12 08:58:41 +01:00
|
|
|
import { SimpleLogoNav } from '@cio/ui/custom/simple-logo-nav';
|
|
|
|
|
import {
|
|
|
|
|
buildOrgLandingPageProps,
|
|
|
|
|
importThemeComponent,
|
|
|
|
|
normalizeLandingPageSettings
|
|
|
|
|
} from '$features/org/utils/landing-page';
|
2026-04-27 11:40:38 +01:00
|
|
|
import { basePath } from '$lib/utils/store/app';
|
2026-04-12 08:58:41 +01:00
|
|
|
import { t } from '$lib/utils/functions/translations';
|
|
|
|
|
import { user } from '$lib/utils/store/user';
|
|
|
|
|
|
|
|
|
|
let { data } = $props();
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
let ThemeComponent = $state<Component<any> | null>(null);
|
2026-04-27 11:40:38 +01:00
|
|
|
|
|
|
|
|
const hasSetupError = $derived(!appInitApi.loading && !!appInitApi.error);
|
2026-04-12 08:58:41 +01:00
|
|
|
|
|
|
|
|
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 () => {
|
2026-05-18 03:47:22 +01:00
|
|
|
if (!data.isOrgSite || !data.org) {
|
|
|
|
|
if (!appInitApi.loading) {
|
2026-05-19 04:32:32 +01:00
|
|
|
appInitApi.setupApp(data.locals, {
|
|
|
|
|
isOrgSite: data.isOrgSite,
|
|
|
|
|
orgSiteName: data.orgSiteName
|
|
|
|
|
});
|
2026-05-18 03:47:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-04-12 08:58:41 +01:00
|
|
|
|
|
|
|
|
const settings = normalizeLandingPageSettings(data.org.landingpage);
|
|
|
|
|
const mod = await importThemeComponent(settings.theme);
|
|
|
|
|
ThemeComponent = mod.default;
|
|
|
|
|
});
|
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}
|
2026-04-27 11:40:38 +01:00
|
|
|
<!-- Theme loading -->
|
2026-04-12 08:58:41 +01:00
|
|
|
{/if}
|
2026-04-27 11:40:38 +01:00
|
|
|
{:else if hasSetupError}
|
|
|
|
|
<Empty
|
|
|
|
|
title="Something Went Wrong"
|
|
|
|
|
description="We encountered an unexpected error. Please reload the page or contact us for support."
|
|
|
|
|
icon={FrownIcon}
|
|
|
|
|
variant="page"
|
|
|
|
|
layout="full-page"
|
|
|
|
|
showLogo={true}
|
|
|
|
|
>
|
|
|
|
|
<p class="my-2 text-red-500">{appInitApi.error}</p>
|
|
|
|
|
<div class="flex gap-2">
|
|
|
|
|
<Button variant="secondary" onclick={() => window.location.reload()}>Reload Page</Button>
|
|
|
|
|
<Button variant="default" href="https://classroomio.com/contact">Contact Us</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</Empty>
|
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}
|