analytica-frontend-lib 1.2.70 → 1.2.72

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.
Files changed (57) hide show
  1. package/dist/ActivitiesHistory/index.js +14 -3
  2. package/dist/ActivitiesHistory/index.js.map +1 -1
  3. package/dist/ActivitiesHistory/index.mjs +14 -3
  4. package/dist/ActivitiesHistory/index.mjs.map +1 -1
  5. package/dist/ActivityDetails/index.d.ts +4 -11
  6. package/dist/ActivityDetails/index.d.ts.map +1 -1
  7. package/dist/ActivityDetails/index.js +176 -69
  8. package/dist/ActivityDetails/index.js.map +1 -1
  9. package/dist/ActivityDetails/index.mjs +143 -36
  10. package/dist/ActivityDetails/index.mjs.map +1 -1
  11. package/dist/ActivityFilters/index.js +5 -5
  12. package/dist/ActivityFilters/index.js.map +1 -1
  13. package/dist/ActivityFilters/index.mjs +5 -5
  14. package/dist/ActivityFilters/index.mjs.map +1 -1
  15. package/dist/CorrectActivityModal/index.d.ts.map +1 -1
  16. package/dist/CorrectActivityModal/index.js +1 -2
  17. package/dist/CorrectActivityModal/index.js.map +1 -1
  18. package/dist/CorrectActivityModal/index.mjs +1 -2
  19. package/dist/CorrectActivityModal/index.mjs.map +1 -1
  20. package/dist/RecommendedLessonsHistory/index.js +14 -3
  21. package/dist/RecommendedLessonsHistory/index.js.map +1 -1
  22. package/dist/RecommendedLessonsHistory/index.mjs +14 -3
  23. package/dist/RecommendedLessonsHistory/index.mjs.map +1 -1
  24. package/dist/TableProvider/index.d.ts +10 -1
  25. package/dist/TableProvider/index.d.ts.map +1 -1
  26. package/dist/TableProvider/index.js +14 -3
  27. package/dist/TableProvider/index.js.map +1 -1
  28. package/dist/TableProvider/index.mjs +14 -3
  29. package/dist/TableProvider/index.mjs.map +1 -1
  30. package/dist/hooks/useActivitiesHistory/index.d.ts +14 -14
  31. package/dist/hooks/useActivitiesHistory.d.ts +14 -14
  32. package/dist/hooks/useActivityDetails.d.ts +59 -0
  33. package/dist/hooks/useActivityDetails.d.ts.map +1 -0
  34. package/dist/hooks/useActivityModels/index.d.ts +6 -6
  35. package/dist/hooks/useActivityModels.d.ts +6 -6
  36. package/dist/index.d.ts +3 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +537 -421
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +390 -276
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/types/activityDetails.d.ts +29 -0
  43. package/dist/types/activityDetails.d.ts.map +1 -1
  44. package/dist/types/activityFilters.d.ts +1 -1
  45. package/dist/types/activityFilters.d.ts.map +1 -1
  46. package/dist/types/questions.d.ts +6 -7
  47. package/dist/types/questions.d.ts.map +1 -1
  48. package/dist/utils/activityDetailsUtils.d.ts +4 -4
  49. package/dist/utils/activityDetailsUtils.d.ts.map +1 -1
  50. package/dist/utils/index.js +13 -10
  51. package/dist/utils/index.js.map +1 -1
  52. package/dist/utils/index.mjs +13 -10
  53. package/dist/utils/index.mjs.map +1 -1
  54. package/dist/utils/questionFiltersConverter.d.ts.map +1 -1
  55. package/dist/utils/studentActivityCorrection/types.d.ts +5 -5
  56. package/dist/utils/studentActivityCorrection/types.d.ts.map +1 -1
  57. package/package.json +1 -1
@@ -1,20 +1,13 @@
1
1
  import { SubjectEnum } from '../../enums/SubjectEnum';
2
- import type { SaveQuestionCorrectionPayload, QuestionsAnswersByStudentResponse } from '../../utils/studentActivityCorrection';
3
- import { type ActivityDetailsData, type ActivityDetailsQueryParams } from '../../types/activityDetails';
2
+ import type { BaseApiClient } from '../../types/api';
4
3
  /**
5
4
  * Props for the ActivityDetails component
6
5
  */
7
6
  export interface ActivityDetailsProps {
8
7
  /** Activity ID to display details for */
9
8
  activityId: string;
10
- /** Function to fetch activity details. Must be memoized (using useCallback) to prevent re-fetches on every render. */
11
- fetchActivityDetails: (id: string, params?: ActivityDetailsQueryParams) => Promise<ActivityDetailsData>;
12
- /** Function to fetch student correction data from API (fetchQuestionsAnswersByStudent) */
13
- fetchStudentCorrection: (activityId: string, studentId: string, studentName: string) => Promise<QuestionsAnswersByStudentResponse>;
14
- /** Function to submit observation */
15
- submitObservation: (activityId: string, studentId: string, observation: string, files: File[]) => Promise<void>;
16
- /** Function to submit question correction (for essay questions) */
17
- submitQuestionCorrection?: (activityId: string, studentId: string, payload: SaveQuestionCorrectionPayload) => Promise<void>;
9
+ /** API client instance for making requests */
10
+ apiClient: BaseApiClient;
18
11
  /** Callback when back button is clicked */
19
12
  onBack?: () => void;
20
13
  /** Callback when view activity button is clicked */
@@ -28,6 +21,6 @@ export interface ActivityDetailsProps {
28
21
  * ActivityDetails component
29
22
  * Displays detailed information about an activity including statistics and student progress
30
23
  */
31
- export declare const ActivityDetails: ({ activityId, fetchActivityDetails, fetchStudentCorrection, submitObservation, submitQuestionCorrection, onBack, onViewActivity, emptyStateImage, mapSubjectNameToEnum, }: ActivityDetailsProps) => import("react/jsx-runtime").JSX.Element;
24
+ export declare const ActivityDetails: ({ activityId, apiClient, onBack, onViewActivity, emptyStateImage, mapSubjectNameToEnum, }: ActivityDetailsProps) => import("react/jsx-runtime").JSX.Element;
32
25
  export default ActivityDetails;
33
26
  //# sourceMappingURL=ActivityDetails.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActivityDetails.d.ts","sourceRoot":"","sources":["../../../src/components/ActivityDetails/ActivityDetails.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAEV,6BAA6B,EAC7B,iCAAiC,EAClC,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAGhC,MAAM,6BAA6B,CAAC;AAQrC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,sHAAsH;IACtH,oBAAoB,EAAE,CACpB,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,0BAA0B,KAChC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAClC,0FAA0F;IAC1F,sBAAsB,EAAE,CACtB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,KAChB,OAAO,CAAC,iCAAiC,CAAC,CAAC;IAChD,qCAAqC;IACrC,iBAAiB,EAAE,CACjB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,IAAI,EAAE,KACV,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,mEAAmE;IACnE,wBAAwB,CAAC,EAAE,CACzB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,6BAA6B,KACnC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,4BAA4B;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,oBAAoB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,WAAW,GAAG,IAAI,CAAC;CACpE;AA2HD;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,2KAU7B,oBAAoB,4CA+ftB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ActivityDetails.d.ts","sourceRoot":"","sources":["../../../src/components/ActivityDetails/ActivityDetails.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAmBtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,SAAS,EAAE,aAAa,CAAC;IACzB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,4BAA4B;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,oBAAoB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,WAAW,GAAG,IAAI,CAAC;CACpE;AA2HD;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,2FAO7B,oBAAoB,4CAogBtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -34,7 +34,7 @@ __export(ActivityDetails_exports, {
34
34
  default: () => ActivityDetails_default
35
35
  });
36
36
  module.exports = __toCommonJS(ActivityDetails_exports);
37
- var import_react27 = require("react");
37
+ var import_react28 = require("react");
38
38
  var import_phosphor_react20 = require("phosphor-react");
39
39
 
40
40
  // src/utils/utils.ts
@@ -42,12 +42,19 @@ var import_clsx = require("clsx");
42
42
  var import_tailwind_merge = require("tailwind-merge");
43
43
 
44
44
  // src/types/activityDetails.ts
45
+ var import_zod = require("zod");
45
46
  var STUDENT_ACTIVITY_STATUS = {
46
47
  CONCLUIDO: "CONCLUIDO",
47
48
  AGUARDANDO_CORRECAO: "AGUARDANDO_CORRECAO",
48
49
  AGUARDANDO_RESPOSTA: "AGUARDANDO_RESPOSTA",
49
50
  NAO_ENTREGUE: "NAO_ENTREGUE"
50
51
  };
52
+ var studentActivityStatusSchema = import_zod.z.enum([
53
+ STUDENT_ACTIVITY_STATUS.CONCLUIDO,
54
+ STUDENT_ACTIVITY_STATUS.AGUARDANDO_CORRECAO,
55
+ STUDENT_ACTIVITY_STATUS.AGUARDANDO_RESPOSTA,
56
+ STUDENT_ACTIVITY_STATUS.NAO_ENTREGUE
57
+ ]);
51
58
 
52
59
  // src/utils/activityDetailsUtils.ts
53
60
  var getStatusBadgeConfig = (status) => {
@@ -71,19 +78,15 @@ var getStatusBadgeConfig = (status) => {
71
78
  label: "N\xE3o Entregue",
72
79
  bgColor: "bg-red-50",
73
80
  textColor: "text-red-800"
74
- },
75
- default: {
76
- label: "Desconhecido",
77
- bgColor: "bg-gray-50",
78
- textColor: "text-gray-800"
79
81
  }
80
82
  };
81
- return configs[status] ?? configs.default;
83
+ return configs[status];
82
84
  };
83
85
  var formatTimeSpent = (seconds) => {
84
- const hours = Math.floor(seconds / 3600);
85
- const minutes = Math.floor(seconds % 3600 / 60);
86
- const secs = seconds % 60;
86
+ const totalSeconds = Math.floor(Math.abs(seconds));
87
+ const hours = Math.floor(totalSeconds / 3600);
88
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
89
+ const secs = totalSeconds % 60;
87
90
  return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
88
91
  };
89
92
  var formatQuestionNumbers = (numbers) => {
@@ -505,7 +508,7 @@ var SkeletonTable = (0, import_react.forwardRef)(
505
508
  );
506
509
 
507
510
  // src/components/TableProvider/TableProvider.tsx
508
- var import_react26 = require("react");
511
+ var import_react27 = require("react");
509
512
 
510
513
  // src/components/Table/Table.tsx
511
514
  var import_react2 = require("react");
@@ -2451,7 +2454,7 @@ Search.displayName = "Search";
2451
2454
  var Search_default = Search;
2452
2455
 
2453
2456
  // src/components/CheckBoxGroup/CheckBoxGroup.tsx
2454
- var import_react25 = require("react");
2457
+ var import_react26 = require("react");
2455
2458
 
2456
2459
  // src/components/CheckBox/CheckBox.tsx
2457
2460
  var import_react10 = require("react");
@@ -6874,7 +6877,6 @@ var CorrectActivityModal = ({
6874
6877
  }
6875
6878
  await onQuestionCorrectionSubmit(data.studentId, {
6876
6879
  questionId: questionData.question.id,
6877
- questionNumber,
6878
6880
  isCorrect: correction.isCorrect,
6879
6881
  teacherFeedback: correction.teacherFeedback
6880
6882
  });
@@ -6953,7 +6955,7 @@ var CorrectActivityModal = ({
6953
6955
  renderQuestionDissertative({
6954
6956
  result
6955
6957
  }),
6956
- !isViewOnly && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "space-y-4 border-t border-border-100 pt-4 mt-4", children: renderEssayCorrectionFields(questionData) })
6958
+ onQuestionCorrectionSubmit && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "space-y-4 border-t border-border-100 pt-4 mt-4", children: renderEssayCorrectionFields(questionData) })
6957
6959
  ] });
6958
6960
  break;
6959
6961
  case "PREENCHER" /* PREENCHER */:
@@ -7591,6 +7593,100 @@ var getSubjectInfo = (subject) => {
7591
7593
  };
7592
7594
  };
7593
7595
 
7596
+ // src/hooks/useActivityDetails.ts
7597
+ var import_react25 = require("react");
7598
+ var buildQueryParams = (params) => {
7599
+ const paramsObj = {};
7600
+ if (params?.page) paramsObj.page = params.page;
7601
+ if (params?.limit) paramsObj.limit = params.limit;
7602
+ if (params?.sortBy) paramsObj.sortBy = params.sortBy;
7603
+ if (params?.sortOrder) paramsObj.sortOrder = params.sortOrder;
7604
+ if (params?.status) paramsObj.status = params.status;
7605
+ return paramsObj;
7606
+ };
7607
+ var useActivityDetails = (apiClient) => {
7608
+ const fetchActivityDetails = (0, import_react25.useCallback)(
7609
+ async (id, params) => {
7610
+ const queryParams = buildQueryParams(params);
7611
+ const [detailsResponse, quizResponse] = await Promise.all([
7612
+ apiClient.get(`/activities/${id}/details`, {
7613
+ params: queryParams
7614
+ }),
7615
+ apiClient.get(`/activities/${id}/quiz`).catch(() => null)
7616
+ ]);
7617
+ return {
7618
+ ...detailsResponse.data.data,
7619
+ activity: quizResponse?.data?.data
7620
+ };
7621
+ },
7622
+ [apiClient]
7623
+ );
7624
+ const fetchStudentCorrection = (0, import_react25.useCallback)(
7625
+ async (activityId, studentId) => {
7626
+ const response = await apiClient.get(
7627
+ `/questions/activity/${activityId}/user/${studentId}/answers`
7628
+ );
7629
+ return response.data;
7630
+ },
7631
+ [apiClient]
7632
+ );
7633
+ const submitObservation = (0, import_react25.useCallback)(
7634
+ async (actId, studentId, observation, file) => {
7635
+ let attachmentUrl = null;
7636
+ if (file) {
7637
+ const presignedRes = await apiClient.post(
7638
+ "/user/get-pre-signed-url",
7639
+ {
7640
+ fileName: file.name,
7641
+ fileType: file.type,
7642
+ fileSize: file.size
7643
+ }
7644
+ );
7645
+ const { url, fields } = presignedRes.data.data;
7646
+ const formData = new FormData();
7647
+ for (const [key2, value] of Object.entries(fields)) {
7648
+ formData.append(key2, value);
7649
+ }
7650
+ formData.append("file", file);
7651
+ await fetch(url, {
7652
+ method: "POST",
7653
+ body: formData
7654
+ }).then((response) => {
7655
+ if (!response.ok) {
7656
+ throw new Error("Falha ao fazer upload do arquivo");
7657
+ }
7658
+ });
7659
+ const baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
7660
+ const key = fields.key.startsWith("/") ? fields.key.slice(1) : fields.key;
7661
+ attachmentUrl = `${baseUrl}/${key}`;
7662
+ }
7663
+ await apiClient.post(
7664
+ `/activities/${actId}/students/${studentId}/feedback/observation`,
7665
+ {
7666
+ observation,
7667
+ attachmentUrl
7668
+ }
7669
+ );
7670
+ },
7671
+ [apiClient]
7672
+ );
7673
+ const submitQuestionCorrection = (0, import_react25.useCallback)(
7674
+ async (activityId, studentId, payload) => {
7675
+ await apiClient.post(
7676
+ `/activities/${activityId}/students/${studentId}/questions/correction`,
7677
+ payload
7678
+ );
7679
+ },
7680
+ [apiClient]
7681
+ );
7682
+ return {
7683
+ fetchActivityDetails,
7684
+ fetchStudentCorrection,
7685
+ submitObservation,
7686
+ submitQuestionCorrection
7687
+ };
7688
+ };
7689
+
7594
7690
  // src/components/CheckBoxGroup/CheckBoxGroup.helpers.ts
7595
7691
  var areSelectedIdsEqual = (ids1, ids2) => {
7596
7692
  if (ids1 === ids2) return true;
@@ -7681,14 +7777,14 @@ var CheckboxGroup = ({
7681
7777
  showDivider = true,
7682
7778
  showSingleItem = false
7683
7779
  }) => {
7684
- const [openAccordion, setOpenAccordion] = (0, import_react25.useState)("");
7685
- const autoSelectionAppliedRef = (0, import_react25.useRef)(false);
7686
- const onCategoriesChangeRef = (0, import_react25.useRef)(onCategoriesChange);
7687
- const previousCategoriesRef = (0, import_react25.useRef)(categories);
7688
- (0, import_react25.useEffect)(() => {
7780
+ const [openAccordion, setOpenAccordion] = (0, import_react26.useState)("");
7781
+ const autoSelectionAppliedRef = (0, import_react26.useRef)(false);
7782
+ const onCategoriesChangeRef = (0, import_react26.useRef)(onCategoriesChange);
7783
+ const previousCategoriesRef = (0, import_react26.useRef)(categories);
7784
+ (0, import_react26.useEffect)(() => {
7689
7785
  onCategoriesChangeRef.current = onCategoriesChange;
7690
7786
  }, [onCategoriesChange]);
7691
- const categoriesWithAutoSelection = (0, import_react25.useMemo)(() => {
7787
+ const categoriesWithAutoSelection = (0, import_react26.useMemo)(() => {
7692
7788
  return categories.map((category) => {
7693
7789
  const filteredItems = calculateFormattedItemsForAutoSelection(
7694
7790
  category,
@@ -7703,7 +7799,7 @@ var CheckboxGroup = ({
7703
7799
  return category;
7704
7800
  });
7705
7801
  }, [categories]);
7706
- (0, import_react25.useEffect)(() => {
7802
+ (0, import_react26.useEffect)(() => {
7707
7803
  const categoriesChanged = categories !== previousCategoriesRef.current;
7708
7804
  if (!categoriesChanged && autoSelectionAppliedRef.current) {
7709
7805
  return;
@@ -7821,7 +7917,7 @@ var CheckboxGroup = ({
7821
7917
  );
7822
7918
  return groupedItems.length ? groupedItems : [{ itens: [] }];
7823
7919
  };
7824
- const formattedItemsMap = (0, import_react25.useMemo)(() => {
7920
+ const formattedItemsMap = (0, import_react26.useMemo)(() => {
7825
7921
  const formattedItemsMap2 = {};
7826
7922
  for (const category of categories) {
7827
7923
  const formattedItems = calculateFormattedItems(category.key);
@@ -8099,7 +8195,7 @@ var CheckboxGroup = ({
8099
8195
  openAccordion !== category.key && showDivider && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Divider_default, {})
8100
8196
  ] }, category.key);
8101
8197
  };
8102
- (0, import_react25.useEffect)(() => {
8198
+ (0, import_react26.useEffect)(() => {
8103
8199
  if (!openAccordion) return;
8104
8200
  const category = categories.find((c) => c.key === openAccordion);
8105
8201
  if (!category) return;
@@ -8286,9 +8382,11 @@ function TableProvider({
8286
8382
  rowKey,
8287
8383
  onParamsChange,
8288
8384
  onRowClick,
8385
+ headerContent,
8386
+ containerClassName,
8289
8387
  children
8290
8388
  }) {
8291
- const [searchQuery, setSearchQuery] = (0, import_react26.useState)("");
8389
+ const [searchQuery, setSearchQuery] = (0, import_react27.useState)("");
8292
8390
  const sortResultRaw = useTableSort(data, { syncWithUrl: true });
8293
8391
  const sortResult = enableTableSort ? sortResultRaw : {
8294
8392
  sortedData: data,
@@ -8299,7 +8397,7 @@ function TableProvider({
8299
8397
  };
8300
8398
  const { sortedData, sortColumn, sortDirection, handleSort } = sortResult;
8301
8399
  const filterResultRaw = useTableFilter(initialFilters, { syncWithUrl: true });
8302
- const disabledFilterResult = (0, import_react26.useMemo)(
8400
+ const disabledFilterResult = (0, import_react27.useMemo)(
8303
8401
  () => ({
8304
8402
  filterConfigs: [],
8305
8403
  activeFilters: {},
@@ -8329,10 +8427,10 @@ function TableProvider({
8329
8427
  totalItems,
8330
8428
  totalPages
8331
8429
  } = paginationConfig;
8332
- const [currentPage, setCurrentPage] = (0, import_react26.useState)(1);
8333
- const [itemsPerPage, setItemsPerPage] = (0, import_react26.useState)(defaultItemsPerPage);
8334
- const [isFilterModalOpen, setIsFilterModalOpen] = (0, import_react26.useState)(false);
8335
- const combinedParams = (0, import_react26.useMemo)(() => {
8430
+ const [currentPage, setCurrentPage] = (0, import_react27.useState)(1);
8431
+ const [itemsPerPage, setItemsPerPage] = (0, import_react27.useState)(defaultItemsPerPage);
8432
+ const [isFilterModalOpen, setIsFilterModalOpen] = (0, import_react27.useState)(false);
8433
+ const combinedParams = (0, import_react27.useMemo)(() => {
8336
8434
  const params = {
8337
8435
  page: currentPage,
8338
8436
  limit: itemsPerPage
@@ -8359,26 +8457,26 @@ function TableProvider({
8359
8457
  enableFilters,
8360
8458
  enableTableSort
8361
8459
  ]);
8362
- (0, import_react26.useEffect)(() => {
8460
+ (0, import_react27.useEffect)(() => {
8363
8461
  onParamsChange?.(combinedParams);
8364
8462
  }, [combinedParams]);
8365
- const handleSearchChange = (0, import_react26.useCallback)((value) => {
8463
+ const handleSearchChange = (0, import_react27.useCallback)((value) => {
8366
8464
  setSearchQuery(value);
8367
8465
  setCurrentPage(1);
8368
8466
  }, []);
8369
- const handleFilterApply = (0, import_react26.useCallback)(() => {
8467
+ const handleFilterApply = (0, import_react27.useCallback)(() => {
8370
8468
  applyFilters();
8371
8469
  setIsFilterModalOpen(false);
8372
8470
  setCurrentPage(1);
8373
8471
  }, [applyFilters]);
8374
- const handlePageChange = (0, import_react26.useCallback)((page) => {
8472
+ const handlePageChange = (0, import_react27.useCallback)((page) => {
8375
8473
  setCurrentPage(page);
8376
8474
  }, []);
8377
- const handleItemsPerPageChange = (0, import_react26.useCallback)((items) => {
8475
+ const handleItemsPerPageChange = (0, import_react27.useCallback)((items) => {
8378
8476
  setItemsPerPage(items);
8379
8477
  setCurrentPage(1);
8380
8478
  }, []);
8381
- const handleRowClickInternal = (0, import_react26.useCallback)(
8479
+ const handleRowClickInternal = (0, import_react27.useCallback)(
8382
8480
  (row, index) => {
8383
8481
  if (enableRowClick && onRowClick) {
8384
8482
  onRowClick(row, index);
@@ -8386,7 +8484,7 @@ function TableProvider({
8386
8484
  },
8387
8485
  [enableRowClick, onRowClick]
8388
8486
  );
8389
- const useInternalPagination = (0, import_react26.useMemo)(
8487
+ const useInternalPagination = (0, import_react27.useMemo)(
8390
8488
  () => enablePagination && !onParamsChange && totalItems === void 0 && totalPages === void 0,
8391
8489
  [enablePagination, onParamsChange, totalItems, totalPages]
8392
8490
  );
@@ -8394,7 +8492,7 @@ function TableProvider({
8394
8492
  (totalItems ?? (useInternalPagination ? sortedData.length : data.length)) / itemsPerPage
8395
8493
  );
8396
8494
  const calculatedTotalItems = totalItems ?? (useInternalPagination ? sortedData.length : data.length);
8397
- const displayData = (0, import_react26.useMemo)(() => {
8495
+ const displayData = (0, import_react27.useMemo)(() => {
8398
8496
  if (!useInternalPagination) {
8399
8497
  return sortedData;
8400
8498
  }
@@ -8430,6 +8528,10 @@ function TableProvider({
8430
8528
  }
8431
8529
  ) })
8432
8530
  ] });
8531
+ const headerSection = (headerContent || controls) && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-col md:flex-row items-stretch md:items-center justify-between gap-4", children: [
8532
+ headerContent && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { children: headerContent }),
8533
+ controls && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "flex-1 md:flex-none", children: controls })
8534
+ ] });
8433
8535
  const table = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "w-full overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
8434
8536
  Table_default,
8435
8537
  {
@@ -8526,7 +8628,11 @@ function TableProvider({
8526
8628
  ) });
8527
8629
  if (children) {
8528
8630
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
8529
- children({ controls, table, pagination }),
8631
+ children({
8632
+ controls: headerSection || controls || null,
8633
+ table,
8634
+ pagination
8635
+ }),
8530
8636
  enableFilters && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
8531
8637
  FilterModal,
8532
8638
  {
@@ -8540,8 +8646,9 @@ function TableProvider({
8540
8646
  )
8541
8647
  ] });
8542
8648
  }
8543
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "w-full space-y-4", children: [
8544
- controls,
8649
+ const wrapperClassName = containerClassName || "w-full space-y-4";
8650
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: wrapperClassName, children: [
8651
+ headerSection,
8545
8652
  table,
8546
8653
  pagination,
8547
8654
  enableFilters && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
@@ -8646,30 +8753,33 @@ var createTableColumns = (onCorrectActivity) => [
8646
8753
  ];
8647
8754
  var ActivityDetails = ({
8648
8755
  activityId,
8649
- fetchActivityDetails,
8650
- fetchStudentCorrection,
8651
- submitObservation,
8652
- submitQuestionCorrection,
8756
+ apiClient,
8653
8757
  onBack,
8654
8758
  onViewActivity,
8655
8759
  emptyStateImage,
8656
8760
  mapSubjectNameToEnum
8657
8761
  }) => {
8658
8762
  const { isMobile } = useMobile();
8659
- const [page, setPage] = (0, import_react27.useState)(1);
8660
- const [limit, setLimit] = (0, import_react27.useState)(10);
8661
- const [sortBy, setSortBy] = (0, import_react27.useState)(void 0);
8662
- const [sortOrder, setSortOrder] = (0, import_react27.useState)(
8763
+ const [page, setPage] = (0, import_react28.useState)(1);
8764
+ const [limit, setLimit] = (0, import_react28.useState)(10);
8765
+ const [sortBy, setSortBy] = (0, import_react28.useState)(void 0);
8766
+ const [sortOrder, setSortOrder] = (0, import_react28.useState)(
8663
8767
  void 0
8664
8768
  );
8665
- const [data, setData] = (0, import_react27.useState)(null);
8666
- const [correctionData, setCorrectionData] = (0, import_react27.useState)(null);
8667
- const [loading, setLoading] = (0, import_react27.useState)(true);
8668
- const [error, setError] = (0, import_react27.useState)(null);
8669
- const [isModalOpen, setIsModalOpen] = (0, import_react27.useState)(false);
8670
- const [isViewOnlyModal, setIsViewOnlyModal] = (0, import_react27.useState)(false);
8671
- const [correctionError, setCorrectionError] = (0, import_react27.useState)(null);
8672
- (0, import_react27.useEffect)(() => {
8769
+ const [data, setData] = (0, import_react28.useState)(null);
8770
+ const [correctionData, setCorrectionData] = (0, import_react28.useState)(null);
8771
+ const [loading, setLoading] = (0, import_react28.useState)(true);
8772
+ const [error, setError] = (0, import_react28.useState)(null);
8773
+ const [isModalOpen, setIsModalOpen] = (0, import_react28.useState)(false);
8774
+ const [isViewOnlyModal, setIsViewOnlyModal] = (0, import_react28.useState)(false);
8775
+ const [correctionError, setCorrectionError] = (0, import_react28.useState)(null);
8776
+ const {
8777
+ fetchActivityDetails,
8778
+ fetchStudentCorrection,
8779
+ submitObservation,
8780
+ submitQuestionCorrection
8781
+ } = useActivityDetails(apiClient);
8782
+ (0, import_react28.useEffect)(() => {
8673
8783
  const loadData = async () => {
8674
8784
  if (!activityId) return;
8675
8785
  setLoading(true);
@@ -8692,7 +8802,7 @@ var ActivityDetails = ({
8692
8802
  };
8693
8803
  loadData();
8694
8804
  }, [activityId, page, limit, sortBy, sortOrder, fetchActivityDetails]);
8695
- const handleCorrectActivity = (0, import_react27.useCallback)(
8805
+ const handleCorrectActivity = (0, import_react28.useCallback)(
8696
8806
  async (studentId) => {
8697
8807
  const student = data?.students.find((s) => s.studentId === studentId);
8698
8808
  if (!student || !activityId) return;
@@ -8700,11 +8810,7 @@ var ActivityDetails = ({
8700
8810
  setIsViewOnlyModal(isViewOnly);
8701
8811
  setCorrectionError(null);
8702
8812
  try {
8703
- const apiResponse = await fetchStudentCorrection(
8704
- activityId,
8705
- studentId,
8706
- student.studentName || "Aluno"
8707
- );
8813
+ const apiResponse = await fetchStudentCorrection(activityId, studentId);
8708
8814
  const correction = convertApiResponseToCorrectionData(
8709
8815
  apiResponse,
8710
8816
  studentId,
@@ -8721,23 +8827,24 @@ var ActivityDetails = ({
8721
8827
  },
8722
8828
  [data?.students, activityId, fetchStudentCorrection]
8723
8829
  );
8724
- const handleCloseModal = (0, import_react27.useCallback)(() => {
8830
+ const handleCloseModal = (0, import_react28.useCallback)(() => {
8725
8831
  setIsModalOpen(false);
8726
8832
  }, []);
8727
- const handleObservationSubmit = (0, import_react27.useCallback)(
8833
+ const handleObservationSubmit = (0, import_react28.useCallback)(
8728
8834
  async (studentId, observation, files) => {
8729
8835
  if (!activityId || !studentId) return;
8730
8836
  try {
8731
- await submitObservation(activityId, studentId, observation, files);
8837
+ const file = files.length > 0 ? files[0] : null;
8838
+ await submitObservation(activityId, studentId, observation, file);
8732
8839
  } catch (err) {
8733
8840
  console.error("Failed to submit observation:", err);
8734
8841
  }
8735
8842
  },
8736
8843
  [activityId, submitObservation]
8737
8844
  );
8738
- const handleQuestionCorrectionSubmit = (0, import_react27.useCallback)(
8845
+ const handleQuestionCorrectionSubmit = (0, import_react28.useCallback)(
8739
8846
  async (studentId, payload) => {
8740
- if (!activityId || !studentId || !submitQuestionCorrection) return;
8847
+ if (!activityId || !studentId) return;
8741
8848
  try {
8742
8849
  await submitQuestionCorrection(activityId, studentId, payload);
8743
8850
  } catch (err) {
@@ -8747,7 +8854,7 @@ var ActivityDetails = ({
8747
8854
  },
8748
8855
  [activityId, submitQuestionCorrection]
8749
8856
  );
8750
- const tableData = (0, import_react27.useMemo)(() => {
8857
+ const tableData = (0, import_react28.useMemo)(() => {
8751
8858
  if (!data?.students) return [];
8752
8859
  return data.students.map((student) => ({
8753
8860
  id: student.studentId,
@@ -8759,7 +8866,7 @@ var ActivityDetails = ({
8759
8866
  score: student.score
8760
8867
  }));
8761
8868
  }, [data?.students]);
8762
- const columns = (0, import_react27.useMemo)(
8869
+ const columns = (0, import_react28.useMemo)(
8763
8870
  () => createTableColumns(handleCorrectActivity),
8764
8871
  [handleCorrectActivity]
8765
8872
  );