UNPKG

analytica-frontend-lib

Version:

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

176 lines 5.96 kB
import { type ReactNode } from 'react'; import { REPORT_PERIOD, REPORT_MODAL_VARIANT } from '../types/common'; /** * Query params for GET /performance/user/:userId */ export interface UserPerformanceRequest { userId: string; period: REPORT_PERIOD; classId?: string; } /** * Consolidated question statistics block. * Mirrors backend ConsolidatedQuestionStats. * * Note: `totalAnswered = correctQuestions + incorrectQuestions` (blank excluded). * To display the full total use `correctQuestions + incorrectQuestions + blankQuestions`. */ export interface UserPerformanceQuestionStats { totalAnswered: number; correctQuestions: number; correctPercentage: number; incorrectQuestions: number; incorrectPercentage: number; blankQuestions: number; blankPercentage: number; /** Localized label e.g. "Acima da média", "Abaixo da média" */ performanceTag: string; } /** * Downloaded lesson entry. * Mirrors backend DownloadedLesson. */ export interface UserPerformanceLesson { lessonId: string; lessonName: string; bnccCode: string | null; } /** * Full 200 response for STUDENT profile. * Mirrors backend StudentUserPerformance. */ export interface UserPerformanceStudentData { user: { id: string; name: string; }; school: { schoolId: string; schoolName: string; }; class: { classId: string; className: string; }; schoolYear: { schoolYearId: string; schoolYearName: string; }; /** Derived from generalStats.performanceTag e.g. "Abaixo da média" */ status: string; generalStats: UserPerformanceQuestionStats; activityStats: UserPerformanceQuestionStats; questionnaireStats: UserPerformanceQuestionStats; simulationStats: UserPerformanceQuestionStats; downloadedLessons: UserPerformanceLesson[]; } /** * Consolidated material production stats. * Mirrors backend ConsolidatedMaterialStats. */ export interface UserPerformanceMaterialStats { totalMaterialProduced: number; totalRecommendedLessons: number; recommendedLessonsPercentage: number; totalActivities: number; activitiesPercentage: number; } /** * Full 200 response for TEACHER / UNIT_MANAGER / REGIONAL_MANAGER profiles. * Mirrors backend ProfessionalUserPerformance. * * Note: no user/school/class context is returned for professional profiles. * Pass user display info via `professionalUserInfo` if needed. */ export interface UserPerformanceProfessionalData { generalStats: UserPerformanceMaterialStats; } /** @deprecated Use {@link REPORT_MODAL_VARIANT} instead. Re-exported for backwards compatibility. */ export { REPORT_MODAL_VARIANT as PerformanceReportModalVariant } from '../types/common'; interface PerformanceReportModalBaseProps { isOpen: boolean; onClose: () => void; /** Modal title (default: "Desempenho em 1 ano") */ title?: string; loading?: boolean; error?: string | null; } type PerformanceReportModalStudentProps = { variant: REPORT_MODAL_VARIANT.STUDENT; data: UserPerformanceStudentData | null; /** * Optional icon mapper for the downloaded lessons table. * The API does not return icons; the parent can derive them from lesson data. */ getLessonIcon?: (lesson: UserPerformanceLesson) => ReactNode; /** * Optional activity/questionnaire/simulation done counts. * These are not part of the API response — pass them from other data sources. */ studentActivityCounts?: { activities?: number; questionnaires?: number; simulations?: number; }; professionalUserInfo?: never; }; type PerformanceReportModalProfessionalProps = { variant: REPORT_MODAL_VARIANT.PROFESSIONAL; data: UserPerformanceProfessionalData | null; /** * Display info for the professional modal header. * The professional API response does not include user/school context, * so the parent should supply this from the table row data. */ professionalUserInfo?: { userName: string; schoolName: string; className: string; year: string | number; }; getLessonIcon?: never; studentActivityCounts?: never; }; export type PerformanceReportModalProps = PerformanceReportModalBaseProps & (PerformanceReportModalStudentProps | PerformanceReportModalProfessionalProps); /** * PerformanceReportModal component * * Displays a modal with performance data for a user from `GET /performance/user/:userId`. * * Two variants driven by the profile type: * - `STUDENT` — question stats per section (generalStats, activityStats, * questionnaireStats, simulationStats) + downloaded lessons table * - `PROFESSIONAL` — material production stats (totalMaterialProduced, * totalRecommendedLessons, totalActivities) * * The professional API response does not include user/school context. * Pass `professionalUserInfo` (from the table row) to show a user header. * * @example * ```tsx * // Student variant — pass API response directly * <PerformanceReportModal * isOpen={isOpen} * onClose={() => setIsOpen(false)} * variant={PerformanceReportModalVariant.STUDENT} * data={apiResponse.data} * /> * * // Professional variant — API has no user context, pass it separately * <PerformanceReportModal * isOpen={isOpen} * onClose={() => setIsOpen(false)} * variant={PerformanceReportModalVariant.PROFESSIONAL} * data={apiResponse.data} * professionalUserInfo={{ * userName: row.userName, * schoolName: row.schoolName, * className: row.className, * year: row.year, * }} * /> * ``` */ export declare const PerformanceReportModal: ({ isOpen, onClose, title, loading, error, ...variantProps }: PerformanceReportModalProps) => import("react/jsx-runtime").JSX.Element; export default PerformanceReportModal; //# sourceMappingURL=PerformanceReportModal.d.ts.map