| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import axios from 'axios';
- const API_BASE_URL = '/api';
- 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(`${API_BASE_URL}/charts/user-activity`);
- return response.data;
- } catch (error) {
- throw error;
- }
- },
- getFileUploads: async (): Promise<ChartDataResponse<FileUploadsData[]>> => {
- try {
- const response = await axios.get(`${API_BASE_URL}/charts/file-uploads`);
- return response.data;
- } catch (error) {
- throw error;
- }
- },
- getFileTypes: async (): Promise<ChartDataResponse<FileTypesData[]>> => {
- try {
- const response = await axios.get(`${API_BASE_URL}/charts/file-types`);
- return response.data;
- } catch (error) {
- throw error;
- }
- },
- getDashboardOverview: async (): Promise<ChartDataResponse<DashboardOverviewData>> => {
- try {
- const response = await axios.get(`${API_BASE_URL}/charts/dashboard-overview`);
- return response.data;
- } catch (error) {
- throw error;
- }
- }
- };
|