2023-09-27 04:23:45 +01:00
|
|
|
<script lang="ts">
|
2021-08-29 07:23:19 +03:00
|
|
|
import Box from '../Box/index.svelte';
|
|
|
|
|
import Card from './components/Card/index.svelte';
|
2024-04-20 14:40:44 +01:00
|
|
|
import List from './components/List/index.svelte';
|
2023-01-03 09:26:08 +01:00
|
|
|
import CardLoader from './components/Card/Loader.svelte';
|
|
|
|
|
import CoursesEmptyIcon from '../Icons/CoursesEmptyIcon.svelte';
|
2023-09-27 04:23:45 +01:00
|
|
|
import { courseMetaDeta } from './store';
|
|
|
|
|
import type { Course } from '$lib/utils/types';
|
2024-02-01 20:18:03 +01:00
|
|
|
import { globalStore } from '$lib/utils/store/app';
|
2024-04-20 14:40:44 +01:00
|
|
|
import {
|
|
|
|
|
StructuredList,
|
|
|
|
|
StructuredListHead,
|
|
|
|
|
StructuredListRow,
|
|
|
|
|
StructuredListCell,
|
|
|
|
|
StructuredListBody
|
|
|
|
|
} from 'carbon-components-svelte';
|
2024-04-19 05:45:48 +01:00
|
|
|
import { t } from '$lib/utils/functions/translations';
|
2023-09-27 04:23:45 +01:00
|
|
|
|
|
|
|
|
export let courses: Course[] = [];
|
2024-04-20 15:05:45 +01:00
|
|
|
export let emptyTitle = $t('courses.course_card.empty_title');
|
|
|
|
|
export let emptyDescription = $t('courses.course_card.empty_description');
|
2024-07-09 21:17:34 +01:00
|
|
|
export let isExplore = false;
|
2023-09-28 11:45:50 +01:00
|
|
|
|
|
|
|
|
function calcProgressRate(progressRate?: number, totalLessons?: number): number {
|
|
|
|
|
if (!progressRate || !totalLessons) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Math.round((progressRate / totalLessons) * 100);
|
|
|
|
|
}
|
2021-05-06 08:22:25 +03:00
|
|
|
</script>
|
|
|
|
|
|
2023-09-28 11:45:50 +01:00
|
|
|
<!-- <CopyCourseModal /> -->
|
2021-12-30 22:30:30 +02:00
|
|
|
|
2024-04-20 14:40:44 +01:00
|
|
|
<div class={`w-full my-4 mx-auto`}>
|
2021-12-30 22:30:30 +02:00
|
|
|
{#if $courseMetaDeta.isLoading}
|
2024-04-20 14:40:44 +01:00
|
|
|
<section class={`${$courseMetaDeta.isLoading || courses ? 'cards-container' : ''} `}>
|
|
|
|
|
<CardLoader />
|
|
|
|
|
<CardLoader />
|
|
|
|
|
<CardLoader />
|
|
|
|
|
</section>
|
|
|
|
|
{:else if $courseMetaDeta.view === 'list'}
|
|
|
|
|
<StructuredList selection class="w-full">
|
|
|
|
|
<StructuredListHead>
|
|
|
|
|
<StructuredListRow head>
|
2024-04-20 15:05:45 +01:00
|
|
|
<StructuredListCell head>
|
|
|
|
|
{$t('courses.course_card.list_view.title')}
|
|
|
|
|
</StructuredListCell>
|
|
|
|
|
<StructuredListCell head>
|
|
|
|
|
{$t('courses.course_card.list_view.description')}
|
|
|
|
|
</StructuredListCell>
|
2024-05-21 00:14:47 +01:00
|
|
|
<StructuredListCell head>
|
|
|
|
|
{$t('courses.course_card.list_view.type')}
|
|
|
|
|
</StructuredListCell>
|
2024-04-20 15:05:45 +01:00
|
|
|
<StructuredListCell head>
|
|
|
|
|
{$t('courses.course_card.list_view.lessons')}
|
|
|
|
|
</StructuredListCell>
|
|
|
|
|
<StructuredListCell head>
|
|
|
|
|
{$t('courses.course_card.list_view.students')}
|
|
|
|
|
</StructuredListCell>
|
|
|
|
|
<StructuredListCell head>
|
|
|
|
|
{$t('courses.course_card.list_view.published')}
|
|
|
|
|
</StructuredListCell>
|
2024-04-20 14:40:44 +01:00
|
|
|
<StructuredListCell head>{''}</StructuredListCell>
|
|
|
|
|
</StructuredListRow>
|
|
|
|
|
</StructuredListHead>
|
|
|
|
|
<StructuredListBody>
|
|
|
|
|
{#each courses as courseData}
|
|
|
|
|
<List
|
|
|
|
|
id={courseData.id}
|
|
|
|
|
title={courseData.title}
|
2024-05-21 00:14:47 +01:00
|
|
|
type={$t(`course.navItem.settings.${courseData.type.toLowerCase()}`)}
|
2024-04-20 14:40:44 +01:00
|
|
|
description={courseData.description}
|
|
|
|
|
isPublished={courseData.is_published}
|
|
|
|
|
totalLessons={courseData.total_lessons}
|
|
|
|
|
totalStudents={courseData.total_students}
|
|
|
|
|
/>
|
|
|
|
|
{/each}
|
|
|
|
|
</StructuredListBody>
|
|
|
|
|
</StructuredList>
|
2021-12-30 22:30:30 +02:00
|
|
|
{:else}
|
2024-04-20 14:40:44 +01:00
|
|
|
<section class={`${$courseMetaDeta.isLoading || courses ? 'cards-container' : ''} `}>
|
|
|
|
|
{#each courses as courseData}
|
|
|
|
|
{#key courseData.id}
|
|
|
|
|
<Card
|
|
|
|
|
id={courseData.id}
|
2024-07-09 21:17:34 +01:00
|
|
|
slug={courseData.slug}
|
2024-04-20 14:40:44 +01:00
|
|
|
bannerImage={courseData.logo || '/images/classroomio-course-img-template.jpg'}
|
|
|
|
|
title={courseData.title}
|
|
|
|
|
description={courseData.description}
|
|
|
|
|
isPublished={courseData.is_published}
|
|
|
|
|
cost={courseData.cost}
|
2024-05-21 00:14:47 +01:00
|
|
|
type={courseData.type}
|
2024-04-20 14:40:44 +01:00
|
|
|
currency={courseData.currency}
|
|
|
|
|
totalLessons={courseData.total_lessons}
|
|
|
|
|
totalStudents={courseData.total_students}
|
|
|
|
|
isLMS={$globalStore.isOrgSite}
|
2024-07-09 21:17:34 +01:00
|
|
|
{isExplore}
|
2024-04-20 14:40:44 +01:00
|
|
|
progressRate={calcProgressRate(courseData.progress_rate, courseData.total_lessons)}
|
|
|
|
|
/>
|
|
|
|
|
{/key}
|
|
|
|
|
{/each}
|
|
|
|
|
</section>
|
2021-12-30 22:30:30 +02:00
|
|
|
{/if}
|
2021-05-07 03:43:37 +03:00
|
|
|
</div>
|
2023-09-27 04:23:45 +01:00
|
|
|
{#if !$courseMetaDeta.isLoading && !courses.length}
|
2023-09-08 09:17:05 +00:00
|
|
|
<Box className="w-full">
|
|
|
|
|
<CoursesEmptyIcon />
|
2023-09-30 09:56:42 +01:00
|
|
|
<h3 class="dark:text-white text-2xl my-5">{emptyTitle}</h3>
|
2023-09-08 09:17:05 +00:00
|
|
|
<p class="dark:text-white w-1/3 text-center">
|
2023-09-30 09:56:42 +01:00
|
|
|
{emptyDescription}
|
2023-09-08 09:17:05 +00:00
|
|
|
</p>
|
|
|
|
|
</Box>
|
|
|
|
|
{/if}
|