feat: add reviews, notifications, notes and account hardening
All checks were successful
CI / Validate frontend and API (push) Successful in 59s
CI / Build and publish Docker images (push) Successful in 23s

This commit is contained in:
Cauê Faleiros
2026-11-05 17:27:36 -03:00
parent 21085e887d
commit fff63f5efa
32 changed files with 1109 additions and 84 deletions

View File

@@ -420,3 +420,72 @@ export const getCommunityComments = async (limit = 100, offset = 0): Promise<Com
const response = await apiRequest<{ data: ApiComment[] }>(`/community/comments?limit=${limit}&offset=${offset}`);
return response.data.map(toComment);
};
export type LearningStats = {
watchedSeconds: number;
completedLessons: number;
activeCourses: number;
weeklyCompleted: number;
streakDays: number;
};
export const getLearningStats = async (): Promise<LearningStats> => {
const response = await apiRequest<{ data: LearningStats }>('/courses/me/learning/stats');
return response.data;
};
export type CourseReview = {
rating: number;
comment: string;
updatedAt: string;
userName: string;
};
export type MyCourseReview = {
rating: number;
comment: string;
updatedAt: string;
};
export type CourseReviewSummary = {
average: number;
count: number;
reviews: CourseReview[];
};
export const getCourseReviews = async (courseId: string): Promise<CourseReviewSummary> => {
const response = await apiRequest<{ data: CourseReviewSummary }>(`/courses/${courseId}/reviews`);
return response.data;
};
export const getMyCourseReview = async (courseId: string): Promise<MyCourseReview | null> => {
const response = await apiRequest<{ data: MyCourseReview | null }>(`/courses/${courseId}/reviews/mine`);
return response.data;
};
export const saveCourseReview = async (courseId: string, rating: number, comment: string): Promise<{ review: MyCourseReview; summary: CourseReviewSummary }> => {
const response = await apiRequest<{ data: { review: MyCourseReview; summary: CourseReviewSummary } }>(`/courses/${courseId}/reviews/mine`, {
method: 'PUT',
body: JSON.stringify({ rating, comment }),
});
return response.data;
};
export const deleteMyCourseReview = async (courseId: string): Promise<void> => {
await apiRequest<void>(`/courses/${courseId}/reviews/mine`, { method: 'DELETE' });
};
export type LessonNote = { body: string; updatedAt: string | null };
export const getLessonNote = async (lessonId: string): Promise<LessonNote> => {
const response = await apiRequest<{ data: LessonNote }>(`/lessons/${lessonId}/note`);
return response.data;
};
export const saveLessonNote = async (lessonId: string, body: string): Promise<LessonNote> => {
const response = await apiRequest<{ data: LessonNote }>(`/lessons/${lessonId}/note`, {
method: 'PUT',
body: JSON.stringify({ body }),
});
return response.data;
};