UNPKG

analytica-frontend-lib

Version:

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

270 lines (268 loc) 8.37 kB
import { PERFORMANCE_TAG_CONFIG } from "./chunk-UU5FBHMC.mjs"; import { ErrorContent, SectionTitle, UserHeader } from "./chunk-PEMHCXLY.mjs"; import { MetricBox } from "./chunk-G5AMZYLQ.mjs"; import { LegendPieCard } from "./chunk-Y4MZ2KAU.mjs"; import { Badge_default } from "./chunk-OEW3ST4F.mjs"; import { Modal_default } from "./chunk-TNLGS7SB.mjs"; import { Text_default } from "./chunk-IMCIR6TJ.mjs"; // src/components/PerformanceReportModal/PerformanceReportModal.tsx import { jsx, jsxs } from "react/jsx-runtime"; function getStatusVariant(status) { return Object.values(PERFORMANCE_TAG_CONFIG).find((c) => c.label === status)?.variant ?? "info"; } function buildQuestionsSlices(stats) { return [ { label: "Quest\xF5es corretas", value: stats.correctQuestions, colorClass: "bg-success-200" }, { label: "Quest\xF5es incorretas", value: stats.incorrectQuestions, colorClass: "bg-warning-400" }, { label: "Quest\xF5es em branco", value: stats.blankQuestions, colorClass: "bg-background-300" } ]; } function buildMaterialSlices(stats) { return [ { label: "Aulas recomendadas", value: stats.totalRecommendedLessons, colorClass: "bg-warning-300", color: "var(--Indicator-Indicator-Positive, #F8CC2E)" }, { label: "Atividades", value: stats.totalActivities, colorClass: "bg-success-700", color: "var(--Success-success700, #206F3E)" } ]; } var QuestionsSection = ({ title, totalLabel, stats, count, countLabel }) => { const displayTotal = stats.correctQuestions + stats.incorrectQuestions + stats.blankQuestions; const slices = buildQuestionsSlices(stats); return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [ /* @__PURE__ */ jsx(SectionTitle, { children: title }), count !== void 0 && countLabel ? /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [ /* @__PURE__ */ jsx(MetricBox, { className: "flex-1", label: countLabel, value: count }), /* @__PURE__ */ jsx( MetricBox, { className: "flex-1", label: totalLabel, value: displayTotal } ) ] }) : /* @__PURE__ */ jsx(MetricBox, { label: totalLabel, value: displayTotal }), /* @__PURE__ */ jsx(LegendPieCard, { slices }) ] }); }; var LessonsTable = ({ lessons, getLessonIcon }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [ /* @__PURE__ */ jsx(SectionTitle, { children: "Aulas baixadas" }), /* @__PURE__ */ jsxs("div", { className: "bg-background border border-border-50 rounded-xl overflow-hidden", children: [ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2 border-b border-border-100", children: [ /* @__PURE__ */ jsx(Text_default, { size: "xs", weight: "bold", className: "text-text-600", children: "Aula" }), /* @__PURE__ */ jsx(Text_default, { size: "xs", weight: "bold", className: "text-text-600", children: "BNCC" }) ] }), lessons.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ jsx(Text_default, { size: "sm", className: "text-text-400", children: "Nenhuma aula baixada" }) }) : lessons.map((lesson) => /* @__PURE__ */ jsxs( "div", { className: "flex items-center justify-between px-4 py-3 border-b border-border-50 last:border-b-0", children: [ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [ getLessonIcon && /* @__PURE__ */ jsx("span", { className: "shrink-0 [&>svg]:w-5 [&>svg]:h-5", children: getLessonIcon(lesson) }), /* @__PURE__ */ jsx(Text_default, { size: "sm", className: "text-text-950 truncate", children: lesson.lessonName }) ] }), /* @__PURE__ */ jsx(Text_default, { size: "sm", className: "text-text-500 shrink-0 ml-3", children: lesson.bnccCode ?? "\u2014" }) ] }, lesson.lessonId )) ] }) ] }); var StudentModalContent = ({ data, getLessonIcon, activityCounts }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [ /* @__PURE__ */ jsx( UserHeader, { name: data.user.name, school: data.school.schoolName, className: data.class.className, year: data.schoolYear.schoolYearName, statusBadge: data.status ? /* @__PURE__ */ jsx( Badge_default, { variant: "solid", action: getStatusVariant(data.status), size: "small", children: data.status.toUpperCase() } ) : void 0 } ), /* @__PURE__ */ jsx( QuestionsSection, { title: "Dados gerais", totalLabel: "Total de quest\xF5es respondidas", stats: data.generalStats } ), /* @__PURE__ */ jsx( QuestionsSection, { title: "Dados de atividades", totalLabel: "Total de quest\xF5es", stats: data.activityStats, count: activityCounts?.activities, countLabel: "Atividades realizadas" } ), /* @__PURE__ */ jsx( QuestionsSection, { title: "Dados de question\xE1rios", totalLabel: "Total de quest\xF5es", stats: data.questionnaireStats, count: activityCounts?.questionnaires, countLabel: "Question\xE1rios realizados" } ), /* @__PURE__ */ jsx( QuestionsSection, { title: "Dados de simulados", totalLabel: "Total de quest\xF5es", stats: data.simulationStats, count: activityCounts?.simulations, countLabel: "Simulados realizados" } ), /* @__PURE__ */ jsx( LessonsTable, { lessons: data.downloadedLessons, getLessonIcon } ) ] }); var ProfessionalModalContent = ({ data, userInfo }) => { const slices = buildMaterialSlices(data.generalStats); return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [ userInfo && /* @__PURE__ */ jsx( UserHeader, { name: userInfo.userName, school: userInfo.schoolName, className: userInfo.className, year: userInfo.year } ), /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [ /* @__PURE__ */ jsx(SectionTitle, { children: "Dados gerais" }), /* @__PURE__ */ jsx( MetricBox, { label: "Total de material produzido", value: data.generalStats.totalMaterialProduced } ), /* @__PURE__ */ jsx(LegendPieCard, { slices }) ] }) ] }); }; var LoadingSkeleton = () => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 animate-pulse", children: [ /* @__PURE__ */ jsx("div", { className: "h-16 bg-background-200 rounded-xl" }), /* @__PURE__ */ jsx("div", { className: "h-5 bg-background-200 rounded w-32 mt-2" }), /* @__PURE__ */ jsx("div", { className: "h-12 bg-background-200 rounded-xl" }), /* @__PURE__ */ jsx("div", { className: "h-32 bg-background-200 rounded-xl" }) ] }); var PerformanceReportModal = ({ isOpen, onClose, title = "Desempenho em 1 ano", loading = false, error = null, ...variantProps }) => { let content; if (loading) { content = /* @__PURE__ */ jsx(LoadingSkeleton, {}); } else if (error) { content = /* @__PURE__ */ jsx(ErrorContent, { message: error }); } else if (variantProps.data !== null) { if (variantProps.variant === "student" /* STUDENT */) { content = /* @__PURE__ */ jsx( StudentModalContent, { data: variantProps.data, getLessonIcon: variantProps.getLessonIcon, activityCounts: variantProps.studentActivityCounts } ); } else { content = /* @__PURE__ */ jsx( ProfessionalModalContent, { data: variantProps.data, userInfo: variantProps.professionalUserInfo } ); } } return /* @__PURE__ */ jsx( Modal_default, { isOpen, onClose, title, size: "lg", contentClassName: "max-h-[80vh] overflow-y-auto", children: content } ); }; var PerformanceReportModal_default = PerformanceReportModal; export { PerformanceReportModal, PerformanceReportModal_default }; //# sourceMappingURL=chunk-FBLBOMJA.mjs.map