analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
355 lines • 11.4 kB
TypeScript
import { z } from 'zod';
import { GoalDisplayStatus } from '../types/recommendedLessons';
import type { GoalHistoryItem, GoalTableItem, GoalsHistoryApiResponse, GoalHistoryFilters, GoalHistoryPagination } from '../types/recommendedLessons';
export declare const goalsHistoryApiResponseSchema: z.ZodObject<{
message: z.ZodString;
data: z.ZodObject<{
goals: z.ZodArray<z.ZodObject<{
goal: z.ZodObject<{
id: z.ZodString;
title: z.ZodString;
startDate: z.ZodNullable<z.ZodString>;
finalDate: z.ZodNullable<z.ZodString>;
createdAt: z.ZodString;
progress: z.ZodNumber;
totalLessons: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
id: string;
title: string;
progress: number;
createdAt: string;
startDate: string | null;
finalDate: string | null;
totalLessons: number;
}, {
id: string;
title: string;
progress: number;
createdAt: string;
startDate: string | null;
finalDate: string | null;
totalLessons: number;
}>;
subject: z.ZodNullable<z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
name: string;
}, {
id: string;
name: string;
}>>;
creator: z.ZodNullable<z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
name: string;
}, {
id: string;
name: string;
}>>;
stats: z.ZodObject<{
totalStudents: z.ZodNumber;
completedCount: z.ZodNumber;
completionPercentage: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
completionPercentage: number;
totalStudents: number;
completedCount: number;
}, {
completionPercentage: number;
totalStudents: number;
completedCount: number;
}>;
breakdown: z.ZodArray<z.ZodObject<{
classId: z.ZodString;
className: z.ZodString;
schoolId: z.ZodString;
schoolName: z.ZodString;
studentCount: z.ZodNumber;
completedCount: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
className: string;
schoolName: string;
schoolId: string;
classId: string;
completedCount: number;
studentCount: number;
}, {
className: string;
schoolName: string;
schoolId: string;
classId: string;
completedCount: number;
studentCount: number;
}>, "many">;
}, "strip", z.ZodTypeAny, {
goal: {
id: string;
title: string;
progress: number;
createdAt: string;
startDate: string | null;
finalDate: string | null;
totalLessons: number;
};
subject: {
id: string;
name: string;
} | null;
creator: {
id: string;
name: string;
} | null;
stats: {
completionPercentage: number;
totalStudents: number;
completedCount: number;
};
breakdown: {
className: string;
schoolName: string;
schoolId: string;
classId: string;
completedCount: number;
studentCount: number;
}[];
}, {
goal: {
id: string;
title: string;
progress: number;
createdAt: string;
startDate: string | null;
finalDate: string | null;
totalLessons: number;
};
subject: {
id: string;
name: string;
} | null;
creator: {
id: string;
name: string;
} | null;
stats: {
completionPercentage: number;
totalStudents: number;
completedCount: number;
};
breakdown: {
className: string;
schoolName: string;
schoolId: string;
classId: string;
completedCount: number;
studentCount: number;
}[];
}>, "many">;
total: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
total: number;
goals: {
goal: {
id: string;
title: string;
progress: number;
createdAt: string;
startDate: string | null;
finalDate: string | null;
totalLessons: number;
};
subject: {
id: string;
name: string;
} | null;
creator: {
id: string;
name: string;
} | null;
stats: {
completionPercentage: number;
totalStudents: number;
completedCount: number;
};
breakdown: {
className: string;
schoolName: string;
schoolId: string;
classId: string;
completedCount: number;
studentCount: number;
}[];
}[];
}, {
total: number;
goals: {
goal: {
id: string;
title: string;
progress: number;
createdAt: string;
startDate: string | null;
finalDate: string | null;
totalLessons: number;
};
subject: {
id: string;
name: string;
} | null;
creator: {
id: string;
name: string;
} | null;
stats: {
completionPercentage: number;
totalStudents: number;
completedCount: number;
};
breakdown: {
className: string;
schoolName: string;
schoolId: string;
classId: string;
completedCount: number;
studentCount: number;
}[];
}[];
}>;
}, "strip", z.ZodTypeAny, {
data: {
total: number;
goals: {
goal: {
id: string;
title: string;
progress: number;
createdAt: string;
startDate: string | null;
finalDate: string | null;
totalLessons: number;
};
subject: {
id: string;
name: string;
} | null;
creator: {
id: string;
name: string;
} | null;
stats: {
completionPercentage: number;
totalStudents: number;
completedCount: number;
};
breakdown: {
className: string;
schoolName: string;
schoolId: string;
classId: string;
completedCount: number;
studentCount: number;
}[];
}[];
};
message: string;
}, {
data: {
total: number;
goals: {
goal: {
id: string;
title: string;
progress: number;
createdAt: string;
startDate: string | null;
finalDate: string | null;
totalLessons: number;
};
subject: {
id: string;
name: string;
} | null;
creator: {
id: string;
name: string;
} | null;
stats: {
completionPercentage: number;
totalStudents: number;
completedCount: number;
};
breakdown: {
className: string;
schoolName: string;
schoolId: string;
classId: string;
completedCount: number;
studentCount: number;
}[];
}[];
};
message: string;
}>;
/**
* Hook state interface
*/
export interface UseRecommendedLessonsHistoryState {
goals: GoalTableItem[];
loading: boolean;
error: string | null;
pagination: GoalHistoryPagination;
}
/**
* Hook return type
*/
export interface UseRecommendedLessonsHistoryReturn extends UseRecommendedLessonsHistoryState {
fetchGoals: (filters?: GoalHistoryFilters) => Promise<void>;
}
/**
* Determine status based on dates and completion
* @param finalDate - Goal final date
* @param completionPercentage - Completion percentage
* @returns Display status for UI
*/
export declare const determineGoalStatus: (finalDate: string | null, completionPercentage: number) => GoalDisplayStatus;
/**
* Transform API response to table item format
* @param item - Goal history item from API response
* @returns Formatted goal for table display
*/
export declare const transformGoalToTableItem: (item: GoalHistoryItem) => GoalTableItem;
/**
* Handle errors during goal fetch
* @param error - Error object
* @returns Error message for UI display
*/
export declare const handleGoalFetchError: (error: unknown) => string;
/**
* Factory function to create useRecommendedLessonsHistory hook
*
* @param fetchGoalsHistory - Function to fetch goals from API
* @returns Hook for managing recommended lessons history
*
* @example
* ```tsx
* // In your app setup
* const fetchGoalsHistory = async (filters) => {
* const response = await api.get('/recommended-class/history', { params: filters });
* return response.data;
* };
*
* const useGoalsHistory = createUseRecommendedLessonsHistory(fetchGoalsHistory);
*
* // In your component
* const { goals, loading, error, pagination, fetchGoals } = useGoalsHistory();
* ```
*/
export declare const createUseRecommendedLessonsHistory: (fetchGoalsHistory: (filters?: GoalHistoryFilters) => Promise<GoalsHistoryApiResponse>) => () => UseRecommendedLessonsHistoryReturn;
/**
* Alias for createUseRecommendedLessonsHistory
*/
export declare const createRecommendedLessonsHistoryHook: (fetchGoalsHistory: (filters?: GoalHistoryFilters) => Promise<GoalsHistoryApiResponse>) => () => UseRecommendedLessonsHistoryReturn;
//# sourceMappingURL=useRecommendedLessons.d.ts.map