66 lines
1.4 KiB
TypeScript
66 lines
1.4 KiB
TypeScript
import axios from 'axios';
|
|
|
|
interface ChartDataResponse<T> {
|
|
message: string;
|
|
data: T;
|
|
}
|
|
|
|
interface UserActivityData {
|
|
date: string;
|
|
count: number;
|
|
}
|
|
|
|
interface FileUploadsData {
|
|
month: string;
|
|
count: number;
|
|
}
|
|
|
|
interface FileTypesData {
|
|
type: string;
|
|
value: number;
|
|
}
|
|
|
|
interface DashboardOverviewData {
|
|
userCount: number;
|
|
fileCount: number;
|
|
articleCount: number;
|
|
todayLoginCount: number;
|
|
}
|
|
|
|
export const ChartAPI = {
|
|
getUserActivity: async (): Promise<ChartDataResponse<UserActivityData[]>> => {
|
|
try {
|
|
const response = await axios.get('/charts/user-activity');
|
|
return response.data;
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
},
|
|
|
|
getFileUploads: async (): Promise<ChartDataResponse<FileUploadsData[]>> => {
|
|
try {
|
|
const response = await axios.get('/charts/file-uploads');
|
|
return response.data;
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
},
|
|
|
|
getFileTypes: async (): Promise<ChartDataResponse<FileTypesData[]>> => {
|
|
try {
|
|
const response = await axios.get('/charts/file-types');
|
|
return response.data;
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
},
|
|
|
|
getDashboardOverview: async (): Promise<ChartDataResponse<DashboardOverviewData>> => {
|
|
try {
|
|
const response = await axios.get('/charts/dashboard-overview');
|
|
return response.data;
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
}
|
|
}; |