analytica-frontend-lib 1.2.71 → 1.2.73

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 +175 -64
  8. package/dist/ActivityDetails/index.js.map +1 -1
  9. package/dist/ActivityDetails/index.mjs +142 -31
  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 -417
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +390 -272
  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,5 +1,5 @@
1
1
  // src/components/ActivityDetails/ActivityDetails.tsx
2
- import { useState as useState19, useMemo as useMemo7, useCallback as useCallback5, useEffect as useEffect19 } from "react";
2
+ import { useState as useState19, useMemo as useMemo7, useCallback as useCallback6, useEffect as useEffect19 } from "react";
3
3
  import { Medal as Medal2, Star as Star2, File, CaretRight as CaretRight5, WarningCircle as WarningCircle3 } from "phosphor-react";
4
4
 
5
5
  // src/utils/utils.ts
@@ -7,12 +7,19 @@ import { clsx } from "clsx";
7
7
  import { twMerge } from "tailwind-merge";
8
8
 
9
9
  // src/types/activityDetails.ts
10
+ import { z } from "zod";
10
11
  var STUDENT_ACTIVITY_STATUS = {
11
12
  CONCLUIDO: "CONCLUIDO",
12
13
  AGUARDANDO_CORRECAO: "AGUARDANDO_CORRECAO",
13
14
  AGUARDANDO_RESPOSTA: "AGUARDANDO_RESPOSTA",
14
15
  NAO_ENTREGUE: "NAO_ENTREGUE"
15
16
  };
17
+ var studentActivityStatusSchema = z.enum([
18
+ STUDENT_ACTIVITY_STATUS.CONCLUIDO,
19
+ STUDENT_ACTIVITY_STATUS.AGUARDANDO_CORRECAO,
20
+ STUDENT_ACTIVITY_STATUS.AGUARDANDO_RESPOSTA,
21
+ STUDENT_ACTIVITY_STATUS.NAO_ENTREGUE
22
+ ]);
16
23
 
17
24
  // src/utils/activityDetailsUtils.ts
18
25
  var getStatusBadgeConfig = (status) => {
@@ -36,19 +43,15 @@ var getStatusBadgeConfig = (status) => {
36
43
  label: "N\xE3o Entregue",
37
44
  bgColor: "bg-red-50",
38
45
  textColor: "text-red-800"
39
- },
40
- default: {
41
- label: "Desconhecido",
42
- bgColor: "bg-gray-50",
43
- textColor: "text-gray-800"
44
46
  }
45
47
  };
46
- return configs[status] ?? configs.default;
48
+ return configs[status];
47
49
  };
48
50
  var formatTimeSpent = (seconds) => {
49
- const hours = Math.floor(seconds / 3600);
50
- const minutes = Math.floor(seconds % 3600 / 60);
51
- const secs = seconds % 60;
51
+ const totalSeconds = Math.floor(Math.abs(seconds));
52
+ const hours = Math.floor(totalSeconds / 3600);
53
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
54
+ const secs = totalSeconds % 60;
52
55
  return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
53
56
  };
54
57
  var formatQuestionNumbers = (numbers) => {
@@ -470,7 +473,7 @@ var SkeletonTable = forwardRef(
470
473
  );
471
474
 
472
475
  // src/components/TableProvider/TableProvider.tsx
473
- import { useState as useState18, useEffect as useEffect18, useMemo as useMemo6, useCallback as useCallback4 } from "react";
476
+ import { useState as useState18, useEffect as useEffect18, useMemo as useMemo6, useCallback as useCallback5 } from "react";
474
477
 
475
478
  // src/components/Table/Table.tsx
476
479
  import {
@@ -6937,7 +6940,6 @@ var CorrectActivityModal = ({
6937
6940
  }
6938
6941
  await onQuestionCorrectionSubmit(data.studentId, {
6939
6942
  questionId: questionData.question.id,
6940
- questionNumber,
6941
6943
  isCorrect: correction.isCorrect,
6942
6944
  teacherFeedback: correction.teacherFeedback
6943
6945
  });
@@ -7016,7 +7018,7 @@ var CorrectActivityModal = ({
7016
7018
  renderQuestionDissertative({
7017
7019
  result
7018
7020
  }),
7019
- !isViewOnly && /* @__PURE__ */ jsx39("div", { className: "space-y-4 border-t border-border-100 pt-4 mt-4", children: renderEssayCorrectionFields(questionData) })
7021
+ onQuestionCorrectionSubmit && /* @__PURE__ */ jsx39("div", { className: "space-y-4 border-t border-border-100 pt-4 mt-4", children: renderEssayCorrectionFields(questionData) })
7020
7022
  ] });
7021
7023
  break;
7022
7024
  case "PREENCHER" /* PREENCHER */:
@@ -7666,6 +7668,100 @@ var getSubjectInfo = (subject) => {
7666
7668
  };
7667
7669
  };
7668
7670
 
7671
+ // src/hooks/useActivityDetails.ts
7672
+ import { useCallback as useCallback4 } from "react";
7673
+ var buildQueryParams = (params) => {
7674
+ const paramsObj = {};
7675
+ if (params?.page) paramsObj.page = params.page;
7676
+ if (params?.limit) paramsObj.limit = params.limit;
7677
+ if (params?.sortBy) paramsObj.sortBy = params.sortBy;
7678
+ if (params?.sortOrder) paramsObj.sortOrder = params.sortOrder;
7679
+ if (params?.status) paramsObj.status = params.status;
7680
+ return paramsObj;
7681
+ };
7682
+ var useActivityDetails = (apiClient) => {
7683
+ const fetchActivityDetails = useCallback4(
7684
+ async (id, params) => {
7685
+ const queryParams = buildQueryParams(params);
7686
+ const [detailsResponse, quizResponse] = await Promise.all([
7687
+ apiClient.get(`/activities/${id}/details`, {
7688
+ params: queryParams
7689
+ }),
7690
+ apiClient.get(`/activities/${id}/quiz`).catch(() => null)
7691
+ ]);
7692
+ return {
7693
+ ...detailsResponse.data.data,
7694
+ activity: quizResponse?.data?.data
7695
+ };
7696
+ },
7697
+ [apiClient]
7698
+ );
7699
+ const fetchStudentCorrection = useCallback4(
7700
+ async (activityId, studentId) => {
7701
+ const response = await apiClient.get(
7702
+ `/questions/activity/${activityId}/user/${studentId}/answers`
7703
+ );
7704
+ return response.data;
7705
+ },
7706
+ [apiClient]
7707
+ );
7708
+ const submitObservation = useCallback4(
7709
+ async (actId, studentId, observation, file) => {
7710
+ let attachmentUrl = null;
7711
+ if (file) {
7712
+ const presignedRes = await apiClient.post(
7713
+ "/user/get-pre-signed-url",
7714
+ {
7715
+ fileName: file.name,
7716
+ fileType: file.type,
7717
+ fileSize: file.size
7718
+ }
7719
+ );
7720
+ const { url, fields } = presignedRes.data.data;
7721
+ const formData = new FormData();
7722
+ for (const [key2, value] of Object.entries(fields)) {
7723
+ formData.append(key2, value);
7724
+ }
7725
+ formData.append("file", file);
7726
+ await fetch(url, {
7727
+ method: "POST",
7728
+ body: formData
7729
+ }).then((response) => {
7730
+ if (!response.ok) {
7731
+ throw new Error("Falha ao fazer upload do arquivo");
7732
+ }
7733
+ });
7734
+ const baseUrl = url.endsWith("/") ? url.slice(0, -1) : url;
7735
+ const key = fields.key.startsWith("/") ? fields.key.slice(1) : fields.key;
7736
+ attachmentUrl = `${baseUrl}/${key}`;
7737
+ }
7738
+ await apiClient.post(
7739
+ `/activities/${actId}/students/${studentId}/feedback/observation`,
7740
+ {
7741
+ observation,
7742
+ attachmentUrl
7743
+ }
7744
+ );
7745
+ },
7746
+ [apiClient]
7747
+ );
7748
+ const submitQuestionCorrection = useCallback4(
7749
+ async (activityId, studentId, payload) => {
7750
+ await apiClient.post(
7751
+ `/activities/${activityId}/students/${studentId}/questions/correction`,
7752
+ payload
7753
+ );
7754
+ },
7755
+ [apiClient]
7756
+ );
7757
+ return {
7758
+ fetchActivityDetails,
7759
+ fetchStudentCorrection,
7760
+ submitObservation,
7761
+ submitQuestionCorrection
7762
+ };
7763
+ };
7764
+
7669
7765
  // src/components/CheckBoxGroup/CheckBoxGroup.helpers.ts
7670
7766
  var areSelectedIdsEqual = (ids1, ids2) => {
7671
7767
  if (ids1 === ids2) return true;
@@ -8361,6 +8457,8 @@ function TableProvider({
8361
8457
  rowKey,
8362
8458
  onParamsChange,
8363
8459
  onRowClick,
8460
+ headerContent,
8461
+ containerClassName,
8364
8462
  children
8365
8463
  }) {
8366
8464
  const [searchQuery, setSearchQuery] = useState18("");
@@ -8437,23 +8535,23 @@ function TableProvider({
8437
8535
  useEffect18(() => {
8438
8536
  onParamsChange?.(combinedParams);
8439
8537
  }, [combinedParams]);
8440
- const handleSearchChange = useCallback4((value) => {
8538
+ const handleSearchChange = useCallback5((value) => {
8441
8539
  setSearchQuery(value);
8442
8540
  setCurrentPage(1);
8443
8541
  }, []);
8444
- const handleFilterApply = useCallback4(() => {
8542
+ const handleFilterApply = useCallback5(() => {
8445
8543
  applyFilters();
8446
8544
  setIsFilterModalOpen(false);
8447
8545
  setCurrentPage(1);
8448
8546
  }, [applyFilters]);
8449
- const handlePageChange = useCallback4((page) => {
8547
+ const handlePageChange = useCallback5((page) => {
8450
8548
  setCurrentPage(page);
8451
8549
  }, []);
8452
- const handleItemsPerPageChange = useCallback4((items) => {
8550
+ const handleItemsPerPageChange = useCallback5((items) => {
8453
8551
  setItemsPerPage(items);
8454
8552
  setCurrentPage(1);
8455
8553
  }, []);
8456
- const handleRowClickInternal = useCallback4(
8554
+ const handleRowClickInternal = useCallback5(
8457
8555
  (row, index) => {
8458
8556
  if (enableRowClick && onRowClick) {
8459
8557
  onRowClick(row, index);
@@ -8505,6 +8603,10 @@ function TableProvider({
8505
8603
  }
8506
8604
  ) })
8507
8605
  ] });
8606
+ const headerSection = (headerContent || controls) && /* @__PURE__ */ jsxs33("div", { className: "flex flex-col md:flex-row items-stretch md:items-center justify-between gap-4", children: [
8607
+ headerContent && /* @__PURE__ */ jsx46("div", { children: headerContent }),
8608
+ controls && /* @__PURE__ */ jsx46("div", { className: "flex-1 md:flex-none", children: controls })
8609
+ ] });
8508
8610
  const table = /* @__PURE__ */ jsx46("div", { className: "w-full overflow-x-auto", children: /* @__PURE__ */ jsxs33(
8509
8611
  Table_default,
8510
8612
  {
@@ -8601,7 +8703,11 @@ function TableProvider({
8601
8703
  ) });
8602
8704
  if (children) {
8603
8705
  return /* @__PURE__ */ jsxs33(Fragment9, { children: [
8604
- children({ controls, table, pagination }),
8706
+ children({
8707
+ controls: headerSection || controls || null,
8708
+ table,
8709
+ pagination
8710
+ }),
8605
8711
  enableFilters && /* @__PURE__ */ jsx46(
8606
8712
  FilterModal,
8607
8713
  {
@@ -8615,8 +8721,9 @@ function TableProvider({
8615
8721
  )
8616
8722
  ] });
8617
8723
  }
8618
- return /* @__PURE__ */ jsxs33("div", { className: "w-full space-y-4", children: [
8619
- controls,
8724
+ const wrapperClassName = containerClassName || "w-full space-y-4";
8725
+ return /* @__PURE__ */ jsxs33("div", { className: wrapperClassName, children: [
8726
+ headerSection,
8620
8727
  table,
8621
8728
  pagination,
8622
8729
  enableFilters && /* @__PURE__ */ jsx46(
@@ -8721,10 +8828,7 @@ var createTableColumns = (onCorrectActivity) => [
8721
8828
  ];
8722
8829
  var ActivityDetails = ({
8723
8830
  activityId,
8724
- fetchActivityDetails,
8725
- fetchStudentCorrection,
8726
- submitObservation,
8727
- submitQuestionCorrection,
8831
+ apiClient,
8728
8832
  onBack,
8729
8833
  onViewActivity,
8730
8834
  emptyStateImage,
@@ -8744,6 +8848,12 @@ var ActivityDetails = ({
8744
8848
  const [isModalOpen, setIsModalOpen] = useState19(false);
8745
8849
  const [isViewOnlyModal, setIsViewOnlyModal] = useState19(false);
8746
8850
  const [correctionError, setCorrectionError] = useState19(null);
8851
+ const {
8852
+ fetchActivityDetails,
8853
+ fetchStudentCorrection,
8854
+ submitObservation,
8855
+ submitQuestionCorrection
8856
+ } = useActivityDetails(apiClient);
8747
8857
  useEffect19(() => {
8748
8858
  const loadData = async () => {
8749
8859
  if (!activityId) return;
@@ -8767,7 +8877,7 @@ var ActivityDetails = ({
8767
8877
  };
8768
8878
  loadData();
8769
8879
  }, [activityId, page, limit, sortBy, sortOrder, fetchActivityDetails]);
8770
- const handleCorrectActivity = useCallback5(
8880
+ const handleCorrectActivity = useCallback6(
8771
8881
  async (studentId) => {
8772
8882
  const student = data?.students.find((s) => s.studentId === studentId);
8773
8883
  if (!student || !activityId) return;
@@ -8792,23 +8902,24 @@ var ActivityDetails = ({
8792
8902
  },
8793
8903
  [data?.students, activityId, fetchStudentCorrection]
8794
8904
  );
8795
- const handleCloseModal = useCallback5(() => {
8905
+ const handleCloseModal = useCallback6(() => {
8796
8906
  setIsModalOpen(false);
8797
8907
  }, []);
8798
- const handleObservationSubmit = useCallback5(
8908
+ const handleObservationSubmit = useCallback6(
8799
8909
  async (studentId, observation, files) => {
8800
8910
  if (!activityId || !studentId) return;
8801
8911
  try {
8802
- await submitObservation(activityId, studentId, observation, files);
8912
+ const file = files.length > 0 ? files[0] : null;
8913
+ await submitObservation(activityId, studentId, observation, file);
8803
8914
  } catch (err) {
8804
8915
  console.error("Failed to submit observation:", err);
8805
8916
  }
8806
8917
  },
8807
8918
  [activityId, submitObservation]
8808
8919
  );
8809
- const handleQuestionCorrectionSubmit = useCallback5(
8920
+ const handleQuestionCorrectionSubmit = useCallback6(
8810
8921
  async (studentId, payload) => {
8811
- if (!activityId || !studentId || !submitQuestionCorrection) return;
8922
+ if (!activityId || !studentId) return;
8812
8923
  try {
8813
8924
  await submitQuestionCorrection(activityId, studentId, payload);
8814
8925
  } catch (err) {