2023-01-03 09:26:08 +01:00
|
|
|
<script lang="ts">
|
2021-12-30 22:30:30 +02:00
|
|
|
import Dropdown from '../../../Dropdown/index.svelte';
|
|
|
|
|
import { copyCourseModal } from '../../store';
|
|
|
|
|
import { ROLE } from '../../../../utils/constants/roles';
|
2023-01-03 09:26:08 +01:00
|
|
|
import getCurrencyFormatter from '../../../../utils/functions/getCurrencyFormatter';
|
|
|
|
|
import OverflowMenuHorizontal24 from 'carbon-icons-svelte/lib/OverflowMenuHorizontal24';
|
|
|
|
|
|
|
|
|
|
export let bannerImage: string | undefined;
|
2021-08-29 07:23:19 +03:00
|
|
|
export let id = '';
|
|
|
|
|
export let title = '';
|
|
|
|
|
export let description = '';
|
2021-12-30 22:30:30 +02:00
|
|
|
export let role_id = ROLE.STUDENT;
|
2023-01-03 09:26:08 +01:00
|
|
|
export let isPublished = false;
|
|
|
|
|
export let cost = 0;
|
2023-01-03 09:53:20 +01:00
|
|
|
export let totalLessons = 0;
|
2023-01-03 09:26:08 +01:00
|
|
|
export let currency = 'NGN';
|
|
|
|
|
|
|
|
|
|
let formatter = getCurrencyFormatter(currency);
|
2021-12-30 22:30:30 +02:00
|
|
|
|
|
|
|
|
function getOptions() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
label: 'Make a copy',
|
|
|
|
|
// Show this option only if user has admin control over this course.
|
|
|
|
|
show: () => role_id === ROLE.ADMIN || role_id === ROLE.TUTOR,
|
|
|
|
|
onClick() {
|
|
|
|
|
// IIFI of copyCourseModal
|
|
|
|
|
(() => {
|
|
|
|
|
$copyCourseModal.id = id;
|
|
|
|
|
$copyCourseModal.open = true;
|
|
|
|
|
$copyCourseModal.title = `Copy of ${title}`;
|
|
|
|
|
})();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// label: 'Delete',
|
|
|
|
|
// onClick() {
|
|
|
|
|
// console.log('Deleting');
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
].filter((option) => option.show());
|
|
|
|
|
}
|
2021-08-29 07:23:19 +03:00
|
|
|
</script>
|
|
|
|
|
|
2023-05-05 20:19:45 +00:00
|
|
|
<a rel="prefetch" href="/courses/{id}" class=" text-black">
|
2023-01-03 09:26:08 +01:00
|
|
|
<div
|
2023-05-11 15:15:18 +00:00
|
|
|
class="root w-72 border bg-gray-100 dark:bg-gray-700 mr-4 mb-4 rounded-md transition ease-in-out relative"
|
2021-12-30 22:30:30 +02:00
|
|
|
>
|
2023-01-03 09:26:08 +01:00
|
|
|
<Dropdown
|
|
|
|
|
options={getOptions()}
|
|
|
|
|
classNames="absolute top-4 right-4"
|
|
|
|
|
isIcon={true}
|
2021-08-29 07:23:19 +03:00
|
|
|
>
|
2023-05-05 20:19:45 +00:00
|
|
|
<div class="p-1 rounded-full bg-white dark:bg-gray-600">
|
2023-01-03 09:26:08 +01:00
|
|
|
<OverflowMenuHorizontal24 class="carbon-icon" />
|
|
|
|
|
</div>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
<img
|
|
|
|
|
class="h-2/5 w-full rounded-tl rounded-tr"
|
|
|
|
|
src={bannerImage ?? '/images/classroomio-course-img-template.jpg'}
|
|
|
|
|
alt="Course Logo"
|
|
|
|
|
/>
|
|
|
|
|
<div class="p-3 pb-0">
|
2023-05-05 20:19:45 +00:00
|
|
|
<h4 class="dark:text-white title text-md font-bold">
|
2023-01-03 09:26:08 +01:00
|
|
|
{title}
|
|
|
|
|
</h4>
|
|
|
|
|
<p
|
2023-05-05 20:19:45 +00:00
|
|
|
class="description text-left text-sm font-small flex flex-col text-gray-500 dark:text-gray-200 my-3"
|
2023-01-03 09:26:08 +01:00
|
|
|
title={description}
|
|
|
|
|
>
|
|
|
|
|
{description}
|
|
|
|
|
</p>
|
|
|
|
|
<div class="flex justify-between">
|
2023-05-05 20:19:45 +00:00
|
|
|
<p class="dark:text-white">{totalLessons} lessons</p>
|
2023-01-03 09:26:08 +01:00
|
|
|
<div class="rounded bg-{isPublished ? 'green' : 'red'}-200 py-1 px-2">
|
|
|
|
|
{#if isPublished}
|
|
|
|
|
Published
|
|
|
|
|
{:else}
|
|
|
|
|
Unpublished
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-05-05 20:19:45 +00:00
|
|
|
<p class="dark:text-white text-gray-500 text-xs mt-1">
|
2023-01-03 09:26:08 +01:00
|
|
|
{!cost ? 'free' : formatter.format(cost)}
|
|
|
|
|
</p>
|
2021-08-29 07:23:19 +03:00
|
|
|
</div>
|
2023-01-03 09:26:08 +01:00
|
|
|
</div>
|
|
|
|
|
</a>
|
2021-08-29 07:23:19 +03:00
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.root {
|
2023-01-03 09:26:08 +01:00
|
|
|
min-height: 370px;
|
2021-08-29 07:23:19 +03:00
|
|
|
}
|
|
|
|
|
|
2021-12-30 22:30:30 +02:00
|
|
|
a {
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
}
|
2023-01-03 09:26:08 +01:00
|
|
|
.title,
|
2021-08-29 07:23:19 +03:00
|
|
|
.description {
|
2023-01-03 09:26:08 +01:00
|
|
|
height: 40px;
|
2021-08-29 07:23:19 +03:00
|
|
|
line-height: 20px;
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
-moz-box-orient: vertical;
|
|
|
|
|
-ms-box-orient: vertical;
|
|
|
|
|
box-orient: vertical;
|
2023-01-03 09:26:08 +01:00
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
-moz-line-clamp: 2;
|
|
|
|
|
-ms-line-clamp: 2;
|
|
|
|
|
line-clamp: 2;
|
2021-08-29 07:23:19 +03:00
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
</style>
|