feat: implement audit logging and add certificate template field to courses

This commit is contained in:
2025-12-23 11:04:36 -03:00
parent 72ddb43fd7
commit f695ed7213
14 changed files with 417 additions and 35 deletions
+24
View File
@@ -6,6 +6,7 @@ export interface Course {
description: string;
instructor_id: string;
passing_percentage: number;
certificate_template?: string;
created_at: string;
}
@@ -108,6 +109,18 @@ export interface AuthPayload {
role?: string;
}
export interface AuditLog {
id: string;
user_id: string;
user_full_name?: string;
action: string;
entity_type: string;
entity_id: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
changes: any;
created_at: string;
}
export const cmsApi = {
async getCourses(): Promise<Course[]> {
const response = await fetch(`${API_BASE_URL}/courses`);
@@ -277,5 +290,16 @@ export const cmsApi = {
});
if (!response.ok) throw new Error('Failed to update course');
return response.json();
},
async getAuditLogs(page: number = 1, limit: number = 50): Promise<AuditLog[]> {
const token = typeof window !== 'undefined' ? localStorage.getItem('studio_token') : null;
const response = await fetch(`${API_BASE_URL}/audit-logs?page=${page}&limit=${limit}`, {
headers: {
'Authorization': `Bearer ${token}`
}
});
if (!response.ok) throw new Error('Failed to fetch audit logs');
return response.json();
}
};