File size: 2,392 Bytes
9a92a42 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | import api from './axiosInstance.api';
export interface ActivityLog {
_id: string;
user: {
_id: string;
username: string;
email: string;
profilePhoto: string;
role: string;
};
action: string;
category: string;
description: string;
metadata: any;
timestamp: string;
success: boolean;
}
export interface ActivityTimelineResponse {
activities: ActivityLog[];
pagination: {
total: number;
limit: number;
skip: number;
pages: number;
};
}
/**
* Get user activity timeline
*/
export const getUserActivityTimeline = async (params: {
userId?: string;
role?: string;
limit?: number;
skip?: number;
startDate?: string;
endDate?: string;
category?: string;
action?: string;
}): Promise<ActivityTimelineResponse> => {
const response = await api.get<{ success: boolean; data: ActivityTimelineResponse }>('/activity/timeline', { params });
return response.data.data;
};
/**
* Get dashboard overview stats
*/
export const getDashboardOverview = async (params: {
startDate?: string;
endDate?: string;
organization?: string;
} = {}): Promise<any> => {
const response = await api.get('/analytics/overview', { params });
return response.data;
};
/**
* Get theme coverage stats
*/
export const getThemeCoverage = async (params: {
startDate?: string;
endDate?: string;
organization?: string;
} = {}): Promise<any> => {
const response = await api.get('/analytics/theme-coverage', { params });
return response.data;
};
/**
* Get organization statistics
*/
export const getOrganizationStats = async (params: {
startDate?: string;
endDate?: string;
} = {}): Promise<any> => {
const response = await api.get('/analytics/organizations', { params });
return response.data;
};
/**
* Get system-wide recent activities (admin only)
*/
export const getSystemRecentActivities = async (params: {
limit?: number;
skip?: number;
} = {}): Promise<ActivityTimelineResponse> => {
const response = await api.get<{ success: boolean; data: ActivityTimelineResponse }>('/activity/recent', { params });
return response.data.data;
};
export default {
getUserActivityTimeline,
getDashboardOverview,
getThemeCoverage,
getOrganizationStats,
getSystemRecentActivities
};
|