* working on the course type * trying to mark it persist * almost done here * fixed sendig emtpy options bug * created migration file * created migration file * made updates based on PR review * merge * update course type card * add redirect logic with classroomio.com/new * make new course modal only open/close with url * feat: page active state (#315) * finished the active link state * updated the active link state based on review * simplify code --------- Co-authored-by: Rotimi Best <best@classroomio.com> * add type to course card --------- Co-authored-by: Rotimi Best <best@classroomio.com>
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { writable, derived } from 'svelte/store';
|
|
import type { Course } from '$lib/utils/types';
|
|
|
|
export const courses = writable<Course[]>([]);
|
|
|
|
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;
|
|
})
|
|
: []
|
|
);
|
|
export const courseMetaDeta = writable<{
|
|
isLoading: boolean;
|
|
view: 'grid' | 'list';
|
|
}>({
|
|
isLoading: true,
|
|
view: 'grid'
|
|
});
|
|
|
|
export const createCourseModal = writable({
|
|
title: '',
|
|
type: '',
|
|
description: '',
|
|
emails: '',
|
|
tutors: '',
|
|
students: ''
|
|
});
|
|
|
|
export const copyCourseModalInitialState = {
|
|
open: false,
|
|
courseIdToCopy: null,
|
|
id: '',
|
|
title: '',
|
|
isSaving: false,
|
|
error: null
|
|
};
|
|
|
|
export const copyCourseModal = writable({ ...copyCourseModalInitialState });
|