analytica-frontend-lib 1.2.68 → 1.2.69

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
@@ -42,6 +42,7 @@ __export(src_exports, {
42
42
  ActivityDetails: () => ActivityDetails,
43
43
  ActivityDisplayStatus: () => GenericDisplayStatus,
44
44
  ActivityDraftType: () => ActivityDraftType,
45
+ ActivityFilter: () => ActivityFilter,
45
46
  ActivityFilters: () => ActivityFilters,
46
47
  ActivityFiltersPopover: () => ActivityFiltersPopover,
47
48
  ActivityPreview: () => ActivityPreview,
@@ -59,6 +60,7 @@ __export(src_exports, {
59
60
  CHAT_MESSAGE_TYPES: () => CHAT_MESSAGE_TYPES,
60
61
  CORRECTION_QUESTION_STATUS: () => QUESTION_STATUS2,
61
62
  Calendar: () => Calendar_default,
63
+ CalendarActivityStatus: () => CalendarActivityStatus,
62
64
  CardAccordation: () => CardAccordation,
63
65
  CardActivitiesResults: () => CardActivitiesResults,
64
66
  CardAudio: () => CardAudio,
@@ -97,6 +99,7 @@ __export(src_exports, {
97
99
  FilterModal: () => FilterModal,
98
100
  GOAL_FILTER_STATUS_OPTIONS: () => GOAL_FILTER_STATUS_OPTIONS,
99
101
  GOAL_STATUS_OPTIONS: () => GOAL_STATUS_OPTIONS,
102
+ GeneralActivityStatus: () => ActivityStatus2,
100
103
  GoalApiStatus: () => GenericApiStatus,
101
104
  GoalBadgeActionType: () => BadgeActionType,
102
105
  GoalDisplayStatus: () => GenericDisplayStatus,
@@ -309,6 +312,7 @@ __export(src_exports, {
309
312
  useQuestionsPdfPrint: () => useQuestionsPdfPrint,
310
313
  useQuizStore: () => useQuizStore,
311
314
  useRouteAuth: () => useRouteAuth,
315
+ useSendActivity: () => useSendActivity,
312
316
  useSendActivityModal: () => useSendActivityModal,
313
317
  useTableFilter: () => useTableFilter,
314
318
  useTableSort: () => useTableSort,
@@ -14846,9 +14850,9 @@ var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
14846
14850
  ActivityType2["ATIVIDADE"] = "ATIVIDADE";
14847
14851
  return ActivityType2;
14848
14852
  })(ActivityType || {});
14849
- var ActivityStatus = /* @__PURE__ */ ((ActivityStatus2) => {
14850
- ActivityStatus2["A_VENCER"] = "A_VENCER";
14851
- return ActivityStatus2;
14853
+ var ActivityStatus = /* @__PURE__ */ ((ActivityStatus3) => {
14854
+ ActivityStatus3["A_VENCER"] = "A_VENCER";
14855
+ return ActivityStatus3;
14852
14856
  })(ActivityStatus || {});
14853
14857
 
14854
14858
  // src/components/ActivityCreate/ActivityCreate.utils.ts
@@ -27338,6 +27342,182 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27338
27342
  token
27339
27343
  };
27340
27344
  };
27345
+
27346
+ // src/types/activities.ts
27347
+ var ActivityStatus2 = /* @__PURE__ */ ((ActivityStatus3) => {
27348
+ ActivityStatus3["MODELO"] = "MODELO";
27349
+ ActivityStatus3["NAO_INICIADA"] = "NAO_INICIADA";
27350
+ ActivityStatus3["EM_ANDAMENTO"] = "EM_ANDAMENTO";
27351
+ ActivityStatus3["CONCLUIDA"] = "CONCLUIDA";
27352
+ return ActivityStatus3;
27353
+ })(ActivityStatus2 || {});
27354
+ var ActivityFilter = /* @__PURE__ */ ((ActivityFilter2) => {
27355
+ ActivityFilter2["NEAR"] = "NEAR";
27356
+ ActivityFilter2["CONCLUDED"] = "CONCLUDED";
27357
+ return ActivityFilter2;
27358
+ })(ActivityFilter || {});
27359
+ var CalendarActivityStatus = /* @__PURE__ */ ((CalendarActivityStatus2) => {
27360
+ CalendarActivityStatus2["NEAR_DEADLINE"] = "near-deadline";
27361
+ CalendarActivityStatus2["OVERDUE"] = "overdue";
27362
+ CalendarActivityStatus2["IN_DEADLINE"] = "in-deadline";
27363
+ return CalendarActivityStatus2;
27364
+ })(CalendarActivityStatus || {});
27365
+
27366
+ // src/hooks/useSendActivity.ts
27367
+ var import_react91 = require("react");
27368
+ var import_dayjs6 = __toESM(require("dayjs"));
27369
+ function transformToCategoryConfig(data) {
27370
+ return [
27371
+ {
27372
+ key: "escola",
27373
+ label: "Escola",
27374
+ itens: data.schools,
27375
+ selectedIds: []
27376
+ },
27377
+ {
27378
+ key: "serie",
27379
+ label: "S\xE9rie",
27380
+ dependsOn: ["escola"],
27381
+ itens: data.schoolYears,
27382
+ filteredBy: [{ key: "escola", internalField: "escolaId" }],
27383
+ selectedIds: []
27384
+ },
27385
+ {
27386
+ key: "turma",
27387
+ label: "Turma",
27388
+ dependsOn: ["escola", "serie"],
27389
+ itens: data.classes,
27390
+ filteredBy: [
27391
+ { key: "escola", internalField: "escolaId" },
27392
+ { key: "serie", internalField: "serieId" }
27393
+ ],
27394
+ selectedIds: []
27395
+ },
27396
+ {
27397
+ key: "alunos",
27398
+ label: "Aluno",
27399
+ dependsOn: ["escola", "serie", "turma"],
27400
+ itens: data.students,
27401
+ filteredBy: [
27402
+ { key: "escola", internalField: "escolaId" },
27403
+ { key: "serie", internalField: "serieId" },
27404
+ { key: "turma", internalField: "turmaId" }
27405
+ ],
27406
+ selectedIds: []
27407
+ }
27408
+ ];
27409
+ }
27410
+ function toISODateTime(date, time) {
27411
+ return (0, import_dayjs6.default)(`${date}T${time}`).toISOString();
27412
+ }
27413
+ function useSendActivity(config) {
27414
+ const {
27415
+ fetchCategories,
27416
+ createActivity,
27417
+ sendToStudents,
27418
+ fetchQuestionIds,
27419
+ onSuccess,
27420
+ onError
27421
+ } = config;
27422
+ const [isOpen, setIsOpen] = (0, import_react91.useState)(false);
27423
+ const [selectedModel, setSelectedModel] = (0, import_react91.useState)(
27424
+ null
27425
+ );
27426
+ const [categories, setCategories] = (0, import_react91.useState)([]);
27427
+ const [isLoading, setIsLoading] = (0, import_react91.useState)(false);
27428
+ const [isCategoriesLoading, setIsCategoriesLoading] = (0, import_react91.useState)(false);
27429
+ const categoriesLoadedRef = (0, import_react91.useRef)(false);
27430
+ const initialData = (0, import_react91.useMemo)(() => {
27431
+ if (!selectedModel) return void 0;
27432
+ return {
27433
+ title: selectedModel.title
27434
+ };
27435
+ }, [selectedModel]);
27436
+ const loadCategories = (0, import_react91.useCallback)(async () => {
27437
+ if (categoriesLoadedRef.current) return;
27438
+ setIsCategoriesLoading(true);
27439
+ try {
27440
+ const data = await fetchCategories();
27441
+ const categoryConfig = transformToCategoryConfig(data);
27442
+ setCategories(categoryConfig);
27443
+ categoriesLoadedRef.current = true;
27444
+ } catch (error) {
27445
+ console.error("Error loading categories:", error);
27446
+ onError?.("Erro ao carregar destinat\xE1rios");
27447
+ } finally {
27448
+ setIsCategoriesLoading(false);
27449
+ }
27450
+ }, [fetchCategories, onError]);
27451
+ const openModal = (0, import_react91.useCallback)(
27452
+ (model) => {
27453
+ setSelectedModel(model);
27454
+ setIsOpen(true);
27455
+ void loadCategories();
27456
+ },
27457
+ [loadCategories]
27458
+ );
27459
+ const closeModal = (0, import_react91.useCallback)(() => {
27460
+ setIsOpen(false);
27461
+ setSelectedModel(null);
27462
+ }, []);
27463
+ const onCategoriesChange = (0, import_react91.useCallback)(
27464
+ (updatedCategories) => {
27465
+ setCategories(updatedCategories);
27466
+ },
27467
+ []
27468
+ );
27469
+ const handleSubmit = (0, import_react91.useCallback)(
27470
+ async (data) => {
27471
+ if (!selectedModel) return;
27472
+ setIsLoading(true);
27473
+ try {
27474
+ const questionIds = await fetchQuestionIds(selectedModel.id);
27475
+ if (!questionIds || questionIds.length === 0) {
27476
+ throw new Error("N\xE3o foi poss\xEDvel obter quest\xF5es do modelo");
27477
+ }
27478
+ const createResponse = await createActivity({
27479
+ title: data.title,
27480
+ subjectId: selectedModel.subjectId,
27481
+ questionIds,
27482
+ subtype: data.subtype,
27483
+ notification: data.notification,
27484
+ startDate: toISODateTime(data.startDate, data.startTime),
27485
+ finalDate: toISODateTime(data.finalDate, data.finalTime),
27486
+ canRetry: data.canRetry
27487
+ });
27488
+ await sendToStudents(createResponse.id, data.students);
27489
+ onSuccess?.(`Atividade enviada para ${data.students.length} aluno(s)`);
27490
+ closeModal();
27491
+ } catch (error) {
27492
+ console.error("Error sending activity:", error);
27493
+ onError?.("Erro ao enviar atividade");
27494
+ } finally {
27495
+ setIsLoading(false);
27496
+ }
27497
+ },
27498
+ [
27499
+ selectedModel,
27500
+ fetchQuestionIds,
27501
+ createActivity,
27502
+ sendToStudents,
27503
+ onSuccess,
27504
+ onError,
27505
+ closeModal
27506
+ ]
27507
+ );
27508
+ return {
27509
+ isOpen,
27510
+ openModal,
27511
+ closeModal,
27512
+ selectedModel,
27513
+ initialData,
27514
+ categories,
27515
+ onCategoriesChange,
27516
+ isLoading,
27517
+ isCategoriesLoading,
27518
+ handleSubmit
27519
+ };
27520
+ }
27341
27521
  // Annotate the CommonJS export names for ESM import in node:
27342
27522
  0 && (module.exports = {
27343
27523
  ACTIVITY_AVAILABILITY,
@@ -27352,6 +27532,7 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27352
27532
  ActivityDetails,
27353
27533
  ActivityDisplayStatus,
27354
27534
  ActivityDraftType,
27535
+ ActivityFilter,
27355
27536
  ActivityFilters,
27356
27537
  ActivityFiltersPopover,
27357
27538
  ActivityPreview,
@@ -27369,6 +27550,7 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27369
27550
  CHAT_MESSAGE_TYPES,
27370
27551
  CORRECTION_QUESTION_STATUS,
27371
27552
  Calendar,
27553
+ CalendarActivityStatus,
27372
27554
  CardAccordation,
27373
27555
  CardActivitiesResults,
27374
27556
  CardAudio,
@@ -27407,6 +27589,7 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27407
27589
  FilterModal,
27408
27590
  GOAL_FILTER_STATUS_OPTIONS,
27409
27591
  GOAL_STATUS_OPTIONS,
27592
+ GeneralActivityStatus,
27410
27593
  GoalApiStatus,
27411
27594
  GoalBadgeActionType,
27412
27595
  GoalDisplayStatus,
@@ -27619,6 +27802,7 @@ var getChatUserInfo = (user, tokens, sessionInfo, defaultUserName = "Usuario") =
27619
27802
  useQuestionsPdfPrint,
27620
27803
  useQuizStore,
27621
27804
  useRouteAuth,
27805
+ useSendActivity,
27622
27806
  useSendActivityModal,
27623
27807
  useTableFilter,
27624
27808
  useTableSort,