import request from '@/utils/request';

export interface ActivityStats {
    activityId: number;
    activityTitle: string;
    registeredCount: number;
    checkedInCount: number;
    checkInRate: number;
    reviewCount: number;
    averageRating: number;
    ratingDistribution: Record<string, number>;
}

export interface OverviewStats {
    totalActivities: number;
    totalRegistrations: number;
    totalCheckIns: number;
    totalReviews: number;
    averageRating: number;
    monthlyStats: {
        month: string;
        activityCount: number;
        registrationCount: number;
    }[];
}

export const getActivityStats = (activityId: number) => {
    return request.get<any, ActivityStats>(`/statistics/activity/${activityId}`);
};

export const getOverviewStats = () => {
    return request.get<any, OverviewStats>('/statistics/overview');
};

export const exportActivityStats = (activityId: number, format = 'csv') => {
    // Return blob or handle download
    return request.get(`/statistics/activity/${activityId}/export`, {
        params: { format },
        responseType: 'blob'
    });
};
