feat: expand admin and instructor tools
All checks were successful
CI / Validate frontend and API (push) Successful in 50s
CI / Build and publish Docker images (push) Successful in 20s

This commit is contained in:
Cauê Faleiros
2026-09-01 13:19:29 -03:00
parent caaf904281
commit 4736fb5208
13 changed files with 385 additions and 22 deletions

View File

@@ -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);