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

63 lines
2.2 KiB
Svelte
Raw Normal View History

<script lang="ts">
import { LessonsPage } from '$features/course/pages';
2025-11-01 15:49:29 +01:00
import { CourseContainer } from '$lib/components/CourseContainer';
import { Button } from '@cio/ui/base/button';
import { RoleBasedSecurity } from '$features/ui';
import * as Page from '@cio/ui/base/page';
import { t } from '$lib/utils/functions/translations';
import { profile } from '$lib/utils/store/user';
import { COURSE_VERSION } from '$lib/utils/types';
import { getGreeting } from '$lib/utils/functions/date.js';
import { course } from '$lib/components/Course/store';
import { handleAddLessonWidget } from '$lib/components/Course/components/Lesson/store';
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);
let activateSections = $state(false);
let lessonEditing: string | undefined;
2021-09-13 14:02:18 +03:00
function addLesson() {
$handleAddLessonWidget.open = true;
2024-08-14 11:13:44 +01:00
$handleAddLessonWidget.isSection = $course.version === COURSE_VERSION.V2;
2021-09-14 07:01:44 +03:00
}
</script>
<svelte:head>
<title>Lessons - ClassroomIO</title>
</svelte:head>
<CourseContainer courseId={data.courseId}>
<Page.Header>
<Page.HeaderContent>
<Page.Title>
{$t(getGreeting())}
{$profile.fullname}!
</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]}>
{#if $course.version === COURSE_VERSION.V1}
<Button variant="outline" onclick={() => (activateSections = !activateSections)} disabled={!!lessonEditing}>
{$t(`course.navItem.lessons.section_prompt.cta`)}
</Button>
2025-11-01 15:49:29 +01:00
{/if}
<Button variant="outline" onclick={() => (reorder = !reorder)} disabled={!!lessonEditing}>
{$t(`course.navItem.lessons.add_lesson.${reorder ? 'end_reorder' : 'start_reorder'}`)}
</Button>
<Button onclick={addLesson} disabled={!!lessonEditing}>
{$t('course.navItem.lessons.add_lesson.button_title')}
</Button>
2025-11-01 15:49:29 +01:00
</RoleBasedSecurity>
</div>
</Page.Action>
</Page.Header>
<Page.Body>
{#snippet child()}
<LessonsPage courseId={data.courseId} />
2025-11-01 15:49:29 +01:00
{/snippet}
</Page.Body>
</CourseContainer>