analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
66 lines • 2.26 kB
TypeScript
import type { BaseApiClient } from '../../types/api';
import type { ExamHistoryResponse, ExamTableItem, ExamHistoryFilters, ExamPagination, ExamApiFilterOptions } from '../../types/examsHistory';
/**
* Hook state interface
*/
export interface UseExamsHistoryState {
exams: ExamTableItem[];
loading: boolean;
error: string | null;
pagination: ExamPagination;
apiFilterOptions: ExamApiFilterOptions;
}
/**
* Hook return type
*/
export interface UseExamsHistoryReturn extends UseExamsHistoryState {
fetchExams: (filters?: ExamHistoryFilters) => Promise<void>;
}
/**
* Default pagination values
*/
export declare const DEFAULT_EXAMS_PAGINATION: ExamPagination;
/**
* Default API filter options
*/
export declare const DEFAULT_EXAM_FILTER_OPTIONS: ExamApiFilterOptions;
/**
* Transform API response to table item format
* @param exam - Exam from API response
* @returns Formatted exam for table display
*/
export declare const transformExamToTableItem: (exam: ExamHistoryResponse) => ExamTableItem;
/**
* Handle errors during exam fetch
* Uses the generic error handler factory to reduce code duplication
*/
export declare const handleExamFetchError: (error: unknown) => string;
/**
* Extract unique filter options from exams API response.
* Delegates to the shared extractBreakdownFilterOptions helper.
*/
export declare const extractExamFilterOptions: (exams: ExamHistoryResponse[]) => ExamApiFilterOptions;
/**
* Factory function to create useExamsHistory hook
*
* @param apiClient - API client instance (axios, fetch wrapper, etc.)
* @returns Hook for managing exams history
*
* @example
* ```tsx
* // In your app setup
* import { createUseExamsHistory } from 'analytica-frontend-lib';
* import api from '@/services/apiService';
*
* export const useExamsHistory = createUseExamsHistory(api);
*
* // In your component
* const { exams, loading, error, pagination, fetchExams } = useExamsHistory();
* ```
*/
export declare const createUseExamsHistory: (apiClient: BaseApiClient) => () => UseExamsHistoryReturn;
/**
* Alias for createUseExamsHistory
*/
export declare const createExamsHistoryHook: (apiClient: BaseApiClient) => () => UseExamsHistoryReturn;
//# sourceMappingURL=useExamsHistory.d.ts.map