Files
classroomio/apps/dashboard/src/lib/components/Courses/store.ts
T

48 lines
1.1 KiB
TypeScript
Raw Normal View History

import { writable, derived } from 'svelte/store';
2023-09-10 07:24:06 +01:00
import type { Course } from '$lib/utils/types';
2021-08-18 19:47:02 +03:00
2023-09-10 07:24:06 +01:00
export const courses = writable<Course[]>([]);
2024-04-20 14:40:44 +01:00
export const view = writable('grid');
export const coursesInProgress = derived(courses, ($courses) =>
$courses.length > 0
? $courses.filter((course) => {
return course.total_lessons !== course.progress_rate;
})
: []
);
export const coursesComplete = derived(courses, ($courses) =>
$courses.length > 0
? $courses.filter((course) => {
return course.total_lessons === course.progress_rate;
})
: []
);
2024-04-20 14:40:44 +01:00
export const courseMetaDeta = writable<{
isLoading: boolean;
view: 'grid' | 'list';
}>({
isLoading: true,
view: 'grid'
2021-12-30 22:30:30 +02:00
});
2021-08-18 19:47:02 +03:00
export const createCourseModal = writable({
title: '',
type: '',
2021-08-18 19:47:02 +03:00
description: '',
emails: '',
tutors: '',
students: ''
2021-08-18 19:47:02 +03:00
});
2021-12-30 22:30:30 +02:00
export const copyCourseModalInitialState = {
open: false,
courseIdToCopy: null,
id: '',
title: '',
isSaving: false,
error: null
2021-12-30 22:30:30 +02:00
};
2021-12-30 22:30:30 +02:00
export const copyCourseModal = writable({ ...copyCourseModalInitialState });