CLASSROOMIO-T-152: Landing page fully ready
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
export const load = ({ params = { slug: '' } }) => {
|
||||
import { fetchCourse } from '$lib/utils/services/courses';
|
||||
import { supabase, getSupabase } from '$lib/utils/functions/supabase';
|
||||
|
||||
if (!supabase) {
|
||||
getSupabase();
|
||||
}
|
||||
|
||||
export const load = async ({ params = { slug: '' } }) => {
|
||||
const { data } = await fetchCourse(undefined, params.slug);
|
||||
|
||||
return {
|
||||
slug: params.slug,
|
||||
course: data
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,39 +1,21 @@
|
||||
<script>
|
||||
import Backdrop from '$lib/components/Backdrop/index.svelte';
|
||||
import { Moon } from 'svelte-loading-spinners';
|
||||
<script lang="ts">
|
||||
import CourseLandingPage from '$lib/components/CourseLandingPage/index.svelte';
|
||||
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';
|
||||
import { browser } from '$app/environment';
|
||||
import type { Course } from '$lib/utils/types';
|
||||
|
||||
export let data;
|
||||
interface Data {
|
||||
course: Course;
|
||||
}
|
||||
export let data: Data;
|
||||
|
||||
let courseData = {};
|
||||
let loading = false;
|
||||
let courseData: Course;
|
||||
|
||||
async function triggerSetCourse(_profile) {
|
||||
if (!browser) return;
|
||||
loading = true;
|
||||
const { data: _data } = await fetchCourse(undefined, data.slug);
|
||||
setCourse(_data);
|
||||
loading = false;
|
||||
function setCourseData(course: Course | null) {
|
||||
if (!course) return;
|
||||
|
||||
courseData = { ...course };
|
||||
}
|
||||
|
||||
function setCourseData(course, lessons) {
|
||||
courseData = { ...course, lessons };
|
||||
console.log('courseData', courseData);
|
||||
}
|
||||
|
||||
$: triggerSetCourse($profile);
|
||||
$: setCourseData($course, $lessons);
|
||||
$: setCourseData(data.course);
|
||||
</script>
|
||||
|
||||
{#if loading}
|
||||
<Backdrop>
|
||||
<Moon size="60" color="#1d4ed8" unit="px" duration="1s" />
|
||||
</Backdrop>
|
||||
{:else}
|
||||
<CourseLandingPage {courseData} />
|
||||
{/if}
|
||||
<CourseLandingPage {courseData} />
|
||||
|
||||
Reference in New Issue
Block a user