2022-01-10 00:18:08 +02:00
|
|
|
<script>
|
|
|
|
|
import { fly } from 'svelte/transition';
|
2023-08-02 19:35:27 +01:00
|
|
|
import CourseLandingPage from '$lib/components/CourseLandingPage/index.svelte';
|
|
|
|
|
import Editor from '$lib/components/CourseLandingPage/components/Editor/index.svelte';
|
|
|
|
|
import { isMobile } from '$lib/utils/store/useMobile';
|
|
|
|
|
import { profile } from '$lib/utils/store/user';
|
|
|
|
|
import { setCourse, course } from '$lib/components/Course/store';
|
|
|
|
|
import { lessons } from '$lib/components/Course/components/Lesson/store/lessons';
|
|
|
|
|
import { fetchCourse } from '$lib/utils/services/courses';
|
2023-08-07 19:44:26 +00:00
|
|
|
import { browser } from '$app/environment';
|
2022-01-10 00:18:08 +02:00
|
|
|
|
2023-08-02 19:35:27 +01:00
|
|
|
export let data;
|
|
|
|
|
const { courseId } = data;
|
2022-12-30 13:08:54 +01:00
|
|
|
|
|
|
|
|
let courseData = {};
|
|
|
|
|
|
|
|
|
|
async function triggerSetCourse(_profile) {
|
2023-08-07 19:44:26 +00:00
|
|
|
if ($course.id || !browser) return;
|
2023-08-02 19:35:27 +01:00
|
|
|
const { data: _data } = await fetchCourse(courseId);
|
|
|
|
|
setCourse(_data);
|
2022-12-30 13:08:54 +01:00
|
|
|
}
|
|
|
|
|
|
2023-08-02 19:35:27 +01:00
|
|
|
function setCourseData(course = {}, lessons) {
|
2022-12-30 13:08:54 +01:00
|
|
|
courseData = { ...course, lessons };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$: triggerSetCourse($profile);
|
|
|
|
|
$: setCourseData($course, $lessons);
|
|
|
|
|
$: console.log('courseData changed', courseData);
|
2022-01-10 00:18:08 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="root absolute inset-0 flex justify-center items-center z-50 bg-white"
|
|
|
|
|
in:fly={{ y: 500, duration: 500 }}
|
|
|
|
|
out:fly={{ y: 500, duration: 500 }}
|
|
|
|
|
>
|
2022-12-30 13:08:54 +01:00
|
|
|
<Editor {courseId} bind:course={courseData} />
|
2022-01-10 00:18:08 +02:00
|
|
|
<div class="rightBar" class:isMobile={$isMobile}>
|
2022-12-30 13:08:54 +01:00
|
|
|
<CourseLandingPage bind:courseData />
|
2022-01-10 00:18:08 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.rightBar {
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
width: calc(100% - 360px);
|
|
|
|
|
overflow: auto;
|
|
|
|
|
height: 100%;
|
|
|
|
|
overflow: auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.rightBar.isMobile {
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|