feat(dashboard): add content page options menu (#757)
* feat(dashboard): add content page options menu Add a three-dot menu on the course Content page with actions to unlock all locked lessons/exercises and toggle content grouping. Reuse shared locked-content collection logic from course settings. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(dashboard): keep unlock-all enabled and add menu icons Show a success snackbar when all content is already unlocked instead of disabling the action. Add lock-open and table-of-contents icons to menu items. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(dashboard): check courseApi.update return for grouping toggle Use the update() return value instead of courseApi.success, which can be false after a successful PUT if the follow-up refresh request fails. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> --------- Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>
This commit is contained in:
co-authored by
Rotimi Best
parent
bfafc685e0
commit
656fa4fa7e
@@ -25,7 +25,6 @@
|
||||
import LockOpenIcon from '@lucide/svelte/icons/lock-open';
|
||||
import type { TCourseType } from '@cio/db/types';
|
||||
import type { Course } from '../utils/types';
|
||||
import { ContentType } from '@cio/utils/constants/content';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
import { isObject } from '$lib/utils/functions/isObject';
|
||||
import { snackbar } from '$features/ui/snackbar/store';
|
||||
@@ -33,6 +32,7 @@
|
||||
import { DEFAULT_COMPLIANCE_SETTINGS } from '../utils/compliance-utils';
|
||||
import { DeleteModal } from '$features/ui';
|
||||
import { contentApi, courseApi } from '$features/course/api';
|
||||
import { collectLockedContentItems } from '$features/course/utils/content-lock-utils';
|
||||
import { tagApi } from '$features/tag/api';
|
||||
import { uploadImage } from '$lib/utils/services/upload';
|
||||
import { copyToClipboard } from '$lib/utils/functions/formatYoutubeVideo';
|
||||
@@ -120,22 +120,6 @@
|
||||
|
||||
let isUnlockingAll = $state(false);
|
||||
|
||||
type LockedContentItem = { id: string; type: ContentType.Lesson | ContentType.Exercise };
|
||||
|
||||
function collectLockedContentItems(course: Course | null): LockedContentItem[] {
|
||||
const content = course?.content;
|
||||
if (!content) return [];
|
||||
|
||||
const items = content.grouped ? content.sections.flatMap((section) => section.items) : content.items;
|
||||
|
||||
return items
|
||||
.filter((item) => (item.isUnlocked ?? true) === false)
|
||||
.map((item) => ({
|
||||
id: item.id,
|
||||
type: item.type === ContentType.Exercise ? ContentType.Exercise : ContentType.Lesson
|
||||
}));
|
||||
}
|
||||
|
||||
const lockedContentItems = $derived(collectLockedContentItems(courseApi.course));
|
||||
const isLiveClassCourse = $derived(courseApi.course?.type === 'LIVE_CLASS');
|
||||
const showLockedContentNotice = $derived($settings.isPublished && lockedContentItems.length > 0);
|
||||
|
||||
Reference in New Issue
Block a user