analytica-frontend-lib 1.2.66 → 1.2.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -24110,6 +24110,17 @@ var LoadingSkeleton2 = () => /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div
24110
24110
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "h-44 bg-background-200 rounded-xl" })
24111
24111
  ] })
24112
24112
  ] });
24113
+ var ErrorContent = ({ message }) => /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "flex flex-col items-center justify-center py-8 gap-3", children: [
24114
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
24115
+ Text_default,
24116
+ {
24117
+ as: "span",
24118
+ className: "size-12 rounded-full bg-error-100 flex items-center justify-center",
24119
+ children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react78.WarningCircleIcon, { size: 24, className: "text-error-700" })
24120
+ }
24121
+ ),
24122
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Text_default, { size: "md", className: "text-error-700 text-center", children: message })
24123
+ ] });
24113
24124
  var PerformanceContent = ({
24114
24125
  data,
24115
24126
  labels
@@ -24168,10 +24179,13 @@ var PerformanceContent = ({
24168
24179
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "flex flex-col gap-2", children: data.lessons.map((lesson) => /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(LessonAccordionItem, { lesson }, lesson.id)) })
24169
24180
  ] })
24170
24181
  ] });
24171
- var renderModalContent = (loading, data, labels) => {
24182
+ var renderModalContent = (loading, error, data, labels) => {
24172
24183
  if (loading) {
24173
24184
  return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(LoadingSkeleton2, {});
24174
24185
  }
24186
+ if (error) {
24187
+ return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ErrorContent, { message: error });
24188
+ }
24175
24189
  if (data) {
24176
24190
  return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(PerformanceContent, { data, labels });
24177
24191
  }
@@ -24182,13 +24196,14 @@ var StudentPerformanceModal = ({
24182
24196
  onClose,
24183
24197
  data,
24184
24198
  loading = false,
24199
+ error = null,
24185
24200
  labels: customLabels
24186
24201
  }) => {
24187
24202
  const labels = (0, import_react77.useMemo)(
24188
24203
  () => ({ ...DEFAULT_PERFORMANCE_LABELS, ...customLabels }),
24189
24204
  [customLabels]
24190
24205
  );
24191
- if (!data && !loading) {
24206
+ if (!data && !loading && !error) {
24192
24207
  return null;
24193
24208
  }
24194
24209
  return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
@@ -24199,7 +24214,7 @@ var StudentPerformanceModal = ({
24199
24214
  title: labels.title,
24200
24215
  size: "lg",
24201
24216
  contentClassName: "max-h-[70vh] overflow-y-auto",
24202
- children: renderModalContent(loading, data, labels)
24217
+ children: renderModalContent(loading, error, data, labels)
24203
24218
  }
24204
24219
  );
24205
24220
  };
@@ -24207,11 +24222,12 @@ var StudentPerformanceModal = ({
24207
24222
  // src/components/RecommendedLessonDetails/RecommendedLessonDetails.tsx
24208
24223
  var import_jsx_runtime95 = require("react/jsx-runtime");
24209
24224
  var RecommendedLessonDetails = ({
24225
+ goalId,
24210
24226
  data,
24211
24227
  loading = false,
24212
24228
  error = null,
24213
24229
  onViewLesson,
24214
- onViewStudentPerformance,
24230
+ fetchStudentPerformance,
24215
24231
  onBreadcrumbClick,
24216
24232
  mapSubjectNameToEnum: mapSubjectNameToEnum2,
24217
24233
  breadcrumbs,
@@ -24222,6 +24238,36 @@ var RecommendedLessonDetails = ({
24222
24238
  () => ({ ...DEFAULT_LABELS, ...customLabels }),
24223
24239
  [customLabels]
24224
24240
  );
24241
+ const [performanceModalOpen, setPerformanceModalOpen] = (0, import_react79.useState)(false);
24242
+ const [performanceData, setPerformanceData] = (0, import_react79.useState)(null);
24243
+ const [performanceLoading, setPerformanceLoading] = (0, import_react79.useState)(false);
24244
+ const [performanceError, setPerformanceError] = (0, import_react79.useState)(null);
24245
+ const handleViewStudentPerformance = (0, import_react79.useCallback)(
24246
+ async (studentId) => {
24247
+ if (!fetchStudentPerformance || !goalId) return;
24248
+ setPerformanceModalOpen(true);
24249
+ setPerformanceLoading(true);
24250
+ setPerformanceData(null);
24251
+ setPerformanceError(null);
24252
+ try {
24253
+ const result = await fetchStudentPerformance(goalId, studentId);
24254
+ setPerformanceData(result);
24255
+ } catch (err) {
24256
+ console.error("Error fetching student performance:", err);
24257
+ setPerformanceError(
24258
+ err instanceof Error ? err.message : "Erro ao carregar desempenho do aluno"
24259
+ );
24260
+ } finally {
24261
+ setPerformanceLoading(false);
24262
+ }
24263
+ },
24264
+ [fetchStudentPerformance, goalId]
24265
+ );
24266
+ const handleClosePerformanceModal = (0, import_react79.useCallback)(() => {
24267
+ setPerformanceModalOpen(false);
24268
+ setPerformanceData(null);
24269
+ setPerformanceError(null);
24270
+ }, []);
24225
24271
  const defaultBreadcrumbs = (0, import_react79.useMemo)(
24226
24272
  () => [
24227
24273
  { label: "Aulas recomendadas", path: "/aulas-recomendadas" },
@@ -24263,34 +24309,46 @@ var RecommendedLessonDetails = ({
24263
24309
  if (!data) {
24264
24310
  return null;
24265
24311
  }
24266
- return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
24267
- "div",
24268
- {
24269
- className: cn("flex flex-col gap-6", className),
24270
- "data-testid": "recommended-lesson-details",
24271
- children: [
24272
- /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Breadcrumb, { items: breadcrumbItems, onItemClick: onBreadcrumbClick }),
24273
- /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
24274
- LessonHeader,
24275
- {
24276
- data,
24277
- onViewLesson,
24278
- mapSubjectNameToEnum: mapSubjectNameToEnum2,
24279
- viewLessonLabel: labels.viewLesson
24280
- }
24281
- ),
24282
- /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ResultsSection, { data, labels }),
24283
- /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
24284
- StudentsTable,
24285
- {
24286
- students: displayStudents,
24287
- onViewPerformance: onViewStudentPerformance,
24288
- labels
24289
- }
24290
- )
24291
- ]
24292
- }
24293
- );
24312
+ return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_jsx_runtime95.Fragment, { children: [
24313
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
24314
+ "div",
24315
+ {
24316
+ className: cn("flex flex-col gap-6", className),
24317
+ "data-testid": "recommended-lesson-details",
24318
+ children: [
24319
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Breadcrumb, { items: breadcrumbItems, onItemClick: onBreadcrumbClick }),
24320
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
24321
+ LessonHeader,
24322
+ {
24323
+ data,
24324
+ onViewLesson,
24325
+ mapSubjectNameToEnum: mapSubjectNameToEnum2,
24326
+ viewLessonLabel: labels.viewLesson
24327
+ }
24328
+ ),
24329
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ResultsSection, { data, labels }),
24330
+ /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
24331
+ StudentsTable,
24332
+ {
24333
+ students: displayStudents,
24334
+ onViewPerformance: fetchStudentPerformance ? handleViewStudentPerformance : void 0,
24335
+ labels
24336
+ }
24337
+ )
24338
+ ]
24339
+ }
24340
+ ),
24341
+ fetchStudentPerformance && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
24342
+ StudentPerformanceModal,
24343
+ {
24344
+ isOpen: performanceModalOpen,
24345
+ onClose: handleClosePerformanceModal,
24346
+ data: performanceData,
24347
+ loading: performanceLoading,
24348
+ error: performanceError
24349
+ }
24350
+ )
24351
+ ] });
24294
24352
  };
24295
24353
  var RecommendedLessonDetails_default = RecommendedLessonDetails;
24296
24354