feat: expand admin and instructor tools
This commit is contained in:
@@ -101,6 +101,7 @@ const toCoursePayload = (course: Course) => ({
|
||||
status: 'published' as const,
|
||||
assets: (course.attachments || []).filter((attachment) => attachment.url && attachment.url !== '#').map(toAssetPayload),
|
||||
lessons: course.lessons.map((lesson) => ({
|
||||
id: /^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(lesson.id) ? lesson.id : undefined,
|
||||
title: lesson.title,
|
||||
description: lesson.description || '',
|
||||
durationSeconds: toSeconds(lesson.duration),
|
||||
@@ -182,6 +183,14 @@ export const saveComment = async (comment: Pick<Comment, 'courseId' | 'lessonId'
|
||||
return toComment(response.data);
|
||||
};
|
||||
|
||||
export const replyToComment = async (commentId: string, text: string): Promise<void> => {
|
||||
await apiRequest(`/comments/${commentId}/reply`, { method: 'PUT', body: JSON.stringify({ text }) });
|
||||
};
|
||||
|
||||
export const moderateComment = async (commentId: string): Promise<void> => {
|
||||
await apiRequest(`/comments/${commentId}`, { method: 'DELETE' });
|
||||
};
|
||||
|
||||
export const getCompletedLessonIds = async (courseId: string): Promise<string[]> => {
|
||||
const response = await apiRequest<{ data: Array<{ lessonId: string; completedAt: string | null }> }>(`/courses/${courseId}/progress`);
|
||||
return response.data.filter((progress) => progress.completedAt).map((progress) => progress.lessonId);
|
||||
|
||||
Reference in New Issue
Block a user