2023-09-29 09:25:32 +01:00
|
|
|
<script lang="ts">
|
2023-08-15 14:28:51 +00:00
|
|
|
import { goto } from '$app/navigation';
|
2025-12-22 02:36:48 +01:00
|
|
|
import { Button } from '@cio/ui/base/button';
|
|
|
|
|
import { courses } from '$features/course/utils/store';
|
2024-04-19 05:45:48 +01:00
|
|
|
import { t } from '$lib/utils/functions/translations';
|
2025-12-02 09:54:38 +01:00
|
|
|
import { Empty } from '@cio/ui/custom/empty';
|
|
|
|
|
import BookOpenIcon from '@lucide/svelte/icons/book-open';
|
2023-08-10 12:23:10 +00:00
|
|
|
|
2023-09-29 09:25:32 +01:00
|
|
|
const gotoCourse = (id: string | undefined) => {
|
|
|
|
|
if (!id) return;
|
2024-04-16 08:51:53 +01:00
|
|
|
goto(`/courses/${id}/lessons?next=true`);
|
2023-08-15 14:28:51 +00:00
|
|
|
};
|
2024-05-21 00:14:47 +01:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
let last3Courses = $derived($courses.length > 0 ? $courses.slice(0, 3) : []);
|
2023-08-10 12:23:10 +00:00
|
|
|
</script>
|
|
|
|
|
|
2023-09-30 09:56:42 +01:00
|
|
|
<section class="h-full">
|
2025-11-01 15:49:29 +01:00
|
|
|
<p class="pb-3 text-base font-semibold text-[#040F2D] dark:text-white">
|
2024-04-19 05:45:48 +01:00
|
|
|
{$t('dashboard.current_lesson')}
|
|
|
|
|
</p>
|
2023-08-15 14:28:51 +00:00
|
|
|
<div
|
2025-11-01 15:49:29 +01:00
|
|
|
class="flex w-full flex-col items-center gap-2 rounded border border-[#EAEAEA] p-3 lg:h-[40vh] dark:bg-neutral-800"
|
2023-08-11 17:11:19 +00:00
|
|
|
>
|
2024-05-21 00:14:47 +01:00
|
|
|
{#if last3Courses.length > 0}
|
2025-11-01 15:49:29 +01:00
|
|
|
<div class="flex h-full w-full flex-col justify-start overflow-y-auto">
|
2024-05-21 00:14:47 +01:00
|
|
|
{#each last3Courses as course}
|
2023-08-10 12:23:10 +00:00
|
|
|
<div class="p-5">
|
2025-11-01 15:49:29 +01:00
|
|
|
<span class="flex flex-col items-start gap-3 pb-5 lg:flex-row">
|
2023-09-29 09:25:32 +01:00
|
|
|
<img
|
|
|
|
|
src={course.logo || '/images/classroomio-course-img-template.jpg'}
|
|
|
|
|
alt="course"
|
2025-11-01 15:49:29 +01:00
|
|
|
class="hidden lg:block lg:h-[60px] lg:w-[60px]"
|
2023-09-29 09:25:32 +01:00
|
|
|
/>
|
2023-08-10 12:23:10 +00:00
|
|
|
<div class="w-full">
|
2023-09-29 09:25:32 +01:00
|
|
|
<p class="text-base font-semibold dark:text-white">{course.title}</p>
|
2023-08-15 14:28:51 +00:00
|
|
|
<p class="line-clamp-2 text-xs font-normal text-[#656565] dark:text-white">
|
2023-09-29 09:25:32 +01:00
|
|
|
{course.description}
|
2023-08-15 14:28:51 +00:00
|
|
|
</p>
|
2023-08-10 12:23:10 +00:00
|
|
|
</div>
|
2025-12-22 02:36:48 +01:00
|
|
|
<Button variant="outline" onclick={() => gotoCourse(course.id)}>
|
|
|
|
|
{$t('dashboard.continue')}
|
|
|
|
|
</Button>
|
2023-08-10 12:23:10 +00:00
|
|
|
</span>
|
2025-11-01 15:49:29 +01:00
|
|
|
<div class="relative h-1 w-full bg-[#EAEAEA]">
|
2023-09-29 09:25:32 +01:00
|
|
|
<div
|
2025-11-01 15:49:29 +01:00
|
|
|
style="width: {Math.round(((course?.progress_rate ?? 0) / (course?.total_lessons ?? 0)) * 100) || 0}%"
|
|
|
|
|
class="bg-primary-700 absolute left-0 top-0 h-full"
|
|
|
|
|
></div>
|
2023-08-10 12:23:10 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
2023-08-15 14:28:51 +00:00
|
|
|
{:else}
|
2025-12-02 09:54:38 +01:00
|
|
|
<Empty title={$t('dashboard.no_courses')} description={$t('dashboard.start_course')} icon={BookOpenIcon} />
|
2023-08-10 12:23:10 +00:00
|
|
|
{/if}
|
2023-08-15 14:28:51 +00:00
|
|
|
</div>
|
2023-08-10 12:23:10 +00:00
|
|
|
</section>
|