import request from '@/utils/request';

export interface CheckinResult {
    id: number;
    userId: number;
    userName: number;
    studentId: string;
    activityId: number;
    checkInTime: string;
}

export interface QrCodeData {
    qrCodeUrl: string;
    qrCodeContent: string;
    expiresAt: string;
}

// Admin: Generate Check-in QR for students to scan
export const generateCheckinQr = (activityId: number) => {
    return request.post<any, QrCodeData>(`/checkin/qrcode/${activityId}`);
};

// Student: Scan Activity QR to check in
export const scanCheckinQr = (qrCodeContent: string) => {
    return request.post<any, CheckinResult>('/checkin/scan', { qrCodeContent });
};

// Admin: Scan Student Ticket to check in
export const adminScanTicket = (activityId: number, ticketCode: string) => {
    return request.post<any, CheckinResult>('/checkin/ticket', { activityId, ticketCode });
};

// Get check-in records for activity
export const getCheckinRecords = (activityId: number) => {
    return request.get<any, { records: CheckinResult[]; total: number }>(`/checkin/activity/${activityId}`);
};
