feat: finalize academy redesign and production readiness
Align admin, community, search, library, learning and course management with the mockup. Add saved courses, download history, public community feed, instructor directory, backend search, course views, admin content tools and community moderation. Harden API and Nginx for production.
This commit is contained in:
@@ -34,13 +34,35 @@ export interface ManagedUser {
|
||||
role: ApiRole;
|
||||
isActive: boolean;
|
||||
createdAt: string;
|
||||
lastAccessAt: string | null;
|
||||
}
|
||||
export interface ManagedUserDetail extends ManagedUser {
|
||||
completedLessons: number;
|
||||
lastLearningAt: string | null;
|
||||
}
|
||||
export interface PlatformAnalytics { totalUsers: number; activeUsers: number; publishedCourses: number; completedLessons: number; comments: number; }
|
||||
export interface InstructorAnalytics { courses: number; lessons: number; learners: number; completedLessons: number; comments: number; }
|
||||
export interface PlatformAnalytics { totalUsers: number; activeUsers: number; publishedCourses: number; completedLessons: number; comments: number; pendingInvitations: number; }
|
||||
export interface InstructorAnalytics { courses: number; lessons: number; learners: number; completedLessons: number; comments: number; unansweredComments: number; }
|
||||
export interface InstructorSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
role: ApiRole;
|
||||
avatarImageUrl: string | null;
|
||||
headline: string;
|
||||
courseCount: number;
|
||||
}
|
||||
export interface DownloadRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
kind: 'document' | 'spreadsheet' | 'archive' | 'image' | 'link';
|
||||
url: string;
|
||||
sizeBytes: number | null;
|
||||
description: string;
|
||||
createdAt: string;
|
||||
courseId: string | null;
|
||||
courseTitle: string | null;
|
||||
lessonNumber: number | null;
|
||||
downloadedAt: string;
|
||||
}
|
||||
export interface AuditEntry { id: string; action: string; subjectType: string; subjectId: string | null; metadata: Record<string, unknown>; createdAt: string; actorName: string; }
|
||||
export interface BunnyVideo { id: string; title: string; status: 'processing' | 'ready' | 'failed'; providerStatus: number; encodeProgress: number; durationSeconds: number | null; }
|
||||
export interface LessonPlayback { provider: string; kind: 'embed' | 'video'; embedUrl?: string; source?: string; expiresAt?: string; }
|
||||
@@ -239,6 +261,7 @@ export const profileApi = {
|
||||
async update(input: ProfileInput) { return apiRequest<{ data: Profile }>('/profiles/me', { method: 'PATCH', body: JSON.stringify(input) }); },
|
||||
async public(profileId: string) { return apiRequest<{ data: Profile & { courses: unknown[] } }>(`/profiles/${profileId}`); },
|
||||
async instructor(instructorId: string) { return apiRequest<{ data: Profile & { courses: unknown[] } }>(`/profiles/instructors/${instructorId}`); },
|
||||
async instructors() { return apiRequest<{ data: InstructorSummary[] }>('/profiles/instructors'); },
|
||||
};
|
||||
|
||||
export const instructorApi = {
|
||||
@@ -267,4 +290,18 @@ export const courseApi = {
|
||||
async playback(courseId: string, lessonId: string) {
|
||||
return apiRequest<{ data: LessonPlayback }>(`/courses/${courseId}/lessons/${lessonId}/playback`);
|
||||
},
|
||||
async trackView(courseId: string) {
|
||||
return apiRequest<{ data: { views: number } }>(`/courses/${courseId}/view`, { method: 'POST' });
|
||||
},
|
||||
};
|
||||
|
||||
export const savedCourseApi = {
|
||||
async list() { return apiRequest<{ data: Array<{ courseId: string; createdAt: string }> }>('/saved-courses'); },
|
||||
async save(courseId: string) { return apiRequest<void>(`/saved-courses/${courseId}`, { method: 'PUT' }); },
|
||||
async remove(courseId: string) { return apiRequest<void>(`/saved-courses/${courseId}`, { method: 'DELETE' }); },
|
||||
};
|
||||
|
||||
export const downloadApi = {
|
||||
async list() { return apiRequest<{ data: DownloadRecord[] }>('/downloads'); },
|
||||
async record(assetId: string) { return apiRequest<void>(`/downloads/${assetId}`, { method: 'POST' }); },
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Attachment, AttachmentType, Comment, Course, Lesson, LessonMedia } from '../types';
|
||||
import { apiRequest } from './api';
|
||||
import { apiRequest, courseApi, downloadApi, DownloadRecord, InstructorSummary } from './api';
|
||||
|
||||
export const initDB = async (): Promise<void> => undefined;
|
||||
|
||||
@@ -24,6 +24,9 @@ export type ApiCourse = {
|
||||
coverImagePositionY: number;
|
||||
status: 'draft' | 'published' | 'archived';
|
||||
progress?: number;
|
||||
views?: number;
|
||||
learners?: number;
|
||||
updatedAt?: string;
|
||||
lastActivity?: string | null;
|
||||
instructor: { id: string; name: string };
|
||||
lessons: Array<{
|
||||
@@ -133,6 +136,9 @@ export const toCourse = (course: ApiCourse): Course => ({
|
||||
instructorId: course.instructor.id,
|
||||
status: course.status === 'draft' ? 'draft' : 'published',
|
||||
progress: course.progress,
|
||||
views: course.views,
|
||||
learners: course.learners,
|
||||
updatedAt: course.updatedAt,
|
||||
lastActivity: course.lastActivity || undefined,
|
||||
duration: toCourseDuration(course.lessons),
|
||||
lessons: course.lessons.map((lesson): Lesson => {
|
||||
@@ -367,4 +373,50 @@ export const saveLessonProgress = async (lessonId: string, watchedSeconds: numbe
|
||||
await apiRequest(`/lessons/${lessonId}/progress`, { method: 'PUT', body: JSON.stringify({ watchedSeconds }) });
|
||||
};
|
||||
|
||||
export const incrementViews = async (_courseId: string): Promise<void> => undefined;
|
||||
export const incrementViews = async (courseId: string): Promise<void> => {
|
||||
await courseApi.trackView(courseId).catch(() => undefined);
|
||||
};
|
||||
|
||||
export type SearchResults = {
|
||||
courses: Course[];
|
||||
paths: PublicLearningPath[];
|
||||
professors: InstructorSummary[];
|
||||
};
|
||||
|
||||
export const searchCatalog = async (query: string, area = ''): Promise<SearchResults> => {
|
||||
const params = new URLSearchParams({ q: query });
|
||||
if (area) params.set('area', area);
|
||||
const response = await apiRequest<{ data: { courses: ApiCourse[]; paths: PublicLearningPath[]; professors: InstructorSummary[] } }>(`/search?${params.toString()}`);
|
||||
return {
|
||||
...response.data,
|
||||
courses: response.data.courses.map(toCourse),
|
||||
};
|
||||
};
|
||||
|
||||
export type DownloadHistoryEntry = {
|
||||
attachment: Attachment;
|
||||
courseId: string;
|
||||
courseTitle: string;
|
||||
lessonNumber: number | null;
|
||||
downloadedAt: string;
|
||||
};
|
||||
|
||||
export const getDownloadHistory = async (): Promise<DownloadHistoryEntry[]> => {
|
||||
const response = await downloadApi.list();
|
||||
return response.data.map((record: DownloadRecord) => ({
|
||||
attachment: toAttachment(record),
|
||||
courseId: record.courseId || '',
|
||||
courseTitle: record.courseTitle || 'Curso removido',
|
||||
lessonNumber: record.lessonNumber,
|
||||
downloadedAt: record.downloadedAt,
|
||||
}));
|
||||
};
|
||||
|
||||
export const recordDownloadHistory = async (assetId: string): Promise<void> => {
|
||||
await downloadApi.record(assetId);
|
||||
};
|
||||
|
||||
export const getCommunityComments = async (limit = 100, offset = 0): Promise<Comment[]> => {
|
||||
const response = await apiRequest<{ data: ApiComment[] }>(`/community/comments?limit=${limit}&offset=${offset}`);
|
||||
return response.data.map(toComment);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user