UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

780 lines 23.9 kB
import { z } from 'zod'; import type { LessonDetailsData, GoalApiResponse, GoalDetailsApiResponse, GoalsHistoryApiResponse } from '../types/recommendedLessons'; /** * Schema for /goals/{id} API response */ export declare const goalApiResponseSchema: z.ZodObject<{ message: z.ZodString; data: z.ZodObject<{ id: z.ZodString; title: z.ZodString; startDate: z.ZodString; finalDate: z.ZodString; progress: z.ZodNumber; lessonsGoals: z.ZodArray<z.ZodObject<{ goalId: z.ZodString; supLessonsProgressId: z.ZodString; supLessonsProgress: z.ZodObject<{ id: z.ZodString; userId: z.ZodString; lessonId: z.ZodString; progress: z.ZodNumber; lesson: z.ZodObject<{ id: z.ZodString; content: z.ZodObject<{ id: z.ZodString; name: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; name: string; }, { id: string; name: string; }>; subtopic: z.ZodObject<{ id: z.ZodString; name: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; name: string; }, { id: string; name: string; }>; topic: z.ZodObject<{ id: z.ZodString; name: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; name: string; }, { id: string; name: string; }>; subject: z.ZodObject<{ id: z.ZodString; name: z.ZodString; color: z.ZodString; icon: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; name: string; color: string; icon: string; }, { id: string; name: string; color: string; icon: string; }>; }, "strip", z.ZodTypeAny, { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }, { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }>; }, "strip", z.ZodTypeAny, { id: string; progress: number; userId: string; lesson: { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }; lessonId: string; }, { id: string; progress: number; userId: string; lesson: { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }; lessonId: string; }>; }, "strip", z.ZodTypeAny, { goalId: string; supLessonsProgressId: string; supLessonsProgress: { id: string; progress: number; userId: string; lesson: { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }; lessonId: string; }; }, { goalId: string; supLessonsProgressId: string; supLessonsProgress: { id: string; progress: number; userId: string; lesson: { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }; lessonId: string; }; }>, "many">; }, "strip", z.ZodTypeAny, { id: string; title: string; progress: number; startDate: string; finalDate: string; lessonsGoals: { goalId: string; supLessonsProgressId: string; supLessonsProgress: { id: string; progress: number; userId: string; lesson: { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }; lessonId: string; }; }[]; }, { id: string; title: string; progress: number; startDate: string; finalDate: string; lessonsGoals: { goalId: string; supLessonsProgressId: string; supLessonsProgress: { id: string; progress: number; userId: string; lesson: { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }; lessonId: string; }; }[]; }>; }, "strip", z.ZodTypeAny, { data: { id: string; title: string; progress: number; startDate: string; finalDate: string; lessonsGoals: { goalId: string; supLessonsProgressId: string; supLessonsProgress: { id: string; progress: number; userId: string; lesson: { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }; lessonId: string; }; }[]; }; message: string; }, { data: { id: string; title: string; progress: number; startDate: string; finalDate: string; lessonsGoals: { goalId: string; supLessonsProgressId: string; supLessonsProgress: { id: string; progress: number; userId: string; lesson: { id: string; content: { id: string; name: string; }; subject: { id: string; name: string; color: string; icon: string; }; topic: { id: string; name: string; }; subtopic: { id: string; name: string; }; }; lessonId: string; }; }[]; }; message: string; }>; /** * Schema for /goals/{id}/details API response */ export declare const goalDetailsApiResponseSchema: z.ZodObject<{ message: z.ZodString; data: z.ZodObject<{ students: z.ZodArray<z.ZodObject<{ userInstitutionId: z.ZodString; userId: z.ZodString; name: z.ZodString; progress: z.ZodNumber; completedAt: z.ZodNullable<z.ZodString>; avgScore: z.ZodNullable<z.ZodNumber>; daysToComplete: z.ZodNullable<z.ZodNumber>; }, "strip", z.ZodTypeAny, { name: string; progress: number; userId: string; userInstitutionId: string; completedAt: string | null; avgScore: number | null; daysToComplete: number | null; }, { name: string; progress: number; userId: string; userInstitutionId: string; completedAt: string | null; avgScore: number | null; daysToComplete: number | null; }>, "many">; aggregated: z.ZodObject<{ completionPercentage: z.ZodNumber; avgScore: z.ZodNullable<z.ZodNumber>; }, "strip", z.ZodTypeAny, { completionPercentage: number; avgScore: number | null; }, { completionPercentage: number; avgScore: number | null; }>; contentPerformance: z.ZodObject<{ best: z.ZodNullable<z.ZodObject<{ contentId: z.ZodString; contentName: z.ZodString; rate: z.ZodNumber; }, "strip", z.ZodTypeAny, { contentId: string; contentName: string; rate: number; }, { contentId: string; contentName: string; rate: number; }>>; worst: z.ZodNullable<z.ZodObject<{ contentId: z.ZodString; contentName: z.ZodString; rate: z.ZodNumber; }, "strip", z.ZodTypeAny, { contentId: string; contentName: string; rate: number; }, { contentId: string; contentName: string; rate: number; }>>; }, "strip", z.ZodTypeAny, { best: { contentId: string; contentName: string; rate: number; } | null; worst: { contentId: string; contentName: string; rate: number; } | null; }, { best: { contentId: string; contentName: string; rate: number; } | null; worst: { contentId: string; contentName: string; rate: number; } | null; }>; }, "strip", z.ZodTypeAny, { students: { name: string; progress: number; userId: string; userInstitutionId: string; completedAt: string | null; avgScore: number | null; daysToComplete: number | null; }[]; aggregated: { completionPercentage: number; avgScore: number | null; }; contentPerformance: { best: { contentId: string; contentName: string; rate: number; } | null; worst: { contentId: string; contentName: string; rate: number; } | null; }; }, { students: { name: string; progress: number; userId: string; userInstitutionId: string; completedAt: string | null; avgScore: number | null; daysToComplete: number | null; }[]; aggregated: { completionPercentage: number; avgScore: number | null; }; contentPerformance: { best: { contentId: string; contentName: string; rate: number; } | null; worst: { contentId: string; contentName: string; rate: number; } | null; }; }>; }, "strip", z.ZodTypeAny, { data: { students: { name: string; progress: number; userId: string; userInstitutionId: string; completedAt: string | null; avgScore: number | null; daysToComplete: number | null; }[]; aggregated: { completionPercentage: number; avgScore: number | null; }; contentPerformance: { best: { contentId: string; contentName: string; rate: number; } | null; worst: { contentId: string; contentName: string; rate: number; } | null; }; }; message: string; }, { data: { students: { name: string; progress: number; userId: string; userInstitutionId: string; completedAt: string | null; avgScore: number | null; daysToComplete: number | null; }[]; aggregated: { completionPercentage: number; avgScore: number | null; }; contentPerformance: { best: { contentId: string; contentName: string; rate: number; } | null; worst: { contentId: string; contentName: string; rate: number; } | null; }; }; message: string; }>; /** * Schema for history API response (partial) */ export declare const historyApiResponseSchema: z.ZodObject<{ message: z.ZodString; data: z.ZodObject<{ goals: z.ZodArray<z.ZodObject<{ goal: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; 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; }; breakdown: { className: string; schoolName: string; schoolId: string; classId: string; completedCount: number; studentCount: number; }[]; }, { goal: { id: string; }; 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; }; breakdown: { className: string; schoolName: string; schoolId: string; classId: string; completedCount: number; studentCount: number; }[]; }[]; }, { total: number; goals: { goal: { id: string; }; breakdown: { className: string; schoolName: string; schoolId: string; classId: string; completedCount: number; studentCount: number; }[]; }[]; }>; }, "strip", z.ZodTypeAny, { data: { total: number; goals: { goal: { id: string; }; breakdown: { className: string; schoolName: string; schoolId: string; classId: string; completedCount: number; studentCount: number; }[]; }[]; }; message: string; }, { data: { total: number; goals: { goal: { id: string; }; breakdown: { className: string; schoolName: string; schoolId: string; classId: string; completedCount: number; studentCount: number; }[]; }[]; }; message: string; }>; /** * Hook state interface */ export interface UseRecommendedLessonDetailsState { data: LessonDetailsData | null; loading: boolean; error: string | null; } /** * Hook return type */ export interface UseRecommendedLessonDetailsReturn extends UseRecommendedLessonDetailsState { refetch: () => Promise<void>; } /** * API client interface for fetching lesson details */ export interface LessonDetailsApiClient { /** Fetch goal metadata from /goals/{id} */ fetchGoal: (id: string) => Promise<GoalApiResponse>; /** Fetch goal details from /goals/{id}/details */ fetchGoalDetails: (id: string) => Promise<GoalDetailsApiResponse>; /** Optional: Fetch breakdown from /recommended-class/history */ fetchBreakdown?: (id: string) => Promise<GoalsHistoryApiResponse>; } /** * Handle errors during lesson details fetch * @param error - Error object * @returns Error message for UI display */ export declare const handleLessonDetailsFetchError: (error: unknown) => string; /** * Factory function to create useRecommendedLessonDetails hook * * @param apiClient - Object containing API fetch functions * @returns Hook for managing recommended lesson details * * @example * ```tsx * // In your app setup * const apiClient = { * fetchGoal: async (id) => { * const response = await api.get(`/goals/${id}`); * return response.data; * }, * fetchGoalDetails: async (id) => { * const response = await api.get(`/goals/${id}/details`); * return response.data; * }, * fetchBreakdown: async (id) => { * const response = await api.get(`/recommended-class/history?search=${id}&limit=1`); * return response.data; * }, * }; * * const useGoalDetails = createUseRecommendedLessonDetails(apiClient); * * // In your component * const { data, loading, error, refetch } = useGoalDetails('goal-id-123'); * ``` */ export declare const createUseRecommendedLessonDetails: (apiClient: LessonDetailsApiClient) => (lessonId: string | undefined) => UseRecommendedLessonDetailsReturn; /** * Alias for createUseRecommendedLessonDetails */ export declare const createRecommendedLessonDetailsHook: (apiClient: LessonDetailsApiClient) => (lessonId: string | undefined) => UseRecommendedLessonDetailsReturn; //# sourceMappingURL=useRecommendedLessonDetails.d.ts.map