Files
classroomio/apps/dashboard/src/routes/courses/[id]/lessons/+page.svelte
T

53 lines
1.8 KiB
Svelte
Raw Normal View History

<script lang="ts">
import { LessonsPage } from '$features/course/pages';
import { Button } from '@cio/ui/base/button';
2026-03-18 23:39:12 +01:00
import { RefreshPageData, RoleBasedSecurity } from '$features/ui';
import * as Page from '@cio/ui/base/page';
import { t } from '$lib/utils/functions/translations';
2026-03-09 11:18:22 +01:00
import { contentCreateStoreUtils, contentEditingStore } from '$features/course/components/content/store';
import { courseApi } from '$features/course/api';
2026-03-18 23:39:12 +01:00
import { profile } from '$lib/utils/store/user';
2025-11-01 15:49:29 +01:00
let { data } = $props();
2023-09-30 10:43:13 +01:00
2025-11-01 15:49:29 +01:00
let reorder = $state(false);
2021-09-13 14:02:18 +03:00
2026-03-09 11:18:22 +01:00
function addContent() {
const contentGroupingEnabled = courseApi.course?.metadata?.isContentGroupingEnabled ?? true;
if (contentGroupingEnabled) {
contentCreateStoreUtils.openSection();
} else {
contentCreateStoreUtils.openDefault();
}
2021-09-14 07:01:44 +03:00
}
</script>
2026-03-09 11:18:22 +01:00
<Page.Root class="mx-auto flex w-[90%] px-4 md:max-w-2xl lg:max-w-3xl">
<Page.Header>
<Page.HeaderContent>
<Page.Title>
2026-03-09 11:18:22 +01:00
{$t('course.navItem.lessons.heading_v2')}
</Page.Title>
</Page.HeaderContent>
<Page.Action>
2025-11-01 15:49:29 +01:00
<div class="flex w-full justify-end gap-2">
<RoleBasedSecurity allowedRoles={[1, 2]}>
2026-03-09 11:18:22 +01:00
<Button variant="outline" onclick={() => (reorder = !reorder)} disabled={!!$contentEditingStore}>
{$t(`course.navItem.lessons.add_lesson.${reorder ? 'end_reorder' : 'start_reorder'}`)}
</Button>
2026-03-09 11:18:22 +01:00
<Button onclick={addContent} disabled={!!$contentEditingStore}
>{$t('course.navItem.lessons.add_content')}</Button
>
2025-11-01 15:49:29 +01:00
</RoleBasedSecurity>
2026-03-18 23:39:12 +01:00
<RefreshPageData onRefresh={() => courseApi.refreshCourse(data.courseId, $profile.id)} />
2025-11-01 15:49:29 +01:00
</div>
</Page.Action>
</Page.Header>
<Page.Body>
{#snippet child()}
2026-03-09 11:18:22 +01:00
<LessonsPage courseId={data.courseId} bind:reorder />
2025-11-01 15:49:29 +01:00
{/snippet}
</Page.Body>
2026-03-09 11:18:22 +01:00
</Page.Root>