import { API } from '../api/API';

export const auditService = {
    /**
     * Get audit logs for a specific entity (e.g., application)
     * @param entityType - The type of entity (e.g., 'application', 'resignation', 'dealer')
     * @param entityId - The UUID of the entity
     * @param page - Page number for pagination (default: 1)
     * @param limit - Number of records per page (default: 50)
     */
    getAuditLogs: async (entityType: string, entityId: string, page: number = 1, limit: number = 50) => {
        try {
            const response: any = await API.getAuditLogs(entityType, entityId, page, limit);
            return response.data?.data || response.data || [];
        } catch (error) {
            console.error('Get audit logs error:', error);
            throw error;
        }
    },

    /**
     * Get audit summary/stats for a specific entity
     * @param entityType - The type of entity
     * @param entityId - The UUID of the entity
     */
    getAuditSummary: async (entityType: string, entityId: string) => {
        try {
            const response: any = await API.getAuditSummary(entityType, entityId);
            return response.data?.data || response.data;
        } catch (error) {
            console.error('Get audit summary error:', error);
            throw error;
        }
    }
};
