analytica-frontend-lib 1.2.51 → 1.2.53
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/ActivitiesHistory/index.css +19420 -0
- package/dist/ActivitiesHistory/index.css.map +1 -0
- package/dist/ActivitiesHistory/index.d.ts +2 -0
- package/dist/ActivitiesHistory/index.d.ts.map +1 -0
- package/dist/ActivitiesHistory/index.js +7381 -0
- package/dist/ActivitiesHistory/index.js.map +1 -0
- package/dist/ActivitiesHistory/index.mjs +7424 -0
- package/dist/ActivitiesHistory/index.mjs.map +1 -0
- package/dist/ActivityCardQuestionBanks/index.css +46 -0
- package/dist/ActivityCardQuestionBanks/index.css.map +1 -1
- package/dist/ActivityCardQuestionPreview/index.css +46 -0
- package/dist/ActivityCardQuestionPreview/index.css.map +1 -1
- package/dist/ActivityDetails/index.css +46 -0
- package/dist/ActivityDetails/index.css.map +1 -1
- package/dist/ActivityFilters/index.css +46 -0
- package/dist/ActivityFilters/index.css.map +1 -1
- package/dist/ActivityPreview/index.css +46 -0
- package/dist/ActivityPreview/index.css.map +1 -1
- package/dist/AlertManager/index.css +46 -0
- package/dist/AlertManager/index.css.map +1 -1
- package/dist/RecommendedLessonsHistory/index.css +46 -0
- package/dist/RecommendedLessonsHistory/index.css.map +1 -1
- package/dist/RecommendedLessonsHistory/index.js +10 -2
- package/dist/RecommendedLessonsHistory/index.js.map +1 -1
- package/dist/RecommendedLessonsHistory/index.mjs +10 -2
- package/dist/RecommendedLessonsHistory/index.mjs.map +1 -1
- package/dist/SendActivityModal/SendActivityModal.css +46 -0
- package/dist/SendActivityModal/SendActivityModal.css.map +1 -1
- package/dist/SendActivityModal/index.css +46 -0
- package/dist/SendActivityModal/index.css.map +1 -1
- package/dist/TableProvider/index.css +46 -0
- package/dist/TableProvider/index.css.map +1 -1
- package/dist/hooks/useActivitiesHistory/index.d.ts +210 -0
- package/dist/hooks/useActivitiesHistory/index.d.ts.map +1 -0
- package/dist/hooks/useActivitiesHistory/index.js +181 -0
- package/dist/hooks/useActivitiesHistory/index.js.map +1 -0
- package/dist/hooks/useActivitiesHistory/index.mjs +141 -0
- package/dist/hooks/useActivitiesHistory/index.mjs.map +1 -0
- package/dist/hooks/useActivitiesHistory.d.ts +210 -0
- package/dist/hooks/useActivitiesHistory.d.ts.map +1 -0
- package/dist/hooks/useActivityModels/index.d.ts +220 -0
- package/dist/hooks/useActivityModels/index.d.ts.map +1 -0
- package/dist/hooks/useActivityModels/index.js +186 -0
- package/dist/hooks/useActivityModels/index.js.map +1 -0
- package/dist/hooks/useActivityModels/index.mjs +146 -0
- package/dist/hooks/useActivityModels/index.mjs.map +1 -0
- package/dist/hooks/useActivityModels.d.ts +220 -0
- package/dist/hooks/useActivityModels.d.ts.map +1 -0
- package/dist/hooks/useChat.d.ts +112 -0
- package/dist/hooks/useChat.d.ts.map +1 -0
- package/dist/hooks/useChatRooms.d.ts +76 -0
- package/dist/hooks/useChatRooms.d.ts.map +1 -0
- package/dist/index.css +46 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1778 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1755 -23
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +46 -0
- package/dist/styles.css.map +1 -1
- package/dist/types/activitiesHistory/index.d.ts +196 -0
- package/dist/types/activitiesHistory/index.d.ts.map +1 -0
- package/dist/types/activitiesHistory/index.js +92 -0
- package/dist/types/activitiesHistory/index.js.map +1 -0
- package/dist/types/activitiesHistory/index.mjs +59 -0
- package/dist/types/activitiesHistory/index.mjs.map +1 -0
- package/dist/types/activitiesHistory.d.ts +196 -0
- package/dist/types/activitiesHistory.d.ts.map +1 -0
- package/dist/types/chat.d.ts +164 -0
- package/dist/types/chat.d.ts.map +1 -0
- package/dist/types/common.d.ts +44 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/recommendedLessons/index.d.ts +10 -18
- package/dist/types/recommendedLessons/index.d.ts.map +1 -1
- package/dist/types/recommendedLessons/index.js +27 -22
- package/dist/types/recommendedLessons/index.js.map +1 -1
- package/dist/types/recommendedLessons/index.mjs +26 -23
- package/dist/types/recommendedLessons/index.mjs.map +1 -1
- package/dist/types/recommendedLessons.d.ts +10 -18
- package/dist/types/recommendedLessons.d.ts.map +1 -1
- package/dist/utils/hookErrorHandler.d.ts +24 -0
- package/dist/utils/hookErrorHandler.d.ts.map +1 -0
- package/package.json +8 -1
- package/dist/RecommendedLessonDetails/index.d.ts +0 -5
- package/dist/RecommendedLessonDetails/index.d.ts.map +0 -1
- package/dist/RecommendedLessonDetails/index.js +0 -4854
- package/dist/RecommendedLessonDetails/index.js.map +0 -1
- package/dist/RecommendedLessonDetails/index.mjs +0 -4872
- package/dist/RecommendedLessonDetails/index.mjs.map +0 -1
- package/dist/hooks/useRecommendedLessonDetails/index.d.ts +0 -780
- package/dist/hooks/useRecommendedLessonDetails/index.d.ts.map +0 -1
- package/dist/hooks/useRecommendedLessonDetails/index.js +0 -204
- package/dist/hooks/useRecommendedLessonDetails/index.js.map +0 -1
- package/dist/hooks/useRecommendedLessonDetails/index.mjs +0 -174
- package/dist/hooks/useRecommendedLessonDetails/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -31,11 +31,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
ACTIVITY_AVAILABILITY: () => ACTIVITY_AVAILABILITY,
|
|
34
|
+
ACTIVITY_FILTER_STATUS_OPTIONS: () => ACTIVITY_FILTER_STATUS_OPTIONS,
|
|
34
35
|
ANSWER_STATUS: () => ANSWER_STATUS,
|
|
35
36
|
AccordionGroup: () => AccordionGroup,
|
|
37
|
+
ActivitiesHistory: () => ActivitiesHistory,
|
|
38
|
+
ActivityApiStatus: () => GenericApiStatus,
|
|
39
|
+
ActivityBadgeActionType: () => BadgeActionType,
|
|
36
40
|
ActivityCardQuestionBanks: () => ActivityCardQuestionBanks,
|
|
37
41
|
ActivityCardQuestionPreview: () => ActivityCardQuestionPreview,
|
|
38
42
|
ActivityDetails: () => ActivityDetails,
|
|
43
|
+
ActivityDisplayStatus: () => GenericDisplayStatus,
|
|
44
|
+
ActivityDraftType: () => ActivityDraftType,
|
|
39
45
|
ActivityFilters: () => ActivityFilters,
|
|
40
46
|
ActivityFiltersPopover: () => ActivityFiltersPopover,
|
|
41
47
|
ActivityPreview: () => ActivityPreview,
|
|
@@ -48,6 +54,7 @@ __export(src_exports, {
|
|
|
48
54
|
Badge: () => Badge_default,
|
|
49
55
|
BreadcrumbMenu: () => BreadcrumbMenu,
|
|
50
56
|
Button: () => Button_default,
|
|
57
|
+
CHAT_MESSAGE_TYPES: () => CHAT_MESSAGE_TYPES,
|
|
51
58
|
CORRECTION_QUESTION_STATUS: () => QUESTION_STATUS2,
|
|
52
59
|
Calendar: () => Calendar_default,
|
|
53
60
|
CardAccordation: () => CardAccordation,
|
|
@@ -62,6 +69,7 @@ __export(src_exports, {
|
|
|
62
69
|
CardStatus: () => CardStatus,
|
|
63
70
|
CardTest: () => CardTest,
|
|
64
71
|
CardTopic: () => CardTopic,
|
|
72
|
+
Chat: () => Chat,
|
|
65
73
|
CheckBox: () => CheckBox_default,
|
|
66
74
|
CheckboxGroup: () => CheckboxGroup,
|
|
67
75
|
CheckboxList: () => CheckboxList_default,
|
|
@@ -69,6 +77,8 @@ __export(src_exports, {
|
|
|
69
77
|
Chips: () => Chips_default,
|
|
70
78
|
CorrectActivityModal: () => CorrectActivityModal_default,
|
|
71
79
|
CreateActivity: () => CreateActivity,
|
|
80
|
+
DEFAULT_ACTIVITIES_PAGINATION: () => DEFAULT_ACTIVITIES_PAGINATION,
|
|
81
|
+
DEFAULT_MODELS_PAGINATION: () => DEFAULT_MODELS_PAGINATION,
|
|
72
82
|
DIFFICULTY_LEVEL_ENUM: () => DIFFICULTY_LEVEL_ENUM,
|
|
73
83
|
DateTimeInput: () => DateTimeInput_default,
|
|
74
84
|
Divider: () => Divider_default,
|
|
@@ -84,9 +94,9 @@ __export(src_exports, {
|
|
|
84
94
|
FilterModal: () => FilterModal,
|
|
85
95
|
GOAL_FILTER_STATUS_OPTIONS: () => GOAL_FILTER_STATUS_OPTIONS,
|
|
86
96
|
GOAL_STATUS_OPTIONS: () => GOAL_STATUS_OPTIONS,
|
|
87
|
-
GoalApiStatus: () =>
|
|
88
|
-
GoalBadgeActionType: () =>
|
|
89
|
-
GoalDisplayStatus: () =>
|
|
97
|
+
GoalApiStatus: () => GenericApiStatus,
|
|
98
|
+
GoalBadgeActionType: () => BadgeActionType,
|
|
99
|
+
GoalDisplayStatus: () => GenericDisplayStatus,
|
|
90
100
|
IconButton: () => IconButton_default,
|
|
91
101
|
IconRender: () => IconRender_default,
|
|
92
102
|
IconRoundedButton: () => IconRoundedButton_default,
|
|
@@ -106,6 +116,7 @@ __export(src_exports, {
|
|
|
106
116
|
NotFound: () => NotFound_default,
|
|
107
117
|
NotificationCard: () => NotificationCard_default,
|
|
108
118
|
NotificationEntityType: () => NotificationEntityType,
|
|
119
|
+
PROFILE_ROLES: () => PROFILE_ROLES,
|
|
109
120
|
ProfileMenuFooter: () => ProfileMenuFooter,
|
|
110
121
|
ProfileMenuHeader: () => ProfileMenuHeader,
|
|
111
122
|
ProfileMenuInfo: () => ProfileMenuInfo,
|
|
@@ -190,16 +201,25 @@ __export(src_exports, {
|
|
|
190
201
|
Toast: () => Toast_default,
|
|
191
202
|
Toaster: () => Toaster_default,
|
|
192
203
|
VideoPlayer: () => VideoPlayer_default,
|
|
204
|
+
WS_STATES: () => WS_STATES,
|
|
193
205
|
Whiteboard: () => Whiteboard_default,
|
|
206
|
+
activitiesHistoryApiResponseSchema: () => activitiesHistoryApiResponseSchema,
|
|
207
|
+
activityModelsApiResponseSchema: () => activityModelsApiResponseSchema,
|
|
194
208
|
cn: () => cn,
|
|
195
209
|
convertActivityFiltersToQuestionsFilter: () => convertActivityFiltersToQuestionsFilter,
|
|
210
|
+
createActivitiesHistoryHook: () => createActivitiesHistoryHook,
|
|
196
211
|
createActivityFiltersDataHook: () => createActivityFiltersDataHook,
|
|
212
|
+
createActivityModelsHook: () => createActivityModelsHook,
|
|
197
213
|
createNotificationStore: () => createNotificationStore,
|
|
198
214
|
createNotificationsHook: () => createNotificationsHook,
|
|
199
215
|
createQuestionsListHook: () => createQuestionsListHook,
|
|
200
216
|
createRecommendedLessonDetailsHook: () => createRecommendedLessonDetailsHook,
|
|
201
217
|
createRecommendedLessonsHistoryHook: () => createRecommendedLessonsHistoryHook,
|
|
218
|
+
createUseActivitiesHistory: () => createUseActivitiesHistory,
|
|
202
219
|
createUseActivityFiltersData: () => createUseActivityFiltersData,
|
|
220
|
+
createUseActivityModels: () => createUseActivityModels,
|
|
221
|
+
createUseChat: () => createUseChat,
|
|
222
|
+
createUseChatRooms: () => createUseChatRooms,
|
|
203
223
|
createUseNotificationStore: () => createUseNotificationStore,
|
|
204
224
|
createUseNotifications: () => createUseNotifications,
|
|
205
225
|
createUseQuestionsList: () => createUseQuestionsList,
|
|
@@ -215,6 +235,7 @@ __export(src_exports, {
|
|
|
215
235
|
formatTimeAgo: () => formatTimeAgo,
|
|
216
236
|
formatTimeSpent: () => formatTimeSpent,
|
|
217
237
|
generateFileId: () => generateFileId,
|
|
238
|
+
getActivityStatusBadgeAction: () => getActivityStatusBadgeAction,
|
|
218
239
|
getCategoryIcon: () => getCategoryIcon,
|
|
219
240
|
getCategoryText: () => getCategoryText,
|
|
220
241
|
getDeviceType: () => getDeviceType,
|
|
@@ -235,12 +256,15 @@ __export(src_exports, {
|
|
|
235
256
|
goalApiResponseSchema: () => goalApiResponseSchema,
|
|
236
257
|
goalDetailsApiResponseSchema: () => goalDetailsApiResponseSchema,
|
|
237
258
|
goalsHistoryApiResponseSchema: () => goalsHistoryApiResponseSchema,
|
|
259
|
+
handleActivityFetchError: () => handleActivityFetchError,
|
|
238
260
|
handleGoalFetchError: () => handleGoalFetchError,
|
|
239
261
|
handleLessonDetailsFetchError: () => handleLessonDetailsFetchError,
|
|
262
|
+
handleModelFetchError: () => handleModelFetchError,
|
|
240
263
|
historyApiResponseSchema: () => historyApiResponseSchema,
|
|
241
264
|
isDeadlinePassed: () => isDeadlinePassed,
|
|
242
265
|
isFormValid: () => isFormValid,
|
|
243
266
|
isStepValid: () => isStepValid,
|
|
267
|
+
mapActivityStatusToDisplay: () => mapActivityStatusToDisplay,
|
|
244
268
|
mapApiStatusToInternal: () => mapApiStatusToInternal,
|
|
245
269
|
mapInternalStatusToApi: () => mapInternalStatusToApi,
|
|
246
270
|
mapQuestionTypeToEnum: () => mapQuestionTypeToEnum,
|
|
@@ -250,7 +274,9 @@ __export(src_exports, {
|
|
|
250
274
|
syncDropdownState: () => syncDropdownState,
|
|
251
275
|
toggleArrayItem: () => toggleArrayItem,
|
|
252
276
|
toggleSingleValue: () => toggleSingleValue,
|
|
277
|
+
transformActivityToTableItem: () => transformActivityToTableItem,
|
|
253
278
|
transformGoalToTableItem: () => transformGoalToTableItem,
|
|
279
|
+
transformModelToTableItem: () => transformModelToTableItem,
|
|
254
280
|
useAlertFormStore: () => useAlertFormStore,
|
|
255
281
|
useApiConfig: () => useApiConfig,
|
|
256
282
|
useAppContent: () => useAppContent,
|
|
@@ -261,6 +287,8 @@ __export(src_exports, {
|
|
|
261
287
|
useAuthStore: () => useAuthStore,
|
|
262
288
|
useBreadcrumb: () => useBreadcrumb,
|
|
263
289
|
useBreadcrumbBuilder: () => useBreadcrumbBuilder,
|
|
290
|
+
useChat: () => useChat,
|
|
291
|
+
useChatRooms: () => useChatRooms,
|
|
264
292
|
useInstitutionId: () => useInstitutionId,
|
|
265
293
|
useMobile: () => useMobile,
|
|
266
294
|
useQuestionFiltersStore: () => useQuestionFiltersStore,
|
|
@@ -5225,6 +5253,11 @@ var Toaster = () => {
|
|
|
5225
5253
|
toast.id
|
|
5226
5254
|
)) });
|
|
5227
5255
|
};
|
|
5256
|
+
var useToast = () => {
|
|
5257
|
+
const addToast = ToastStore_default((state) => state.addToast);
|
|
5258
|
+
const removeToast = ToastStore_default((state) => state.removeToast);
|
|
5259
|
+
return { addToast, removeToast };
|
|
5260
|
+
};
|
|
5228
5261
|
var Toaster_default = Toaster;
|
|
5229
5262
|
|
|
5230
5263
|
// src/components/Search/Search.tsx
|
|
@@ -22523,26 +22556,26 @@ var SendActivityModal_default = SendActivityModal;
|
|
|
22523
22556
|
var import_react71 = require("react");
|
|
22524
22557
|
var import_phosphor_react44 = require("phosphor-react");
|
|
22525
22558
|
|
|
22526
|
-
// src/types/
|
|
22527
|
-
var
|
|
22528
|
-
|
|
22529
|
-
|
|
22530
|
-
|
|
22531
|
-
return
|
|
22532
|
-
})(
|
|
22533
|
-
var
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22537
|
-
return
|
|
22538
|
-
})(
|
|
22539
|
-
var
|
|
22540
|
-
|
|
22541
|
-
|
|
22542
|
-
|
|
22543
|
-
return
|
|
22544
|
-
})(
|
|
22545
|
-
var
|
|
22559
|
+
// src/types/common.ts
|
|
22560
|
+
var GenericApiStatus = /* @__PURE__ */ ((GenericApiStatus2) => {
|
|
22561
|
+
GenericApiStatus2["A_VENCER"] = "A_VENCER";
|
|
22562
|
+
GenericApiStatus2["VENCIDA"] = "VENCIDA";
|
|
22563
|
+
GenericApiStatus2["CONCLUIDA"] = "CONCLUIDA";
|
|
22564
|
+
return GenericApiStatus2;
|
|
22565
|
+
})(GenericApiStatus || {});
|
|
22566
|
+
var GenericDisplayStatus = /* @__PURE__ */ ((GenericDisplayStatus4) => {
|
|
22567
|
+
GenericDisplayStatus4["ATIVA"] = "ATIVA";
|
|
22568
|
+
GenericDisplayStatus4["VENCIDA"] = "VENCIDA";
|
|
22569
|
+
GenericDisplayStatus4["CONCLUIDA"] = "CONCLU\xCDDA";
|
|
22570
|
+
return GenericDisplayStatus4;
|
|
22571
|
+
})(GenericDisplayStatus || {});
|
|
22572
|
+
var BadgeActionType = /* @__PURE__ */ ((BadgeActionType4) => {
|
|
22573
|
+
BadgeActionType4["SUCCESS"] = "success";
|
|
22574
|
+
BadgeActionType4["WARNING"] = "warning";
|
|
22575
|
+
BadgeActionType4["ERROR"] = "error";
|
|
22576
|
+
return BadgeActionType4;
|
|
22577
|
+
})(BadgeActionType || {});
|
|
22578
|
+
var getStatusBadgeAction2 = (status) => {
|
|
22546
22579
|
const actionMap = {
|
|
22547
22580
|
["CONCLU\xCDDA" /* CONCLUIDA */]: "success" /* SUCCESS */,
|
|
22548
22581
|
["ATIVA" /* ATIVA */]: "warning" /* WARNING */,
|
|
@@ -22550,6 +22583,17 @@ var getGoalStatusBadgeAction = (status) => {
|
|
|
22550
22583
|
};
|
|
22551
22584
|
return actionMap[status] ?? "warning" /* WARNING */;
|
|
22552
22585
|
};
|
|
22586
|
+
var mapApiStatusToDisplay = (apiStatus) => {
|
|
22587
|
+
const statusMap = {
|
|
22588
|
+
["A_VENCER" /* A_VENCER */]: "ATIVA" /* ATIVA */,
|
|
22589
|
+
["VENCIDA" /* VENCIDA */]: "VENCIDA" /* VENCIDA */,
|
|
22590
|
+
["CONCLUIDA" /* CONCLUIDA */]: "CONCLU\xCDDA" /* CONCLUIDA */
|
|
22591
|
+
};
|
|
22592
|
+
return statusMap[apiStatus];
|
|
22593
|
+
};
|
|
22594
|
+
|
|
22595
|
+
// src/types/recommendedLessons.ts
|
|
22596
|
+
var getGoalStatusBadgeAction = (status) => getStatusBadgeAction2(status);
|
|
22553
22597
|
var GOAL_FILTER_STATUS_OPTIONS = [
|
|
22554
22598
|
{ id: "VENCIDA" /* VENCIDA */, name: "Vencida" },
|
|
22555
22599
|
{ id: "A_VENCER" /* A_VENCER */, name: "Ativa" }
|
|
@@ -24093,14 +24137,1703 @@ var createUseRecommendedLessonDetails = (apiClient) => {
|
|
|
24093
24137
|
};
|
|
24094
24138
|
};
|
|
24095
24139
|
var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
24140
|
+
|
|
24141
|
+
// src/components/ActivitiesHistory/ActivitiesHistory.tsx
|
|
24142
|
+
var import_react85 = require("react");
|
|
24143
|
+
|
|
24144
|
+
// src/components/ActivitiesHistory/tabs/HistoryTab.tsx
|
|
24145
|
+
var import_react82 = require("react");
|
|
24146
|
+
var import_phosphor_react46 = require("phosphor-react");
|
|
24147
|
+
|
|
24148
|
+
// src/components/ActivitiesHistory/components/ErrorDisplay.tsx
|
|
24149
|
+
var import_jsx_runtime95 = require("react/jsx-runtime");
|
|
24150
|
+
var ErrorDisplay = ({ error }) => /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "flex items-center justify-center bg-background rounded-xl w-full min-h-[705px]", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Text_default, { size: "lg", color: "text-error-500", children: error }) });
|
|
24151
|
+
|
|
24152
|
+
// src/components/ActivitiesHistory/config/historyTableColumns.tsx
|
|
24153
|
+
var import_phosphor_react45 = require("phosphor-react");
|
|
24154
|
+
|
|
24155
|
+
// src/components/ActivitiesHistory/utils/renderSubjectCell.tsx
|
|
24156
|
+
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
24157
|
+
var renderSubjectCell = (subjectName, mapSubjectNameToEnum, showEmptyDash = false) => {
|
|
24158
|
+
if (!subjectName) {
|
|
24159
|
+
return showEmptyDash ? /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Text_default, { size: "sm", color: "text-text-400", children: "-" }) : null;
|
|
24160
|
+
}
|
|
24161
|
+
const subjectEnum = mapSubjectNameToEnum?.(subjectName);
|
|
24162
|
+
if (!subjectEnum) {
|
|
24163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Text_default, { size: "sm", className: "truncate", title: subjectName, children: subjectName });
|
|
24164
|
+
}
|
|
24165
|
+
const subjectInfo = getSubjectInfo(subjectEnum);
|
|
24166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { className: "flex items-center gap-2", title: subjectName, children: [
|
|
24167
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
24168
|
+
"span",
|
|
24169
|
+
{
|
|
24170
|
+
className: cn(
|
|
24171
|
+
"w-[21px] h-[21px] flex items-center justify-center rounded-sm text-text-950 shrink-0",
|
|
24172
|
+
subjectInfo.colorClass
|
|
24173
|
+
),
|
|
24174
|
+
children: subjectInfo.icon
|
|
24175
|
+
}
|
|
24176
|
+
),
|
|
24177
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(Text_default, { size: "sm", className: "truncate", children: subjectName })
|
|
24178
|
+
] });
|
|
24179
|
+
};
|
|
24180
|
+
|
|
24181
|
+
// src/components/ActivitiesHistory/utils/renderTruncatedText.tsx
|
|
24182
|
+
var import_jsx_runtime97 = require("react/jsx-runtime");
|
|
24183
|
+
var renderTruncatedText = (value) => {
|
|
24184
|
+
const text = typeof value === "string" ? value : "";
|
|
24185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(Text_default, { size: "sm", title: text, children: text });
|
|
24186
|
+
};
|
|
24187
|
+
|
|
24188
|
+
// src/components/ActivitiesHistory/utils/filterBuilders.ts
|
|
24189
|
+
var isNonEmptyArray2 = (param) => Array.isArray(param) && param.length > 0;
|
|
24190
|
+
var isValidApiStatus = (value) => Object.values(GenericApiStatus).includes(value);
|
|
24191
|
+
var buildHistoryFiltersFromParams = (params) => {
|
|
24192
|
+
const filters = {
|
|
24193
|
+
page: params.page,
|
|
24194
|
+
limit: params.limit
|
|
24195
|
+
};
|
|
24196
|
+
if (params.search) {
|
|
24197
|
+
filters.search = params.search;
|
|
24198
|
+
}
|
|
24199
|
+
if (isNonEmptyArray2(params.status) && isValidApiStatus(params.status[0])) {
|
|
24200
|
+
filters.status = params.status[0];
|
|
24201
|
+
}
|
|
24202
|
+
if (isNonEmptyArray2(params.school)) {
|
|
24203
|
+
filters.schoolId = params.school[0];
|
|
24204
|
+
}
|
|
24205
|
+
if (isNonEmptyArray2(params.subject)) {
|
|
24206
|
+
filters.subjectId = params.subject[0];
|
|
24207
|
+
}
|
|
24208
|
+
return filters;
|
|
24209
|
+
};
|
|
24210
|
+
var buildModelsFiltersFromParams = (params) => {
|
|
24211
|
+
const filters = {
|
|
24212
|
+
page: params.page,
|
|
24213
|
+
limit: params.limit
|
|
24214
|
+
};
|
|
24215
|
+
if (params.search) {
|
|
24216
|
+
filters.search = params.search;
|
|
24217
|
+
}
|
|
24218
|
+
if (isNonEmptyArray2(params.subject)) {
|
|
24219
|
+
filters.subjectId = params.subject[0];
|
|
24220
|
+
}
|
|
24221
|
+
return filters;
|
|
24222
|
+
};
|
|
24223
|
+
|
|
24224
|
+
// src/components/ActivitiesHistory/utils/filterOptions.ts
|
|
24225
|
+
var getSchoolOptions2 = (data) => {
|
|
24226
|
+
if (!data?.schools) return [];
|
|
24227
|
+
return data.schools.map((school) => ({
|
|
24228
|
+
id: school.id,
|
|
24229
|
+
name: school.name
|
|
24230
|
+
}));
|
|
24231
|
+
};
|
|
24232
|
+
var getSubjectOptions2 = (data) => {
|
|
24233
|
+
if (!data?.subjects) return [];
|
|
24234
|
+
return data.subjects.map((subject) => ({
|
|
24235
|
+
id: subject.id,
|
|
24236
|
+
name: subject.name
|
|
24237
|
+
}));
|
|
24238
|
+
};
|
|
24239
|
+
|
|
24240
|
+
// src/types/activitiesHistory.ts
|
|
24241
|
+
var ActivityDraftType = /* @__PURE__ */ ((ActivityDraftType2) => {
|
|
24242
|
+
ActivityDraftType2["MODELO"] = "MODELO";
|
|
24243
|
+
ActivityDraftType2["RASCUNHO"] = "RASCUNHO";
|
|
24244
|
+
return ActivityDraftType2;
|
|
24245
|
+
})(ActivityDraftType || {});
|
|
24246
|
+
var getActivityStatusBadgeAction = (status) => getStatusBadgeAction2(status);
|
|
24247
|
+
var ACTIVITY_FILTER_STATUS_OPTIONS = [
|
|
24248
|
+
{ id: "A_VENCER" /* A_VENCER */, name: "A Vencer" },
|
|
24249
|
+
{ id: "VENCIDA" /* VENCIDA */, name: "Vencida" },
|
|
24250
|
+
{ id: "CONCLUIDA" /* CONCLUIDA */, name: "Conclu\xEDda" }
|
|
24251
|
+
];
|
|
24252
|
+
var mapActivityStatusToDisplay = (apiStatus) => mapApiStatusToDisplay(apiStatus);
|
|
24253
|
+
|
|
24254
|
+
// src/components/ActivitiesHistory/config/historyTableColumns.tsx
|
|
24255
|
+
var import_jsx_runtime98 = require("react/jsx-runtime");
|
|
24256
|
+
var createHistoryTableColumns = (mapSubjectNameToEnum) => [
|
|
24257
|
+
{
|
|
24258
|
+
key: "startDate",
|
|
24259
|
+
label: "In\xEDcio",
|
|
24260
|
+
sortable: true
|
|
24261
|
+
},
|
|
24262
|
+
{
|
|
24263
|
+
key: "deadline",
|
|
24264
|
+
label: "Prazo",
|
|
24265
|
+
sortable: true
|
|
24266
|
+
},
|
|
24267
|
+
{
|
|
24268
|
+
key: "title",
|
|
24269
|
+
label: "T\xEDtulo",
|
|
24270
|
+
sortable: true,
|
|
24271
|
+
className: "max-w-[200px] truncate",
|
|
24272
|
+
render: renderTruncatedText
|
|
24273
|
+
},
|
|
24274
|
+
{
|
|
24275
|
+
key: "school",
|
|
24276
|
+
label: "Escola",
|
|
24277
|
+
sortable: true,
|
|
24278
|
+
className: "max-w-[150px] truncate",
|
|
24279
|
+
render: renderTruncatedText
|
|
24280
|
+
},
|
|
24281
|
+
{
|
|
24282
|
+
key: "year",
|
|
24283
|
+
label: "Ano",
|
|
24284
|
+
sortable: true
|
|
24285
|
+
},
|
|
24286
|
+
{
|
|
24287
|
+
key: "subject",
|
|
24288
|
+
label: "Mat\xE9ria",
|
|
24289
|
+
sortable: true,
|
|
24290
|
+
className: "max-w-[140px]",
|
|
24291
|
+
render: (value) => {
|
|
24292
|
+
const subjectName = typeof value === "string" ? value : "";
|
|
24293
|
+
return renderSubjectCell(subjectName, mapSubjectNameToEnum, false);
|
|
24294
|
+
}
|
|
24295
|
+
},
|
|
24296
|
+
{
|
|
24297
|
+
key: "class",
|
|
24298
|
+
label: "Turma",
|
|
24299
|
+
sortable: true
|
|
24300
|
+
},
|
|
24301
|
+
{
|
|
24302
|
+
key: "status",
|
|
24303
|
+
label: "Status",
|
|
24304
|
+
sortable: true,
|
|
24305
|
+
render: (value) => {
|
|
24306
|
+
const status = typeof value === "string" ? value : "";
|
|
24307
|
+
if (!status) {
|
|
24308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Text_default, { size: "sm", color: "text-text-500", children: "-" });
|
|
24309
|
+
}
|
|
24310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
24311
|
+
Badge_default,
|
|
24312
|
+
{
|
|
24313
|
+
variant: "solid",
|
|
24314
|
+
action: getActivityStatusBadgeAction(status),
|
|
24315
|
+
size: "small",
|
|
24316
|
+
children: status
|
|
24317
|
+
}
|
|
24318
|
+
);
|
|
24319
|
+
}
|
|
24320
|
+
},
|
|
24321
|
+
{
|
|
24322
|
+
key: "completionPercentage",
|
|
24323
|
+
label: "Conclus\xE3o",
|
|
24324
|
+
sortable: true,
|
|
24325
|
+
render: (value) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
24326
|
+
ProgressBar_default,
|
|
24327
|
+
{
|
|
24328
|
+
value: Number(value),
|
|
24329
|
+
variant: "blue",
|
|
24330
|
+
size: "medium",
|
|
24331
|
+
layout: "compact",
|
|
24332
|
+
showPercentage: true,
|
|
24333
|
+
compactWidth: "w-[100px]"
|
|
24334
|
+
}
|
|
24335
|
+
)
|
|
24336
|
+
},
|
|
24337
|
+
{
|
|
24338
|
+
key: "navigation",
|
|
24339
|
+
label: "",
|
|
24340
|
+
sortable: false,
|
|
24341
|
+
className: "w-12",
|
|
24342
|
+
render: () => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_phosphor_react45.CaretRight, { size: 20, className: "text-text-600" }) })
|
|
24343
|
+
}
|
|
24344
|
+
];
|
|
24345
|
+
|
|
24346
|
+
// src/components/ActivitiesHistory/config/historyFiltersConfig.ts
|
|
24347
|
+
var createHistoryFiltersConfig = (userData) => [
|
|
24348
|
+
{
|
|
24349
|
+
key: "status",
|
|
24350
|
+
label: "STATUS",
|
|
24351
|
+
categories: [
|
|
24352
|
+
{
|
|
24353
|
+
key: "status",
|
|
24354
|
+
label: "Status da Atividade",
|
|
24355
|
+
selectedIds: [],
|
|
24356
|
+
itens: ACTIVITY_FILTER_STATUS_OPTIONS
|
|
24357
|
+
}
|
|
24358
|
+
]
|
|
24359
|
+
},
|
|
24360
|
+
{
|
|
24361
|
+
key: "academic",
|
|
24362
|
+
label: "DADOS ACAD\xCAMICOS",
|
|
24363
|
+
categories: [
|
|
24364
|
+
{
|
|
24365
|
+
key: "school",
|
|
24366
|
+
label: "Escola",
|
|
24367
|
+
selectedIds: [],
|
|
24368
|
+
itens: getSchoolOptions2(userData)
|
|
24369
|
+
}
|
|
24370
|
+
]
|
|
24371
|
+
},
|
|
24372
|
+
{
|
|
24373
|
+
key: "content",
|
|
24374
|
+
label: "CONTE\xDADO",
|
|
24375
|
+
categories: [
|
|
24376
|
+
{
|
|
24377
|
+
key: "subject",
|
|
24378
|
+
label: "Mat\xE9ria",
|
|
24379
|
+
selectedIds: [],
|
|
24380
|
+
itens: getSubjectOptions2(userData)
|
|
24381
|
+
}
|
|
24382
|
+
]
|
|
24383
|
+
}
|
|
24384
|
+
];
|
|
24385
|
+
|
|
24386
|
+
// src/hooks/useActivitiesHistory.ts
|
|
24387
|
+
var import_react81 = require("react");
|
|
24388
|
+
var import_zod7 = require("zod");
|
|
24389
|
+
var import_dayjs4 = __toESM(require("dayjs"));
|
|
24390
|
+
|
|
24391
|
+
// src/utils/hookErrorHandler.ts
|
|
24392
|
+
var import_zod6 = require("zod");
|
|
24393
|
+
var createFetchErrorHandler = (validationErrorMessage, genericErrorMessage) => (error) => {
|
|
24394
|
+
if (error instanceof import_zod6.z.ZodError) {
|
|
24395
|
+
console.error(validationErrorMessage, error);
|
|
24396
|
+
return validationErrorMessage;
|
|
24397
|
+
}
|
|
24398
|
+
console.error(genericErrorMessage, error);
|
|
24399
|
+
return genericErrorMessage;
|
|
24400
|
+
};
|
|
24401
|
+
|
|
24402
|
+
// src/hooks/useActivitiesHistory.ts
|
|
24403
|
+
var activityHistoryResponseSchema = import_zod7.z.object({
|
|
24404
|
+
id: import_zod7.z.string().uuid(),
|
|
24405
|
+
title: import_zod7.z.string(),
|
|
24406
|
+
startDate: import_zod7.z.string().nullable(),
|
|
24407
|
+
finalDate: import_zod7.z.string().nullable(),
|
|
24408
|
+
status: import_zod7.z.nativeEnum(GenericApiStatus),
|
|
24409
|
+
completionPercentage: import_zod7.z.number().min(0).max(100),
|
|
24410
|
+
subjectId: import_zod7.z.string().uuid(),
|
|
24411
|
+
schoolId: import_zod7.z.string().optional(),
|
|
24412
|
+
schoolName: import_zod7.z.string().optional(),
|
|
24413
|
+
year: import_zod7.z.string().optional(),
|
|
24414
|
+
className: import_zod7.z.string().optional(),
|
|
24415
|
+
subjectName: import_zod7.z.string().optional()
|
|
24416
|
+
});
|
|
24417
|
+
var activitiesHistoryApiResponseSchema = import_zod7.z.object({
|
|
24418
|
+
message: import_zod7.z.string(),
|
|
24419
|
+
data: import_zod7.z.object({
|
|
24420
|
+
activities: import_zod7.z.array(activityHistoryResponseSchema),
|
|
24421
|
+
pagination: import_zod7.z.object({
|
|
24422
|
+
total: import_zod7.z.number(),
|
|
24423
|
+
page: import_zod7.z.number(),
|
|
24424
|
+
limit: import_zod7.z.number(),
|
|
24425
|
+
totalPages: import_zod7.z.number()
|
|
24426
|
+
})
|
|
24427
|
+
})
|
|
24428
|
+
});
|
|
24429
|
+
var DEFAULT_ACTIVITIES_PAGINATION = {
|
|
24430
|
+
total: 0,
|
|
24431
|
+
page: 1,
|
|
24432
|
+
limit: 10,
|
|
24433
|
+
totalPages: 0
|
|
24434
|
+
};
|
|
24435
|
+
var transformActivityToTableItem = (activity) => {
|
|
24436
|
+
return {
|
|
24437
|
+
id: activity.id,
|
|
24438
|
+
startDate: activity.startDate ? (0, import_dayjs4.default)(activity.startDate).format("DD/MM") : "-",
|
|
24439
|
+
deadline: activity.finalDate ? (0, import_dayjs4.default)(activity.finalDate).format("DD/MM") : "-",
|
|
24440
|
+
title: activity.title,
|
|
24441
|
+
school: activity.schoolName || "-",
|
|
24442
|
+
year: activity.year || "-",
|
|
24443
|
+
subject: activity.subjectName || "-",
|
|
24444
|
+
class: activity.className || "-",
|
|
24445
|
+
status: mapActivityStatusToDisplay(activity.status),
|
|
24446
|
+
completionPercentage: activity.completionPercentage
|
|
24447
|
+
};
|
|
24448
|
+
};
|
|
24449
|
+
var handleActivityFetchError = createFetchErrorHandler(
|
|
24450
|
+
"Erro ao validar dados de hist\xF3rico de atividades",
|
|
24451
|
+
"Erro ao carregar hist\xF3rico de atividades"
|
|
24452
|
+
);
|
|
24453
|
+
var createUseActivitiesHistory = (fetchActivitiesHistory) => {
|
|
24454
|
+
return () => {
|
|
24455
|
+
const [state, setState] = (0, import_react81.useState)({
|
|
24456
|
+
activities: [],
|
|
24457
|
+
loading: false,
|
|
24458
|
+
error: null,
|
|
24459
|
+
pagination: DEFAULT_ACTIVITIES_PAGINATION
|
|
24460
|
+
});
|
|
24461
|
+
const fetchActivities = (0, import_react81.useCallback)(
|
|
24462
|
+
async (filters) => {
|
|
24463
|
+
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
24464
|
+
try {
|
|
24465
|
+
const responseData = await fetchActivitiesHistory(filters);
|
|
24466
|
+
const validatedData = activitiesHistoryApiResponseSchema.parse(responseData);
|
|
24467
|
+
const tableItems = validatedData.data.activities.map(
|
|
24468
|
+
transformActivityToTableItem
|
|
24469
|
+
);
|
|
24470
|
+
setState({
|
|
24471
|
+
activities: tableItems,
|
|
24472
|
+
loading: false,
|
|
24473
|
+
error: null,
|
|
24474
|
+
pagination: validatedData.data.pagination
|
|
24475
|
+
});
|
|
24476
|
+
} catch (error) {
|
|
24477
|
+
const errorMessage = handleActivityFetchError(error);
|
|
24478
|
+
setState((prev) => ({
|
|
24479
|
+
...prev,
|
|
24480
|
+
loading: false,
|
|
24481
|
+
error: errorMessage
|
|
24482
|
+
}));
|
|
24483
|
+
}
|
|
24484
|
+
},
|
|
24485
|
+
[fetchActivitiesHistory]
|
|
24486
|
+
);
|
|
24487
|
+
return {
|
|
24488
|
+
...state,
|
|
24489
|
+
fetchActivities
|
|
24490
|
+
};
|
|
24491
|
+
};
|
|
24492
|
+
};
|
|
24493
|
+
var createActivitiesHistoryHook = createUseActivitiesHistory;
|
|
24494
|
+
|
|
24495
|
+
// src/components/ActivitiesHistory/tabs/HistoryTab.tsx
|
|
24496
|
+
var import_jsx_runtime99 = require("react/jsx-runtime");
|
|
24497
|
+
var HistoryTab = ({
|
|
24498
|
+
fetchActivitiesHistory,
|
|
24499
|
+
onCreateActivity,
|
|
24500
|
+
onRowClick,
|
|
24501
|
+
emptyStateImage,
|
|
24502
|
+
noSearchImage,
|
|
24503
|
+
mapSubjectNameToEnum,
|
|
24504
|
+
userFilterData
|
|
24505
|
+
}) => {
|
|
24506
|
+
const fetchActivitiesHistoryRef = (0, import_react82.useRef)(fetchActivitiesHistory);
|
|
24507
|
+
fetchActivitiesHistoryRef.current = fetchActivitiesHistory;
|
|
24508
|
+
const useActivitiesHistory = (0, import_react82.useMemo)(
|
|
24509
|
+
() => createUseActivitiesHistory(
|
|
24510
|
+
(filters) => fetchActivitiesHistoryRef.current(filters)
|
|
24511
|
+
),
|
|
24512
|
+
[]
|
|
24513
|
+
);
|
|
24514
|
+
const {
|
|
24515
|
+
activities,
|
|
24516
|
+
loading,
|
|
24517
|
+
error,
|
|
24518
|
+
pagination,
|
|
24519
|
+
fetchActivities
|
|
24520
|
+
} = useActivitiesHistory();
|
|
24521
|
+
const historyFilterConfigs = (0, import_react82.useMemo)(
|
|
24522
|
+
() => createHistoryFiltersConfig(userFilterData),
|
|
24523
|
+
[userFilterData]
|
|
24524
|
+
);
|
|
24525
|
+
const historyTableColumns = (0, import_react82.useMemo)(
|
|
24526
|
+
() => createHistoryTableColumns(mapSubjectNameToEnum),
|
|
24527
|
+
[mapSubjectNameToEnum]
|
|
24528
|
+
);
|
|
24529
|
+
const handleParamsChange = (0, import_react82.useCallback)(
|
|
24530
|
+
(params) => {
|
|
24531
|
+
const filters = buildHistoryFiltersFromParams(params);
|
|
24532
|
+
fetchActivities(filters);
|
|
24533
|
+
},
|
|
24534
|
+
[fetchActivities]
|
|
24535
|
+
);
|
|
24536
|
+
if (error) {
|
|
24537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(ErrorDisplay, { error });
|
|
24538
|
+
}
|
|
24539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
24540
|
+
TableProvider,
|
|
24541
|
+
{
|
|
24542
|
+
data: activities,
|
|
24543
|
+
headers: historyTableColumns,
|
|
24544
|
+
loading,
|
|
24545
|
+
variant: "borderless",
|
|
24546
|
+
enableSearch: true,
|
|
24547
|
+
enableFilters: true,
|
|
24548
|
+
enableTableSort: true,
|
|
24549
|
+
enablePagination: true,
|
|
24550
|
+
enableRowClick: true,
|
|
24551
|
+
initialFilters: historyFilterConfigs,
|
|
24552
|
+
paginationConfig: {
|
|
24553
|
+
itemLabel: "atividades",
|
|
24554
|
+
itemsPerPageOptions: [10, 20, 50, 100],
|
|
24555
|
+
defaultItemsPerPage: 10,
|
|
24556
|
+
totalItems: pagination.total,
|
|
24557
|
+
totalPages: pagination.totalPages
|
|
24558
|
+
},
|
|
24559
|
+
searchPlaceholder: "Buscar atividade",
|
|
24560
|
+
noSearchResultState: {
|
|
24561
|
+
image: noSearchImage
|
|
24562
|
+
},
|
|
24563
|
+
emptyState: {
|
|
24564
|
+
component: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
24565
|
+
EmptyState_default,
|
|
24566
|
+
{
|
|
24567
|
+
image: emptyStateImage,
|
|
24568
|
+
title: "Incentive sua turma ao aprendizado",
|
|
24569
|
+
description: "Crie uma nova atividade e ajude seus alunos a colocarem o conte\xFAdo em pr\xE1tica!",
|
|
24570
|
+
buttonText: "Criar atividade",
|
|
24571
|
+
buttonIcon: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_phosphor_react46.Plus, { size: 18 }),
|
|
24572
|
+
buttonVariant: "outline",
|
|
24573
|
+
buttonAction: "primary",
|
|
24574
|
+
onButtonClick: onCreateActivity
|
|
24575
|
+
}
|
|
24576
|
+
)
|
|
24577
|
+
},
|
|
24578
|
+
onParamsChange: handleParamsChange,
|
|
24579
|
+
onRowClick,
|
|
24580
|
+
children: (renderProps) => {
|
|
24581
|
+
const {
|
|
24582
|
+
controls,
|
|
24583
|
+
table,
|
|
24584
|
+
pagination: paginationComponent
|
|
24585
|
+
} = renderProps;
|
|
24586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: "space-y-4", children: [
|
|
24587
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
24588
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
24589
|
+
Button_default,
|
|
24590
|
+
{
|
|
24591
|
+
variant: "solid",
|
|
24592
|
+
action: "primary",
|
|
24593
|
+
size: "medium",
|
|
24594
|
+
onClick: onCreateActivity,
|
|
24595
|
+
iconLeft: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_phosphor_react46.Plus, { size: 18, weight: "bold" }),
|
|
24596
|
+
children: "Criar atividade"
|
|
24597
|
+
}
|
|
24598
|
+
),
|
|
24599
|
+
controls
|
|
24600
|
+
] }),
|
|
24601
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: "bg-background rounded-xl p-6 space-y-4", children: [
|
|
24602
|
+
table,
|
|
24603
|
+
paginationComponent
|
|
24604
|
+
] })
|
|
24605
|
+
] });
|
|
24606
|
+
}
|
|
24607
|
+
}
|
|
24608
|
+
) });
|
|
24609
|
+
};
|
|
24610
|
+
|
|
24611
|
+
// src/components/ActivitiesHistory/tabs/ModelsTab.tsx
|
|
24612
|
+
var import_react84 = require("react");
|
|
24613
|
+
var import_phosphor_react48 = require("phosphor-react");
|
|
24614
|
+
|
|
24615
|
+
// src/components/ActivitiesHistory/config/modelsTableColumns.tsx
|
|
24616
|
+
var import_phosphor_react47 = require("phosphor-react");
|
|
24617
|
+
var import_jsx_runtime100 = require("react/jsx-runtime");
|
|
24618
|
+
var createModelsTableColumns = (mapSubjectNameToEnum, onSendActivity, onEditModel, onDeleteModel) => [
|
|
24619
|
+
{
|
|
24620
|
+
key: "title",
|
|
24621
|
+
label: "T\xEDtulo",
|
|
24622
|
+
sortable: true,
|
|
24623
|
+
className: "max-w-[400px]",
|
|
24624
|
+
render: (value) => {
|
|
24625
|
+
const title = typeof value === "string" ? value : "";
|
|
24626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(Text_default, { size: "sm", title, className: "truncate block", children: title });
|
|
24627
|
+
}
|
|
24628
|
+
},
|
|
24629
|
+
{
|
|
24630
|
+
key: "savedAt",
|
|
24631
|
+
label: "Salvo em",
|
|
24632
|
+
sortable: true,
|
|
24633
|
+
className: "w-[120px]"
|
|
24634
|
+
},
|
|
24635
|
+
{
|
|
24636
|
+
key: "subject",
|
|
24637
|
+
label: "Mat\xE9ria",
|
|
24638
|
+
sortable: true,
|
|
24639
|
+
className: "max-w-[160px]",
|
|
24640
|
+
render: (value) => {
|
|
24641
|
+
const subjectName = typeof value === "string" ? value : "";
|
|
24642
|
+
return renderSubjectCell(subjectName, mapSubjectNameToEnum, true);
|
|
24643
|
+
}
|
|
24644
|
+
},
|
|
24645
|
+
{
|
|
24646
|
+
key: "actions",
|
|
24647
|
+
label: "",
|
|
24648
|
+
sortable: false,
|
|
24649
|
+
className: "w-[220px]",
|
|
24650
|
+
render: (_value, row) => {
|
|
24651
|
+
const handleSend = (e) => {
|
|
24652
|
+
e.stopPropagation();
|
|
24653
|
+
onSendActivity?.(row);
|
|
24654
|
+
};
|
|
24655
|
+
const handleEdit = (e) => {
|
|
24656
|
+
e.stopPropagation();
|
|
24657
|
+
onEditModel?.(row);
|
|
24658
|
+
};
|
|
24659
|
+
const handleDelete = (e) => {
|
|
24660
|
+
e.stopPropagation();
|
|
24661
|
+
onDeleteModel(row);
|
|
24662
|
+
};
|
|
24663
|
+
return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("div", { className: "flex items-center gap-2 justify-end", children: [
|
|
24664
|
+
onSendActivity && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
|
|
24665
|
+
Button_default,
|
|
24666
|
+
{
|
|
24667
|
+
variant: "outline",
|
|
24668
|
+
action: "primary",
|
|
24669
|
+
size: "small",
|
|
24670
|
+
iconLeft: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_phosphor_react47.PaperPlaneTilt, { size: 16 }),
|
|
24671
|
+
onClick: handleSend,
|
|
24672
|
+
"aria-label": "Enviar atividade",
|
|
24673
|
+
children: "Enviar atividade"
|
|
24674
|
+
}
|
|
24675
|
+
),
|
|
24676
|
+
/* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
|
|
24677
|
+
IconButton_default,
|
|
24678
|
+
{
|
|
24679
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_phosphor_react47.Trash, { size: 20 }),
|
|
24680
|
+
size: "md",
|
|
24681
|
+
onClick: handleDelete,
|
|
24682
|
+
"aria-label": "Deletar modelo",
|
|
24683
|
+
className: "text-text-600 hover:text-error-500 hover:bg-transparent"
|
|
24684
|
+
}
|
|
24685
|
+
),
|
|
24686
|
+
onEditModel && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
|
|
24687
|
+
IconButton_default,
|
|
24688
|
+
{
|
|
24689
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_phosphor_react47.PencilSimple, { size: 20 }),
|
|
24690
|
+
size: "md",
|
|
24691
|
+
onClick: handleEdit,
|
|
24692
|
+
"aria-label": "Editar modelo",
|
|
24693
|
+
className: "text-text-600 hover:text-primary-700 hover:bg-transparent"
|
|
24694
|
+
}
|
|
24695
|
+
)
|
|
24696
|
+
] });
|
|
24697
|
+
}
|
|
24698
|
+
}
|
|
24699
|
+
];
|
|
24700
|
+
|
|
24701
|
+
// src/components/ActivitiesHistory/config/modelsFiltersConfig.ts
|
|
24702
|
+
var createModelsFiltersConfig = (userData) => [
|
|
24703
|
+
{
|
|
24704
|
+
key: "content",
|
|
24705
|
+
label: "CONTE\xDADO",
|
|
24706
|
+
categories: [
|
|
24707
|
+
{
|
|
24708
|
+
key: "subject",
|
|
24709
|
+
label: "Mat\xE9ria",
|
|
24710
|
+
selectedIds: [],
|
|
24711
|
+
itens: getSubjectOptions2(userData)
|
|
24712
|
+
}
|
|
24713
|
+
]
|
|
24714
|
+
}
|
|
24715
|
+
];
|
|
24716
|
+
|
|
24717
|
+
// src/hooks/useActivityModels.ts
|
|
24718
|
+
var import_react83 = require("react");
|
|
24719
|
+
var import_zod8 = require("zod");
|
|
24720
|
+
var import_dayjs5 = __toESM(require("dayjs"));
|
|
24721
|
+
var activityDraftFiltersSchema = import_zod8.z.object({
|
|
24722
|
+
questionTypes: import_zod8.z.array(import_zod8.z.string()).optional(),
|
|
24723
|
+
questionBanks: import_zod8.z.array(import_zod8.z.string()).optional(),
|
|
24724
|
+
subjects: import_zod8.z.array(import_zod8.z.string()).optional(),
|
|
24725
|
+
topics: import_zod8.z.array(import_zod8.z.string()).optional(),
|
|
24726
|
+
subtopics: import_zod8.z.array(import_zod8.z.string()).optional(),
|
|
24727
|
+
contents: import_zod8.z.array(import_zod8.z.string()).optional()
|
|
24728
|
+
}).nullable();
|
|
24729
|
+
var activityModelResponseSchema = import_zod8.z.object({
|
|
24730
|
+
id: import_zod8.z.string().uuid(),
|
|
24731
|
+
type: import_zod8.z.nativeEnum(ActivityDraftType),
|
|
24732
|
+
title: import_zod8.z.string().nullable(),
|
|
24733
|
+
creatorUserInstitutionId: import_zod8.z.string().uuid().nullable(),
|
|
24734
|
+
subjectId: import_zod8.z.string().uuid().nullable(),
|
|
24735
|
+
filters: activityDraftFiltersSchema,
|
|
24736
|
+
createdAt: import_zod8.z.string(),
|
|
24737
|
+
updatedAt: import_zod8.z.string()
|
|
24738
|
+
});
|
|
24739
|
+
var activityModelsApiResponseSchema = import_zod8.z.object({
|
|
24740
|
+
message: import_zod8.z.string(),
|
|
24741
|
+
data: import_zod8.z.object({
|
|
24742
|
+
activityDrafts: import_zod8.z.array(activityModelResponseSchema),
|
|
24743
|
+
total: import_zod8.z.number()
|
|
24744
|
+
})
|
|
24745
|
+
});
|
|
24746
|
+
var DEFAULT_MODELS_PAGINATION = {
|
|
24747
|
+
total: 0,
|
|
24748
|
+
page: 1,
|
|
24749
|
+
limit: 10,
|
|
24750
|
+
totalPages: 0
|
|
24751
|
+
};
|
|
24752
|
+
var transformModelToTableItem = (model, subjectsMap) => {
|
|
24753
|
+
const subjectName = model.subjectId ? subjectsMap?.get(model.subjectId) || "" : "";
|
|
24754
|
+
return {
|
|
24755
|
+
id: model.id,
|
|
24756
|
+
title: model.title || "Sem t\xEDtulo",
|
|
24757
|
+
savedAt: (0, import_dayjs5.default)(model.createdAt).format("DD/MM/YYYY"),
|
|
24758
|
+
subject: subjectName,
|
|
24759
|
+
subjectId: model.subjectId
|
|
24760
|
+
};
|
|
24761
|
+
};
|
|
24762
|
+
var handleModelFetchError = createFetchErrorHandler(
|
|
24763
|
+
"Erro ao validar dados de modelos de atividades",
|
|
24764
|
+
"Erro ao carregar modelos de atividades"
|
|
24765
|
+
);
|
|
24766
|
+
var createUseActivityModels = (fetchActivityModels, deleteActivityModel) => {
|
|
24767
|
+
return () => {
|
|
24768
|
+
const [state, setState] = (0, import_react83.useState)({
|
|
24769
|
+
models: [],
|
|
24770
|
+
loading: false,
|
|
24771
|
+
error: null,
|
|
24772
|
+
pagination: DEFAULT_MODELS_PAGINATION
|
|
24773
|
+
});
|
|
24774
|
+
const fetchModels = (0, import_react83.useCallback)(
|
|
24775
|
+
async (filters, subjectsMap) => {
|
|
24776
|
+
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
24777
|
+
try {
|
|
24778
|
+
const responseData = await fetchActivityModels(filters);
|
|
24779
|
+
const validatedData = activityModelsApiResponseSchema.parse(responseData);
|
|
24780
|
+
const tableItems = validatedData.data.activityDrafts.map(
|
|
24781
|
+
(model) => transformModelToTableItem(model, subjectsMap)
|
|
24782
|
+
);
|
|
24783
|
+
const limit = filters?.limit || 10;
|
|
24784
|
+
const page = filters?.page || 1;
|
|
24785
|
+
const total = validatedData.data.total;
|
|
24786
|
+
const totalPages = Math.ceil(total / limit);
|
|
24787
|
+
setState({
|
|
24788
|
+
models: tableItems,
|
|
24789
|
+
loading: false,
|
|
24790
|
+
error: null,
|
|
24791
|
+
pagination: {
|
|
24792
|
+
total,
|
|
24793
|
+
page,
|
|
24794
|
+
limit,
|
|
24795
|
+
totalPages
|
|
24796
|
+
}
|
|
24797
|
+
});
|
|
24798
|
+
} catch (error) {
|
|
24799
|
+
const errorMessage = handleModelFetchError(error);
|
|
24800
|
+
setState((prev) => ({
|
|
24801
|
+
...prev,
|
|
24802
|
+
loading: false,
|
|
24803
|
+
error: errorMessage
|
|
24804
|
+
}));
|
|
24805
|
+
}
|
|
24806
|
+
},
|
|
24807
|
+
[fetchActivityModels]
|
|
24808
|
+
);
|
|
24809
|
+
const deleteModel = (0, import_react83.useCallback)(
|
|
24810
|
+
async (id) => {
|
|
24811
|
+
try {
|
|
24812
|
+
await deleteActivityModel(id);
|
|
24813
|
+
return true;
|
|
24814
|
+
} catch (error) {
|
|
24815
|
+
console.error("Erro ao deletar modelo:", error);
|
|
24816
|
+
return false;
|
|
24817
|
+
}
|
|
24818
|
+
},
|
|
24819
|
+
[deleteActivityModel]
|
|
24820
|
+
);
|
|
24821
|
+
return {
|
|
24822
|
+
...state,
|
|
24823
|
+
fetchModels,
|
|
24824
|
+
deleteModel
|
|
24825
|
+
};
|
|
24826
|
+
};
|
|
24827
|
+
};
|
|
24828
|
+
var createActivityModelsHook = createUseActivityModels;
|
|
24829
|
+
|
|
24830
|
+
// src/components/ActivitiesHistory/tabs/ModelsTab.tsx
|
|
24831
|
+
var import_jsx_runtime101 = require("react/jsx-runtime");
|
|
24832
|
+
var ModelsTab = ({
|
|
24833
|
+
fetchActivityModels,
|
|
24834
|
+
deleteActivityModel,
|
|
24835
|
+
onCreateModel,
|
|
24836
|
+
onSendActivity,
|
|
24837
|
+
onEditModel,
|
|
24838
|
+
emptyStateImage,
|
|
24839
|
+
noSearchImage,
|
|
24840
|
+
mapSubjectNameToEnum,
|
|
24841
|
+
userFilterData,
|
|
24842
|
+
subjectsMap
|
|
24843
|
+
}) => {
|
|
24844
|
+
const [deleteDialogOpen, setDeleteDialogOpen] = (0, import_react84.useState)(false);
|
|
24845
|
+
const [modelToDelete, setModelToDelete] = (0, import_react84.useState)(null);
|
|
24846
|
+
const { addToast } = useToast();
|
|
24847
|
+
const fetchActivityModelsRef = (0, import_react84.useRef)(fetchActivityModels);
|
|
24848
|
+
fetchActivityModelsRef.current = fetchActivityModels;
|
|
24849
|
+
const deleteActivityModelRef = (0, import_react84.useRef)(deleteActivityModel);
|
|
24850
|
+
deleteActivityModelRef.current = deleteActivityModel;
|
|
24851
|
+
const subjectsMapRef = (0, import_react84.useRef)(subjectsMap);
|
|
24852
|
+
subjectsMapRef.current = subjectsMap;
|
|
24853
|
+
const useActivityModels = (0, import_react84.useMemo)(
|
|
24854
|
+
() => createUseActivityModels(
|
|
24855
|
+
(filters) => fetchActivityModelsRef.current(filters),
|
|
24856
|
+
(id) => deleteActivityModelRef.current(id)
|
|
24857
|
+
),
|
|
24858
|
+
[]
|
|
24859
|
+
);
|
|
24860
|
+
const {
|
|
24861
|
+
models,
|
|
24862
|
+
loading: modelsLoading,
|
|
24863
|
+
error: modelsError,
|
|
24864
|
+
pagination: modelsPagination,
|
|
24865
|
+
fetchModels,
|
|
24866
|
+
deleteModel
|
|
24867
|
+
} = useActivityModels();
|
|
24868
|
+
const modelsFilterConfigs = (0, import_react84.useMemo)(
|
|
24869
|
+
() => createModelsFiltersConfig(userFilterData),
|
|
24870
|
+
[userFilterData]
|
|
24871
|
+
);
|
|
24872
|
+
const handleDeleteClick = (0, import_react84.useCallback)((model) => {
|
|
24873
|
+
setModelToDelete(model);
|
|
24874
|
+
setDeleteDialogOpen(true);
|
|
24875
|
+
}, []);
|
|
24876
|
+
const modelsTableColumns = (0, import_react84.useMemo)(
|
|
24877
|
+
() => createModelsTableColumns(
|
|
24878
|
+
mapSubjectNameToEnum,
|
|
24879
|
+
onSendActivity,
|
|
24880
|
+
onEditModel,
|
|
24881
|
+
handleDeleteClick
|
|
24882
|
+
),
|
|
24883
|
+
[mapSubjectNameToEnum, onSendActivity, onEditModel, handleDeleteClick]
|
|
24884
|
+
);
|
|
24885
|
+
const handleParamsChange = (0, import_react84.useCallback)(
|
|
24886
|
+
(params) => {
|
|
24887
|
+
const filters = buildModelsFiltersFromParams(params);
|
|
24888
|
+
fetchModels(filters, subjectsMapRef.current);
|
|
24889
|
+
},
|
|
24890
|
+
[fetchModels]
|
|
24891
|
+
);
|
|
24892
|
+
(0, import_react84.useEffect)(() => {
|
|
24893
|
+
fetchModels({ page: 1, limit: 10 }, subjectsMapRef.current);
|
|
24894
|
+
}, [fetchModels]);
|
|
24895
|
+
const handleConfirmDelete = (0, import_react84.useCallback)(async () => {
|
|
24896
|
+
if (modelToDelete) {
|
|
24897
|
+
const success = await deleteModel(modelToDelete.id);
|
|
24898
|
+
if (success) {
|
|
24899
|
+
addToast({ title: "Modelo deletado com sucesso", action: "success" });
|
|
24900
|
+
fetchModels({ page: 1, limit: 10 }, subjectsMapRef.current);
|
|
24901
|
+
} else {
|
|
24902
|
+
addToast({ title: "Erro ao deletar modelo", action: "warning" });
|
|
24903
|
+
}
|
|
24904
|
+
}
|
|
24905
|
+
setDeleteDialogOpen(false);
|
|
24906
|
+
setModelToDelete(null);
|
|
24907
|
+
}, [modelToDelete, deleteModel, fetchModels, addToast]);
|
|
24908
|
+
const handleCancelDelete = (0, import_react84.useCallback)(() => {
|
|
24909
|
+
setDeleteDialogOpen(false);
|
|
24910
|
+
setModelToDelete(null);
|
|
24911
|
+
}, []);
|
|
24912
|
+
return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
|
|
24913
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(Toaster_default, {}),
|
|
24914
|
+
modelsError ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(ErrorDisplay, { error: modelsError }) : /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "w-full", "data-testid": "activity-models-tab", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
24915
|
+
TableProvider,
|
|
24916
|
+
{
|
|
24917
|
+
data: models,
|
|
24918
|
+
headers: modelsTableColumns,
|
|
24919
|
+
loading: modelsLoading,
|
|
24920
|
+
variant: "borderless",
|
|
24921
|
+
enableSearch: true,
|
|
24922
|
+
enableFilters: true,
|
|
24923
|
+
enableTableSort: true,
|
|
24924
|
+
enablePagination: true,
|
|
24925
|
+
initialFilters: modelsFilterConfigs,
|
|
24926
|
+
paginationConfig: {
|
|
24927
|
+
itemLabel: "modelos",
|
|
24928
|
+
itemsPerPageOptions: [10, 20, 50, 100],
|
|
24929
|
+
defaultItemsPerPage: 10,
|
|
24930
|
+
totalItems: modelsPagination.total,
|
|
24931
|
+
totalPages: modelsPagination.totalPages
|
|
24932
|
+
},
|
|
24933
|
+
searchPlaceholder: "Buscar modelo",
|
|
24934
|
+
noSearchResultState: {
|
|
24935
|
+
image: noSearchImage
|
|
24936
|
+
},
|
|
24937
|
+
emptyState: {
|
|
24938
|
+
component: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
24939
|
+
EmptyState_default,
|
|
24940
|
+
{
|
|
24941
|
+
image: emptyStateImage,
|
|
24942
|
+
title: "Crie modelos para agilizar suas atividades",
|
|
24943
|
+
description: "Salve modelos de atividades para reutilizar e enviar rapidamente para suas turmas!",
|
|
24944
|
+
buttonText: "Criar modelo",
|
|
24945
|
+
buttonIcon: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_phosphor_react48.Plus, { size: 18 }),
|
|
24946
|
+
buttonVariant: "outline",
|
|
24947
|
+
buttonAction: "primary",
|
|
24948
|
+
onButtonClick: onCreateModel
|
|
24949
|
+
}
|
|
24950
|
+
)
|
|
24951
|
+
},
|
|
24952
|
+
onParamsChange: handleParamsChange,
|
|
24953
|
+
children: (renderProps) => {
|
|
24954
|
+
const {
|
|
24955
|
+
controls,
|
|
24956
|
+
table,
|
|
24957
|
+
pagination: paginationComponent
|
|
24958
|
+
} = renderProps;
|
|
24959
|
+
return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "space-y-4", children: [
|
|
24960
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
24961
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
24962
|
+
Button_default,
|
|
24963
|
+
{
|
|
24964
|
+
variant: "solid",
|
|
24965
|
+
action: "primary",
|
|
24966
|
+
size: "medium",
|
|
24967
|
+
onClick: onCreateModel,
|
|
24968
|
+
iconLeft: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_phosphor_react48.Plus, { size: 18, weight: "bold" }),
|
|
24969
|
+
children: "Criar modelo"
|
|
24970
|
+
}
|
|
24971
|
+
),
|
|
24972
|
+
controls
|
|
24973
|
+
] }),
|
|
24974
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "bg-background rounded-xl p-6 space-y-4", children: [
|
|
24975
|
+
table,
|
|
24976
|
+
paginationComponent
|
|
24977
|
+
] })
|
|
24978
|
+
] });
|
|
24979
|
+
}
|
|
24980
|
+
}
|
|
24981
|
+
) }),
|
|
24982
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
24983
|
+
AlertDialog,
|
|
24984
|
+
{
|
|
24985
|
+
isOpen: deleteDialogOpen,
|
|
24986
|
+
onChangeOpen: setDeleteDialogOpen,
|
|
24987
|
+
title: "Deletar modelo",
|
|
24988
|
+
description: `Tem certeza que deseja deletar o modelo "${modelToDelete?.title}"? Esta a\xE7\xE3o n\xE3o pode ser desfeita.`,
|
|
24989
|
+
submitButtonLabel: "Deletar",
|
|
24990
|
+
cancelButtonLabel: "Cancelar",
|
|
24991
|
+
onSubmit: handleConfirmDelete,
|
|
24992
|
+
onCancel: handleCancelDelete
|
|
24993
|
+
}
|
|
24994
|
+
)
|
|
24995
|
+
] });
|
|
24996
|
+
};
|
|
24997
|
+
|
|
24998
|
+
// src/components/ActivitiesHistory/tabs/DraftsTab.tsx
|
|
24999
|
+
var import_jsx_runtime102 = require("react/jsx-runtime");
|
|
25000
|
+
var DraftsTab = () => {
|
|
25001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "flex items-center justify-center bg-background rounded-xl w-full min-h-[705px]", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(Text_default, { size: "lg", color: "text-text-600", children: "Rascunhos em desenvolvimento" }) });
|
|
25002
|
+
};
|
|
25003
|
+
|
|
25004
|
+
// src/components/ActivitiesHistory/ActivitiesHistory.tsx
|
|
25005
|
+
var import_jsx_runtime103 = require("react/jsx-runtime");
|
|
25006
|
+
var PAGE_TITLES = {
|
|
25007
|
+
["history" /* HISTORY */]: "Hist\xF3rico de atividades",
|
|
25008
|
+
["drafts" /* DRAFTS */]: "Rascunhos",
|
|
25009
|
+
["models" /* MODELS */]: "Modelos de atividades"
|
|
25010
|
+
};
|
|
25011
|
+
var ActivitiesHistory = ({
|
|
25012
|
+
fetchActivitiesHistory,
|
|
25013
|
+
fetchActivityModels,
|
|
25014
|
+
deleteActivityModel,
|
|
25015
|
+
onCreateActivity,
|
|
25016
|
+
onCreateModel,
|
|
25017
|
+
onRowClick,
|
|
25018
|
+
onSendActivity,
|
|
25019
|
+
onEditModel,
|
|
25020
|
+
emptyStateImage,
|
|
25021
|
+
noSearchImage,
|
|
25022
|
+
mapSubjectNameToEnum,
|
|
25023
|
+
userFilterData,
|
|
25024
|
+
subjectsMap
|
|
25025
|
+
}) => {
|
|
25026
|
+
const [activeTab, setActiveTab] = (0, import_react85.useState)("history" /* HISTORY */);
|
|
25027
|
+
return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
|
|
25028
|
+
"div",
|
|
25029
|
+
{
|
|
25030
|
+
"data-testid": "activities-history",
|
|
25031
|
+
className: "flex flex-col w-full h-auto relative justify-center items-center mb-5 overflow-hidden",
|
|
25032
|
+
children: [
|
|
25033
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "absolute top-0 left-0 h-[150px] w-full z-0" }),
|
|
25034
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "flex flex-col w-full h-full max-w-[1350px] mx-auto z-10 lg:px-0 px-4 pt-4 sm:pt-0", children: [
|
|
25035
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "flex flex-col sm:flex-row w-full mb-6 items-start sm:items-center sm:justify-between gap-0 sm:gap-4", children: [
|
|
25036
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
25037
|
+
Text_default,
|
|
25038
|
+
{
|
|
25039
|
+
as: "h1",
|
|
25040
|
+
weight: "bold",
|
|
25041
|
+
className: "leading-[28px] tracking-[0.2px] text-xl lg:text-2xl",
|
|
25042
|
+
children: PAGE_TITLES[activeTab]
|
|
25043
|
+
}
|
|
25044
|
+
),
|
|
25045
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { className: "flex-shrink-0 lg:w-auto self-center sm:self-auto", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
25046
|
+
Menu,
|
|
25047
|
+
{
|
|
25048
|
+
defaultValue: "history" /* HISTORY */,
|
|
25049
|
+
value: activeTab,
|
|
25050
|
+
onValueChange: (value) => setActiveTab(value),
|
|
25051
|
+
variant: "menu2",
|
|
25052
|
+
className: "bg-transparent shadow-none px-0",
|
|
25053
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
|
|
25054
|
+
MenuContent,
|
|
25055
|
+
{
|
|
25056
|
+
variant: "menu2",
|
|
25057
|
+
className: "w-full lg:w-auto max-w-full min-w-0",
|
|
25058
|
+
children: [
|
|
25059
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
25060
|
+
MenuItem,
|
|
25061
|
+
{
|
|
25062
|
+
variant: "menu2",
|
|
25063
|
+
value: "history" /* HISTORY */,
|
|
25064
|
+
"data-testid": "menu-item-history",
|
|
25065
|
+
className: "whitespace-nowrap flex-1 lg:flex-none",
|
|
25066
|
+
children: "Hist\xF3rico"
|
|
25067
|
+
}
|
|
25068
|
+
),
|
|
25069
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
25070
|
+
MenuItem,
|
|
25071
|
+
{
|
|
25072
|
+
variant: "menu2",
|
|
25073
|
+
value: "drafts" /* DRAFTS */,
|
|
25074
|
+
"data-testid": "menu-item-drafts",
|
|
25075
|
+
className: "whitespace-nowrap flex-1 lg:flex-none",
|
|
25076
|
+
children: "Rascunhos"
|
|
25077
|
+
}
|
|
25078
|
+
),
|
|
25079
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
25080
|
+
MenuItem,
|
|
25081
|
+
{
|
|
25082
|
+
variant: "menu2",
|
|
25083
|
+
value: "models" /* MODELS */,
|
|
25084
|
+
"data-testid": "menu-item-models",
|
|
25085
|
+
className: "whitespace-nowrap flex-1 lg:flex-none",
|
|
25086
|
+
children: "Modelos"
|
|
25087
|
+
}
|
|
25088
|
+
)
|
|
25089
|
+
]
|
|
25090
|
+
}
|
|
25091
|
+
)
|
|
25092
|
+
}
|
|
25093
|
+
) })
|
|
25094
|
+
] }),
|
|
25095
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "flex flex-col items-center w-full min-h-0 flex-1", children: [
|
|
25096
|
+
activeTab === "history" /* HISTORY */ && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
25097
|
+
HistoryTab,
|
|
25098
|
+
{
|
|
25099
|
+
fetchActivitiesHistory,
|
|
25100
|
+
onCreateActivity,
|
|
25101
|
+
onRowClick,
|
|
25102
|
+
emptyStateImage,
|
|
25103
|
+
noSearchImage,
|
|
25104
|
+
mapSubjectNameToEnum,
|
|
25105
|
+
userFilterData
|
|
25106
|
+
}
|
|
25107
|
+
),
|
|
25108
|
+
activeTab === "drafts" /* DRAFTS */ && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(DraftsTab, {}),
|
|
25109
|
+
activeTab === "models" /* MODELS */ && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
25110
|
+
ModelsTab,
|
|
25111
|
+
{
|
|
25112
|
+
fetchActivityModels,
|
|
25113
|
+
deleteActivityModel,
|
|
25114
|
+
onCreateModel,
|
|
25115
|
+
onSendActivity,
|
|
25116
|
+
onEditModel,
|
|
25117
|
+
emptyStateImage,
|
|
25118
|
+
noSearchImage,
|
|
25119
|
+
mapSubjectNameToEnum,
|
|
25120
|
+
userFilterData,
|
|
25121
|
+
subjectsMap
|
|
25122
|
+
}
|
|
25123
|
+
)
|
|
25124
|
+
] })
|
|
25125
|
+
] })
|
|
25126
|
+
]
|
|
25127
|
+
}
|
|
25128
|
+
);
|
|
25129
|
+
};
|
|
25130
|
+
|
|
25131
|
+
// src/hooks/useChat.ts
|
|
25132
|
+
var import_react86 = require("react");
|
|
25133
|
+
var WS_STATES = {
|
|
25134
|
+
CONNECTING: 0,
|
|
25135
|
+
OPEN: 1,
|
|
25136
|
+
CLOSING: 2,
|
|
25137
|
+
CLOSED: 3
|
|
25138
|
+
};
|
|
25139
|
+
function useChat({
|
|
25140
|
+
wsUrl,
|
|
25141
|
+
token,
|
|
25142
|
+
roomId,
|
|
25143
|
+
userId,
|
|
25144
|
+
onConnect,
|
|
25145
|
+
onDisconnect,
|
|
25146
|
+
onError,
|
|
25147
|
+
autoReconnect = true,
|
|
25148
|
+
reconnectInterval = 3e3,
|
|
25149
|
+
maxReconnectAttempts = 5
|
|
25150
|
+
}) {
|
|
25151
|
+
const [isConnected, setIsConnected] = (0, import_react86.useState)(false);
|
|
25152
|
+
const [messages, setMessages] = (0, import_react86.useState)([]);
|
|
25153
|
+
const [participants, setParticipants] = (0, import_react86.useState)([]);
|
|
25154
|
+
const [error, setError] = (0, import_react86.useState)(null);
|
|
25155
|
+
const wsRef = (0, import_react86.useRef)(null);
|
|
25156
|
+
const reconnectAttemptsRef = (0, import_react86.useRef)(0);
|
|
25157
|
+
const reconnectTimeoutRef = (0, import_react86.useRef)(
|
|
25158
|
+
null
|
|
25159
|
+
);
|
|
25160
|
+
const isManualDisconnectRef = (0, import_react86.useRef)(false);
|
|
25161
|
+
const sendWsMessage = (0, import_react86.useCallback)((message) => {
|
|
25162
|
+
if (wsRef.current?.readyState === WS_STATES.OPEN) {
|
|
25163
|
+
wsRef.current.send(JSON.stringify(message));
|
|
25164
|
+
}
|
|
25165
|
+
}, []);
|
|
25166
|
+
const sendMessage = (0, import_react86.useCallback)(
|
|
25167
|
+
(content) => {
|
|
25168
|
+
const trimmedContent = content.trim();
|
|
25169
|
+
if (!trimmedContent) return;
|
|
25170
|
+
sendWsMessage({
|
|
25171
|
+
type: "message",
|
|
25172
|
+
payload: { content: trimmedContent }
|
|
25173
|
+
});
|
|
25174
|
+
},
|
|
25175
|
+
[sendWsMessage]
|
|
25176
|
+
);
|
|
25177
|
+
const leave = (0, import_react86.useCallback)(() => {
|
|
25178
|
+
isManualDisconnectRef.current = true;
|
|
25179
|
+
sendWsMessage({ type: "leave" });
|
|
25180
|
+
wsRef.current?.close(1e3, "User left");
|
|
25181
|
+
}, [sendWsMessage]);
|
|
25182
|
+
const handleMessage = (0, import_react86.useCallback)(
|
|
25183
|
+
(event) => {
|
|
25184
|
+
try {
|
|
25185
|
+
const data = JSON.parse(event.data);
|
|
25186
|
+
switch (data.type) {
|
|
25187
|
+
case "history":
|
|
25188
|
+
if (data.payload.messages) {
|
|
25189
|
+
setMessages(data.payload.messages);
|
|
25190
|
+
}
|
|
25191
|
+
break;
|
|
25192
|
+
case "participants":
|
|
25193
|
+
if (data.payload.participants) {
|
|
25194
|
+
setParticipants(data.payload.participants);
|
|
25195
|
+
}
|
|
25196
|
+
break;
|
|
25197
|
+
case "new_message":
|
|
25198
|
+
if (data.payload.message) {
|
|
25199
|
+
setMessages((prev) => [...prev, data.payload.message]);
|
|
25200
|
+
}
|
|
25201
|
+
break;
|
|
25202
|
+
case "user_joined":
|
|
25203
|
+
if (data.payload.user) {
|
|
25204
|
+
const user = data.payload.user;
|
|
25205
|
+
setParticipants((prev) => {
|
|
25206
|
+
const exists = prev.some(
|
|
25207
|
+
(p) => p.userInstitutionId === user.userInstitutionId
|
|
25208
|
+
);
|
|
25209
|
+
if (exists) {
|
|
25210
|
+
return prev.map(
|
|
25211
|
+
(p) => p.userInstitutionId === user.userInstitutionId ? { ...p, isOnline: true } : p
|
|
25212
|
+
);
|
|
25213
|
+
}
|
|
25214
|
+
return [
|
|
25215
|
+
...prev,
|
|
25216
|
+
{
|
|
25217
|
+
userInstitutionId: user.userInstitutionId,
|
|
25218
|
+
name: user.name,
|
|
25219
|
+
photo: user.photo,
|
|
25220
|
+
role: user.role,
|
|
25221
|
+
isOnline: true
|
|
25222
|
+
}
|
|
25223
|
+
];
|
|
25224
|
+
});
|
|
25225
|
+
}
|
|
25226
|
+
break;
|
|
25227
|
+
case "user_left":
|
|
25228
|
+
if (data.payload.user) {
|
|
25229
|
+
const user = data.payload.user;
|
|
25230
|
+
setParticipants(
|
|
25231
|
+
(prev) => prev.map(
|
|
25232
|
+
(p) => p.userInstitutionId === user.userInstitutionId ? { ...p, isOnline: false } : p
|
|
25233
|
+
)
|
|
25234
|
+
);
|
|
25235
|
+
}
|
|
25236
|
+
break;
|
|
25237
|
+
case "error": {
|
|
25238
|
+
const errorMessage = data.payload.message_text || "Erro desconhecido";
|
|
25239
|
+
setError(new Error(errorMessage));
|
|
25240
|
+
onError?.(new Error(errorMessage));
|
|
25241
|
+
break;
|
|
25242
|
+
}
|
|
25243
|
+
}
|
|
25244
|
+
} catch (err) {
|
|
25245
|
+
console.error("Error parsing WebSocket message:", err);
|
|
25246
|
+
}
|
|
25247
|
+
},
|
|
25248
|
+
[onError]
|
|
25249
|
+
);
|
|
25250
|
+
const connect = (0, import_react86.useCallback)(() => {
|
|
25251
|
+
const url = new URL(wsUrl);
|
|
25252
|
+
url.searchParams.set("roomId", roomId);
|
|
25253
|
+
url.searchParams.set("token", token);
|
|
25254
|
+
if (wsRef.current) {
|
|
25255
|
+
wsRef.current.close();
|
|
25256
|
+
}
|
|
25257
|
+
const ws = new WebSocket(url.toString());
|
|
25258
|
+
wsRef.current = ws;
|
|
25259
|
+
ws.onopen = () => {
|
|
25260
|
+
setIsConnected(true);
|
|
25261
|
+
setError(null);
|
|
25262
|
+
reconnectAttemptsRef.current = 0;
|
|
25263
|
+
onConnect?.();
|
|
25264
|
+
};
|
|
25265
|
+
ws.onmessage = handleMessage;
|
|
25266
|
+
ws.onerror = () => {
|
|
25267
|
+
const error2 = new Error("Erro na conex\xE3o WebSocket");
|
|
25268
|
+
setError(error2);
|
|
25269
|
+
onError?.(error2);
|
|
25270
|
+
};
|
|
25271
|
+
ws.onclose = (event) => {
|
|
25272
|
+
setIsConnected(false);
|
|
25273
|
+
onDisconnect?.();
|
|
25274
|
+
if (autoReconnect && !isManualDisconnectRef.current && reconnectAttemptsRef.current < maxReconnectAttempts && event.code !== 4001 && // Unauthorized
|
|
25275
|
+
event.code !== 4002 && // Missing roomId
|
|
25276
|
+
event.code !== 4003) {
|
|
25277
|
+
reconnectAttemptsRef.current += 1;
|
|
25278
|
+
reconnectTimeoutRef.current = setTimeout(() => {
|
|
25279
|
+
connect();
|
|
25280
|
+
}, reconnectInterval);
|
|
25281
|
+
}
|
|
25282
|
+
};
|
|
25283
|
+
}, [
|
|
25284
|
+
wsUrl,
|
|
25285
|
+
roomId,
|
|
25286
|
+
token,
|
|
25287
|
+
handleMessage,
|
|
25288
|
+
onConnect,
|
|
25289
|
+
onDisconnect,
|
|
25290
|
+
onError,
|
|
25291
|
+
autoReconnect,
|
|
25292
|
+
reconnectInterval,
|
|
25293
|
+
maxReconnectAttempts
|
|
25294
|
+
]);
|
|
25295
|
+
const reconnect = (0, import_react86.useCallback)(() => {
|
|
25296
|
+
isManualDisconnectRef.current = false;
|
|
25297
|
+
reconnectAttemptsRef.current = 0;
|
|
25298
|
+
connect();
|
|
25299
|
+
}, [connect]);
|
|
25300
|
+
(0, import_react86.useEffect)(() => {
|
|
25301
|
+
isManualDisconnectRef.current = false;
|
|
25302
|
+
connect();
|
|
25303
|
+
return () => {
|
|
25304
|
+
isManualDisconnectRef.current = true;
|
|
25305
|
+
if (reconnectTimeoutRef.current) {
|
|
25306
|
+
clearTimeout(reconnectTimeoutRef.current);
|
|
25307
|
+
}
|
|
25308
|
+
wsRef.current?.close(1e3, "Component unmounted");
|
|
25309
|
+
};
|
|
25310
|
+
}, [connect]);
|
|
25311
|
+
return {
|
|
25312
|
+
isConnected,
|
|
25313
|
+
messages,
|
|
25314
|
+
participants,
|
|
25315
|
+
sendMessage,
|
|
25316
|
+
leave,
|
|
25317
|
+
error,
|
|
25318
|
+
reconnect,
|
|
25319
|
+
currentUserId: userId
|
|
25320
|
+
};
|
|
25321
|
+
}
|
|
25322
|
+
function createUseChat(baseWsUrl) {
|
|
25323
|
+
return (options) => useChat({ ...options, wsUrl: baseWsUrl });
|
|
25324
|
+
}
|
|
25325
|
+
|
|
25326
|
+
// src/hooks/useChatRooms.ts
|
|
25327
|
+
var import_react87 = require("react");
|
|
25328
|
+
function useChatRooms({
|
|
25329
|
+
apiClient
|
|
25330
|
+
}) {
|
|
25331
|
+
const [rooms, setRooms] = (0, import_react87.useState)([]);
|
|
25332
|
+
const [availableUsers, setAvailableUsers] = (0, import_react87.useState)([]);
|
|
25333
|
+
const [loading, setLoading] = (0, import_react87.useState)(false);
|
|
25334
|
+
const [error, setError] = (0, import_react87.useState)(null);
|
|
25335
|
+
const fetchRooms = (0, import_react87.useCallback)(async () => {
|
|
25336
|
+
setLoading(true);
|
|
25337
|
+
setError(null);
|
|
25338
|
+
try {
|
|
25339
|
+
const response = await apiClient.get("/chat/rooms");
|
|
25340
|
+
setRooms(response.data.rooms);
|
|
25341
|
+
} catch (err) {
|
|
25342
|
+
const error2 = err instanceof Error ? err : new Error("Erro ao carregar salas");
|
|
25343
|
+
setError(error2);
|
|
25344
|
+
console.error("Error fetching chat rooms:", err);
|
|
25345
|
+
} finally {
|
|
25346
|
+
setLoading(false);
|
|
25347
|
+
}
|
|
25348
|
+
}, [apiClient]);
|
|
25349
|
+
const fetchAvailableUsers = (0, import_react87.useCallback)(async () => {
|
|
25350
|
+
setLoading(true);
|
|
25351
|
+
setError(null);
|
|
25352
|
+
try {
|
|
25353
|
+
const response = await apiClient.get(
|
|
25354
|
+
"/chat/available-users"
|
|
25355
|
+
);
|
|
25356
|
+
setAvailableUsers(response.data.users);
|
|
25357
|
+
} catch (err) {
|
|
25358
|
+
const error2 = err instanceof Error ? err : new Error("Erro ao carregar usu\xE1rios");
|
|
25359
|
+
setError(error2);
|
|
25360
|
+
console.error("Error fetching available users:", err);
|
|
25361
|
+
} finally {
|
|
25362
|
+
setLoading(false);
|
|
25363
|
+
}
|
|
25364
|
+
}, [apiClient]);
|
|
25365
|
+
const createRoom = (0, import_react87.useCallback)(
|
|
25366
|
+
async (participantIds) => {
|
|
25367
|
+
setLoading(true);
|
|
25368
|
+
setError(null);
|
|
25369
|
+
try {
|
|
25370
|
+
const response = await apiClient.post(
|
|
25371
|
+
"/chat/rooms",
|
|
25372
|
+
{
|
|
25373
|
+
participantIds
|
|
25374
|
+
}
|
|
25375
|
+
);
|
|
25376
|
+
await fetchRooms();
|
|
25377
|
+
return response.data.room;
|
|
25378
|
+
} catch (err) {
|
|
25379
|
+
const error2 = err instanceof Error ? err : new Error("Erro ao criar sala");
|
|
25380
|
+
setError(error2);
|
|
25381
|
+
console.error("Error creating chat room:", err);
|
|
25382
|
+
return null;
|
|
25383
|
+
} finally {
|
|
25384
|
+
setLoading(false);
|
|
25385
|
+
}
|
|
25386
|
+
},
|
|
25387
|
+
[apiClient, fetchRooms]
|
|
25388
|
+
);
|
|
25389
|
+
const clearError = (0, import_react87.useCallback)(() => {
|
|
25390
|
+
setError(null);
|
|
25391
|
+
}, []);
|
|
25392
|
+
return {
|
|
25393
|
+
rooms,
|
|
25394
|
+
availableUsers,
|
|
25395
|
+
loading,
|
|
25396
|
+
error,
|
|
25397
|
+
fetchRooms,
|
|
25398
|
+
fetchAvailableUsers,
|
|
25399
|
+
createRoom,
|
|
25400
|
+
clearError
|
|
25401
|
+
};
|
|
25402
|
+
}
|
|
25403
|
+
function createUseChatRooms(apiClient) {
|
|
25404
|
+
return () => useChatRooms({ apiClient });
|
|
25405
|
+
}
|
|
25406
|
+
|
|
25407
|
+
// src/types/chat.ts
|
|
25408
|
+
var PROFILE_ROLES = /* @__PURE__ */ ((PROFILE_ROLES2) => {
|
|
25409
|
+
PROFILE_ROLES2["SUPER_ADMIN"] = "SUPER_ADMIN";
|
|
25410
|
+
PROFILE_ROLES2["GENERAL_MANAGER"] = "GENERAL_MANAGER";
|
|
25411
|
+
PROFILE_ROLES2["REGIONAL_MANAGER"] = "REGIONAL_MANAGER";
|
|
25412
|
+
PROFILE_ROLES2["UNIT_MANAGER"] = "UNIT_MANAGER";
|
|
25413
|
+
PROFILE_ROLES2["TEACHER"] = "TEACHER";
|
|
25414
|
+
PROFILE_ROLES2["STUDENT"] = "STUDENT";
|
|
25415
|
+
return PROFILE_ROLES2;
|
|
25416
|
+
})(PROFILE_ROLES || {});
|
|
25417
|
+
var CHAT_MESSAGE_TYPES = {
|
|
25418
|
+
TEXT: "text",
|
|
25419
|
+
SYSTEM: "system"
|
|
25420
|
+
};
|
|
25421
|
+
|
|
25422
|
+
// src/components/Chat/Chat.tsx
|
|
25423
|
+
var import_react88 = require("react");
|
|
25424
|
+
var import_react89 = require("@phosphor-icons/react");
|
|
25425
|
+
var import_jsx_runtime104 = require("react/jsx-runtime");
|
|
25426
|
+
var RoomItem = ({
|
|
25427
|
+
room,
|
|
25428
|
+
onClick,
|
|
25429
|
+
isActive
|
|
25430
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25431
|
+
Button_default,
|
|
25432
|
+
{
|
|
25433
|
+
variant: "link",
|
|
25434
|
+
onClick,
|
|
25435
|
+
className: cn(
|
|
25436
|
+
"w-full p-3 rounded-lg text-left transition-colors justify-start h-auto",
|
|
25437
|
+
"hover:bg-background-100",
|
|
25438
|
+
isActive && "bg-primary-50 border-l-4 border-primary-500"
|
|
25439
|
+
),
|
|
25440
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex items-start gap-3 w-full", children: [
|
|
25441
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "w-10 h-10 rounded-full bg-primary-100 flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_react89.UsersIcon, { size: 20, className: "text-primary-600" }) }),
|
|
25442
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
25443
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", weight: "semibold", className: "text-text-900 truncate", children: room.name }),
|
|
25444
|
+
room.lastMessage && /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(Text_default, { size: "xs", className: "text-text-500 truncate mt-1", children: [
|
|
25445
|
+
room.lastMessage.senderName,
|
|
25446
|
+
": ",
|
|
25447
|
+
room.lastMessage.content
|
|
25448
|
+
] }),
|
|
25449
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(Text_default, { size: "xs", className: "text-text-400 mt-1", children: [
|
|
25450
|
+
room.participantCount,
|
|
25451
|
+
" participantes"
|
|
25452
|
+
] })
|
|
25453
|
+
] })
|
|
25454
|
+
] })
|
|
25455
|
+
}
|
|
25456
|
+
);
|
|
25457
|
+
var MessageBubble = ({
|
|
25458
|
+
message,
|
|
25459
|
+
isOwn
|
|
25460
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: cn("flex gap-2 mb-3", isOwn && "flex-row-reverse"), children: [
|
|
25461
|
+
!isOwn && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center flex-shrink-0", children: message.senderPhoto ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25462
|
+
"img",
|
|
25463
|
+
{
|
|
25464
|
+
src: message.senderPhoto,
|
|
25465
|
+
alt: message.senderName,
|
|
25466
|
+
className: "w-8 h-8 rounded-full object-cover"
|
|
25467
|
+
}
|
|
25468
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "xs", weight: "bold", className: "text-gray-600", children: message.senderName.charAt(0).toUpperCase() }) }),
|
|
25469
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: cn("max-w-[70%]", isOwn && "items-end"), children: [
|
|
25470
|
+
!isOwn && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "xs", className: "text-text-500 mb-1", children: message.senderName }),
|
|
25471
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25472
|
+
"div",
|
|
25473
|
+
{
|
|
25474
|
+
className: cn(
|
|
25475
|
+
"px-4 py-2 rounded-2xl",
|
|
25476
|
+
isOwn ? "bg-primary-500 text-white rounded-br-md" : "bg-background-100 text-text-900 rounded-bl-md"
|
|
25477
|
+
),
|
|
25478
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", children: message.content })
|
|
25479
|
+
}
|
|
25480
|
+
),
|
|
25481
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25482
|
+
Text_default,
|
|
25483
|
+
{
|
|
25484
|
+
size: "xs",
|
|
25485
|
+
className: cn("text-text-400 mt-1", isOwn && "text-right"),
|
|
25486
|
+
children: new Date(message.createdAt).toLocaleTimeString("pt-BR", {
|
|
25487
|
+
hour: "2-digit",
|
|
25488
|
+
minute: "2-digit"
|
|
25489
|
+
})
|
|
25490
|
+
}
|
|
25491
|
+
)
|
|
25492
|
+
] })
|
|
25493
|
+
] });
|
|
25494
|
+
var ParticipantItem = ({ participant }) => /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex items-center gap-2 py-2", children: [
|
|
25495
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "relative", children: [
|
|
25496
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center", children: participant.photo ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25497
|
+
"img",
|
|
25498
|
+
{
|
|
25499
|
+
src: participant.photo,
|
|
25500
|
+
alt: participant.name,
|
|
25501
|
+
className: "w-8 h-8 rounded-full object-cover"
|
|
25502
|
+
}
|
|
25503
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "xs", weight: "bold", className: "text-gray-600", children: participant.name.charAt(0).toUpperCase() }) }),
|
|
25504
|
+
participant.isOnline && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "absolute bottom-0 right-0 w-3 h-3 bg-green-500 rounded-full border-2 border-white" })
|
|
25505
|
+
] }),
|
|
25506
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
25507
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", className: "text-text-900 truncate", children: participant.name }),
|
|
25508
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "xs", className: "text-text-500", children: participant.role })
|
|
25509
|
+
] })
|
|
25510
|
+
] });
|
|
25511
|
+
var UserSelector = ({
|
|
25512
|
+
users,
|
|
25513
|
+
selectedIds,
|
|
25514
|
+
onToggle
|
|
25515
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "space-y-2 max-h-64 overflow-y-auto", children: users.map((user) => /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
|
|
25516
|
+
Button_default,
|
|
25517
|
+
{
|
|
25518
|
+
variant: "link",
|
|
25519
|
+
onClick: () => onToggle(user.userInstitutionId),
|
|
25520
|
+
className: cn(
|
|
25521
|
+
"w-full flex items-center gap-3 p-3 rounded-lg transition-colors justify-start h-auto",
|
|
25522
|
+
selectedIds.has(user.userInstitutionId) ? "bg-primary-50 border border-primary-500" : "bg-background-50 hover:bg-background-100 border border-transparent"
|
|
25523
|
+
),
|
|
25524
|
+
children: [
|
|
25525
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center", children: user.photo ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25526
|
+
"img",
|
|
25527
|
+
{
|
|
25528
|
+
src: user.photo,
|
|
25529
|
+
alt: user.name,
|
|
25530
|
+
className: "w-10 h-10 rounded-full object-cover"
|
|
25531
|
+
}
|
|
25532
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", weight: "bold", className: "text-gray-600", children: user.name.charAt(0).toUpperCase() }) }),
|
|
25533
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex-1 text-left", children: [
|
|
25534
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", weight: "medium", className: "text-text-900", children: user.name }),
|
|
25535
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "xs", className: "text-text-500", children: user.profileName })
|
|
25536
|
+
] }),
|
|
25537
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25538
|
+
"div",
|
|
25539
|
+
{
|
|
25540
|
+
className: cn(
|
|
25541
|
+
"w-5 h-5 rounded-full border-2 flex items-center justify-center",
|
|
25542
|
+
selectedIds.has(user.userInstitutionId) ? "bg-primary-500 border-primary-500" : "border-gray-300"
|
|
25543
|
+
),
|
|
25544
|
+
children: selectedIds.has(user.userInstitutionId) && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "w-2 h-2 bg-white rounded-full" })
|
|
25545
|
+
}
|
|
25546
|
+
)
|
|
25547
|
+
]
|
|
25548
|
+
},
|
|
25549
|
+
user.userInstitutionId
|
|
25550
|
+
)) });
|
|
25551
|
+
function Chat({
|
|
25552
|
+
apiClient,
|
|
25553
|
+
wsUrl,
|
|
25554
|
+
token,
|
|
25555
|
+
userId,
|
|
25556
|
+
userName,
|
|
25557
|
+
userPhoto,
|
|
25558
|
+
userRole,
|
|
25559
|
+
className
|
|
25560
|
+
}) {
|
|
25561
|
+
const [view, setView] = (0, import_react88.useState)("list");
|
|
25562
|
+
const [selectedRoom, setSelectedRoom] = (0, import_react88.useState)(
|
|
25563
|
+
null
|
|
25564
|
+
);
|
|
25565
|
+
const [selectedUserIds, setSelectedUserIds] = (0, import_react88.useState)(
|
|
25566
|
+
/* @__PURE__ */ new Set()
|
|
25567
|
+
);
|
|
25568
|
+
const [messageInput, setMessageInput] = (0, import_react88.useState)("");
|
|
25569
|
+
const [showCreateModal, setShowCreateModal] = (0, import_react88.useState)(false);
|
|
25570
|
+
const {
|
|
25571
|
+
rooms,
|
|
25572
|
+
availableUsers,
|
|
25573
|
+
loading: roomsLoading,
|
|
25574
|
+
error: roomsError,
|
|
25575
|
+
fetchRooms,
|
|
25576
|
+
fetchAvailableUsers,
|
|
25577
|
+
createRoom
|
|
25578
|
+
} = useChatRooms({ apiClient });
|
|
25579
|
+
const {
|
|
25580
|
+
isConnected,
|
|
25581
|
+
messages,
|
|
25582
|
+
participants,
|
|
25583
|
+
sendMessage,
|
|
25584
|
+
error: chatError
|
|
25585
|
+
} = useChat({
|
|
25586
|
+
wsUrl,
|
|
25587
|
+
token,
|
|
25588
|
+
roomId: selectedRoom?.id || "",
|
|
25589
|
+
userId,
|
|
25590
|
+
onConnect: () => console.log("Connected to chat"),
|
|
25591
|
+
onDisconnect: () => console.log("Disconnected from chat"),
|
|
25592
|
+
onError: (err) => console.error("Chat error:", err)
|
|
25593
|
+
});
|
|
25594
|
+
const getRoleLabel = () => {
|
|
25595
|
+
return userRole === "TEACHER" /* TEACHER */ ? "Professor" : "Aluno";
|
|
25596
|
+
};
|
|
25597
|
+
(0, import_react88.useEffect)(() => {
|
|
25598
|
+
fetchRooms();
|
|
25599
|
+
}, [fetchRooms]);
|
|
25600
|
+
const handleSelectRoom = (0, import_react88.useCallback)((room) => {
|
|
25601
|
+
setSelectedRoom(room);
|
|
25602
|
+
setView("room");
|
|
25603
|
+
}, []);
|
|
25604
|
+
const handleOpenCreateModal = (0, import_react88.useCallback)(async () => {
|
|
25605
|
+
await fetchAvailableUsers();
|
|
25606
|
+
setSelectedUserIds(/* @__PURE__ */ new Set());
|
|
25607
|
+
setShowCreateModal(true);
|
|
25608
|
+
}, [fetchAvailableUsers]);
|
|
25609
|
+
const handleToggleUser = (0, import_react88.useCallback)((id) => {
|
|
25610
|
+
setSelectedUserIds((prev) => {
|
|
25611
|
+
const next = new Set(prev);
|
|
25612
|
+
if (next.has(id)) {
|
|
25613
|
+
next.delete(id);
|
|
25614
|
+
} else {
|
|
25615
|
+
next.add(id);
|
|
25616
|
+
}
|
|
25617
|
+
return next;
|
|
25618
|
+
});
|
|
25619
|
+
}, []);
|
|
25620
|
+
const handleCreateRoom = (0, import_react88.useCallback)(async () => {
|
|
25621
|
+
if (selectedUserIds.size === 0) return;
|
|
25622
|
+
const room = await createRoom(Array.from(selectedUserIds));
|
|
25623
|
+
if (room) {
|
|
25624
|
+
setShowCreateModal(false);
|
|
25625
|
+
setSelectedUserIds(/* @__PURE__ */ new Set());
|
|
25626
|
+
await fetchRooms();
|
|
25627
|
+
}
|
|
25628
|
+
}, [selectedUserIds, createRoom, fetchRooms]);
|
|
25629
|
+
const handleSendMessage = (0, import_react88.useCallback)(() => {
|
|
25630
|
+
if (!messageInput.trim()) return;
|
|
25631
|
+
sendMessage(messageInput);
|
|
25632
|
+
setMessageInput("");
|
|
25633
|
+
}, [messageInput, sendMessage]);
|
|
25634
|
+
const handleBackToList = (0, import_react88.useCallback)(() => {
|
|
25635
|
+
setSelectedRoom(null);
|
|
25636
|
+
setView("list");
|
|
25637
|
+
}, []);
|
|
25638
|
+
const renderMessagesContent = () => {
|
|
25639
|
+
if (chatError) {
|
|
25640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "text-center", children: [
|
|
25641
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", className: "text-red-500 mb-2", children: "Erro de conexao com o chat" }),
|
|
25642
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "xs", className: "text-text-500", children: "Tentando reconectar..." })
|
|
25643
|
+
] }) });
|
|
25644
|
+
}
|
|
25645
|
+
if (messages.length === 0) {
|
|
25646
|
+
return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", className: "text-text-500", children: "Nenhuma mensagem ainda. Comece a conversa!" }) });
|
|
25647
|
+
}
|
|
25648
|
+
return messages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25649
|
+
MessageBubble,
|
|
25650
|
+
{
|
|
25651
|
+
message,
|
|
25652
|
+
isOwn: message.senderId === userId
|
|
25653
|
+
},
|
|
25654
|
+
message.id
|
|
25655
|
+
));
|
|
25656
|
+
};
|
|
25657
|
+
const renderRoomList = () => /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex flex-col h-full", children: [
|
|
25658
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "p-4 border-b border-background-200 flex items-center justify-between", children: [
|
|
25659
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
25660
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "w-10 h-10 rounded-full bg-primary-100 flex items-center justify-center flex-shrink-0", children: userPhoto ? /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25661
|
+
"img",
|
|
25662
|
+
{
|
|
25663
|
+
src: userPhoto,
|
|
25664
|
+
alt: userName,
|
|
25665
|
+
className: "w-10 h-10 rounded-full object-cover"
|
|
25666
|
+
}
|
|
25667
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", weight: "bold", className: "text-primary-600", children: userName.charAt(0).toUpperCase() }) }),
|
|
25668
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { children: [
|
|
25669
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "lg", weight: "bold", className: "text-text-900", children: "Conversas" }),
|
|
25670
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(Text_default, { size: "xs", className: "text-text-500", children: [
|
|
25671
|
+
userName,
|
|
25672
|
+
" - ",
|
|
25673
|
+
getRoleLabel()
|
|
25674
|
+
] })
|
|
25675
|
+
] })
|
|
25676
|
+
] }),
|
|
25677
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25678
|
+
Button_default,
|
|
25679
|
+
{
|
|
25680
|
+
variant: "solid",
|
|
25681
|
+
size: "small",
|
|
25682
|
+
onClick: handleOpenCreateModal,
|
|
25683
|
+
iconLeft: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_react89.PlusIcon, { size: 16 }),
|
|
25684
|
+
children: "Nova conversa"
|
|
25685
|
+
}
|
|
25686
|
+
)
|
|
25687
|
+
] }),
|
|
25688
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex-1 overflow-y-auto p-2", children: [
|
|
25689
|
+
roomsError && /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "p-4 text-center", children: [
|
|
25690
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", className: "text-red-500 mb-2", children: "Erro ao carregar conversas" }),
|
|
25691
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Button_default, { variant: "outline", size: "small", onClick: fetchRooms, children: "Tentar novamente" })
|
|
25692
|
+
] }),
|
|
25693
|
+
!roomsError && roomsLoading && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "space-y-3 p-2", children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
25694
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SkeletonRounded, { className: "w-10 h-10" }),
|
|
25695
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex-1", children: [
|
|
25696
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SkeletonText, { className: "w-3/4 h-4 mb-2" }),
|
|
25697
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SkeletonText, { className: "w-1/2 h-3" })
|
|
25698
|
+
] })
|
|
25699
|
+
] }, i)) }),
|
|
25700
|
+
!roomsError && !roomsLoading && rooms.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25701
|
+
EmptyState_default,
|
|
25702
|
+
{
|
|
25703
|
+
title: "Nenhuma conversa",
|
|
25704
|
+
description: "Comece uma nova conversa clicando no botao acima"
|
|
25705
|
+
}
|
|
25706
|
+
),
|
|
25707
|
+
!roomsError && !roomsLoading && rooms.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "space-y-1", children: rooms.map((room) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25708
|
+
RoomItem,
|
|
25709
|
+
{
|
|
25710
|
+
room,
|
|
25711
|
+
onClick: () => handleSelectRoom(room),
|
|
25712
|
+
isActive: selectedRoom?.id === room.id
|
|
25713
|
+
},
|
|
25714
|
+
room.id
|
|
25715
|
+
)) })
|
|
25716
|
+
] })
|
|
25717
|
+
] });
|
|
25718
|
+
const renderChatRoom = () => {
|
|
25719
|
+
if (!selectedRoom) return null;
|
|
25720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex h-full", children: [
|
|
25721
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex-1 flex flex-col", children: [
|
|
25722
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "p-4 border-b border-background-200 flex items-center gap-3", children: [
|
|
25723
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Button_default, { variant: "link", size: "small", onClick: handleBackToList, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_react89.XIcon, { size: 20 }) }),
|
|
25724
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex-1", children: [
|
|
25725
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "md", weight: "semibold", className: "text-text-900", children: selectedRoom.name }),
|
|
25726
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "xs", className: "text-text-500", children: isConnected ? "Conectado" : "Conectando..." })
|
|
25727
|
+
] })
|
|
25728
|
+
] }),
|
|
25729
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "flex-1 overflow-y-auto p-4", children: renderMessagesContent() }),
|
|
25730
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "p-4 border-t border-background-200", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex gap-2", children: [
|
|
25731
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25732
|
+
Input_default,
|
|
25733
|
+
{
|
|
25734
|
+
placeholder: "Digite sua mensagem...",
|
|
25735
|
+
value: messageInput,
|
|
25736
|
+
onChange: (e) => setMessageInput(e.target.value),
|
|
25737
|
+
onKeyDown: (e) => {
|
|
25738
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
25739
|
+
e.preventDefault();
|
|
25740
|
+
handleSendMessage();
|
|
25741
|
+
}
|
|
25742
|
+
},
|
|
25743
|
+
className: "flex-1"
|
|
25744
|
+
}
|
|
25745
|
+
),
|
|
25746
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25747
|
+
Button_default,
|
|
25748
|
+
{
|
|
25749
|
+
variant: "solid",
|
|
25750
|
+
onClick: handleSendMessage,
|
|
25751
|
+
disabled: !messageInput.trim() || !isConnected,
|
|
25752
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_react89.PaperPlaneTiltIcon, { size: 20 })
|
|
25753
|
+
}
|
|
25754
|
+
)
|
|
25755
|
+
] }) })
|
|
25756
|
+
] }),
|
|
25757
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "w-64 border-l border-background-200 p-4 hidden lg:block", children: [
|
|
25758
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(Text_default, { size: "sm", weight: "semibold", className: "text-text-900 mb-3", children: [
|
|
25759
|
+
"Participantes (",
|
|
25760
|
+
participants.length,
|
|
25761
|
+
")"
|
|
25762
|
+
] }),
|
|
25763
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "space-y-1", children: participants.map((participant) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25764
|
+
ParticipantItem,
|
|
25765
|
+
{
|
|
25766
|
+
participant
|
|
25767
|
+
},
|
|
25768
|
+
participant.userInstitutionId
|
|
25769
|
+
)) })
|
|
25770
|
+
] })
|
|
25771
|
+
] });
|
|
25772
|
+
};
|
|
25773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
|
|
25774
|
+
"div",
|
|
25775
|
+
{
|
|
25776
|
+
className: cn(
|
|
25777
|
+
"bg-background rounded-xl border border-background-200 h-[600px]",
|
|
25778
|
+
className
|
|
25779
|
+
),
|
|
25780
|
+
children: [
|
|
25781
|
+
view === "list" && renderRoomList(),
|
|
25782
|
+
view === "room" && renderChatRoom(),
|
|
25783
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25784
|
+
Modal_default,
|
|
25785
|
+
{
|
|
25786
|
+
isOpen: showCreateModal,
|
|
25787
|
+
onClose: () => setShowCreateModal(false),
|
|
25788
|
+
title: "Nova conversa",
|
|
25789
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "p-4", children: [
|
|
25790
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", className: "text-text-600 mb-4", children: "Selecione os participantes para iniciar uma conversa" }),
|
|
25791
|
+
roomsLoading && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "space-y-3", children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
25792
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SkeletonRounded, { className: "w-10 h-10" }),
|
|
25793
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(SkeletonText, { className: "flex-1 h-4" })
|
|
25794
|
+
] }, i)) }),
|
|
25795
|
+
!roomsLoading && availableUsers.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Text_default, { size: "sm", className: "text-text-500 text-center py-4", children: "Nenhum usuario disponivel para chat" }),
|
|
25796
|
+
!roomsLoading && availableUsers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25797
|
+
UserSelector,
|
|
25798
|
+
{
|
|
25799
|
+
users: availableUsers,
|
|
25800
|
+
selectedIds: selectedUserIds,
|
|
25801
|
+
onToggle: handleToggleUser
|
|
25802
|
+
}
|
|
25803
|
+
),
|
|
25804
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex justify-end gap-2 mt-6", children: [
|
|
25805
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(Button_default, { variant: "outline", onClick: () => setShowCreateModal(false), children: "Cancelar" }),
|
|
25806
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
25807
|
+
Button_default,
|
|
25808
|
+
{
|
|
25809
|
+
variant: "solid",
|
|
25810
|
+
onClick: handleCreateRoom,
|
|
25811
|
+
disabled: selectedUserIds.size === 0 || roomsLoading,
|
|
25812
|
+
children: "Criar conversa"
|
|
25813
|
+
}
|
|
25814
|
+
)
|
|
25815
|
+
] })
|
|
25816
|
+
] })
|
|
25817
|
+
}
|
|
25818
|
+
)
|
|
25819
|
+
]
|
|
25820
|
+
}
|
|
25821
|
+
);
|
|
25822
|
+
}
|
|
24096
25823
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24097
25824
|
0 && (module.exports = {
|
|
24098
25825
|
ACTIVITY_AVAILABILITY,
|
|
25826
|
+
ACTIVITY_FILTER_STATUS_OPTIONS,
|
|
24099
25827
|
ANSWER_STATUS,
|
|
24100
25828
|
AccordionGroup,
|
|
25829
|
+
ActivitiesHistory,
|
|
25830
|
+
ActivityApiStatus,
|
|
25831
|
+
ActivityBadgeActionType,
|
|
24101
25832
|
ActivityCardQuestionBanks,
|
|
24102
25833
|
ActivityCardQuestionPreview,
|
|
24103
25834
|
ActivityDetails,
|
|
25835
|
+
ActivityDisplayStatus,
|
|
25836
|
+
ActivityDraftType,
|
|
24104
25837
|
ActivityFilters,
|
|
24105
25838
|
ActivityFiltersPopover,
|
|
24106
25839
|
ActivityPreview,
|
|
@@ -24113,6 +25846,7 @@ var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
|
24113
25846
|
Badge,
|
|
24114
25847
|
BreadcrumbMenu,
|
|
24115
25848
|
Button,
|
|
25849
|
+
CHAT_MESSAGE_TYPES,
|
|
24116
25850
|
CORRECTION_QUESTION_STATUS,
|
|
24117
25851
|
Calendar,
|
|
24118
25852
|
CardAccordation,
|
|
@@ -24127,6 +25861,7 @@ var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
|
24127
25861
|
CardStatus,
|
|
24128
25862
|
CardTest,
|
|
24129
25863
|
CardTopic,
|
|
25864
|
+
Chat,
|
|
24130
25865
|
CheckBox,
|
|
24131
25866
|
CheckboxGroup,
|
|
24132
25867
|
CheckboxList,
|
|
@@ -24134,6 +25869,8 @@ var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
|
24134
25869
|
Chips,
|
|
24135
25870
|
CorrectActivityModal,
|
|
24136
25871
|
CreateActivity,
|
|
25872
|
+
DEFAULT_ACTIVITIES_PAGINATION,
|
|
25873
|
+
DEFAULT_MODELS_PAGINATION,
|
|
24137
25874
|
DIFFICULTY_LEVEL_ENUM,
|
|
24138
25875
|
DateTimeInput,
|
|
24139
25876
|
Divider,
|
|
@@ -24171,6 +25908,7 @@ var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
|
24171
25908
|
NotFound,
|
|
24172
25909
|
NotificationCard,
|
|
24173
25910
|
NotificationEntityType,
|
|
25911
|
+
PROFILE_ROLES,
|
|
24174
25912
|
ProfileMenuFooter,
|
|
24175
25913
|
ProfileMenuHeader,
|
|
24176
25914
|
ProfileMenuInfo,
|
|
@@ -24255,16 +25993,25 @@ var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
|
24255
25993
|
Toast,
|
|
24256
25994
|
Toaster,
|
|
24257
25995
|
VideoPlayer,
|
|
25996
|
+
WS_STATES,
|
|
24258
25997
|
Whiteboard,
|
|
25998
|
+
activitiesHistoryApiResponseSchema,
|
|
25999
|
+
activityModelsApiResponseSchema,
|
|
24259
26000
|
cn,
|
|
24260
26001
|
convertActivityFiltersToQuestionsFilter,
|
|
26002
|
+
createActivitiesHistoryHook,
|
|
24261
26003
|
createActivityFiltersDataHook,
|
|
26004
|
+
createActivityModelsHook,
|
|
24262
26005
|
createNotificationStore,
|
|
24263
26006
|
createNotificationsHook,
|
|
24264
26007
|
createQuestionsListHook,
|
|
24265
26008
|
createRecommendedLessonDetailsHook,
|
|
24266
26009
|
createRecommendedLessonsHistoryHook,
|
|
26010
|
+
createUseActivitiesHistory,
|
|
24267
26011
|
createUseActivityFiltersData,
|
|
26012
|
+
createUseActivityModels,
|
|
26013
|
+
createUseChat,
|
|
26014
|
+
createUseChatRooms,
|
|
24268
26015
|
createUseNotificationStore,
|
|
24269
26016
|
createUseNotifications,
|
|
24270
26017
|
createUseQuestionsList,
|
|
@@ -24280,6 +26027,7 @@ var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
|
24280
26027
|
formatTimeAgo,
|
|
24281
26028
|
formatTimeSpent,
|
|
24282
26029
|
generateFileId,
|
|
26030
|
+
getActivityStatusBadgeAction,
|
|
24283
26031
|
getCategoryIcon,
|
|
24284
26032
|
getCategoryText,
|
|
24285
26033
|
getDeviceType,
|
|
@@ -24300,12 +26048,15 @@ var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
|
24300
26048
|
goalApiResponseSchema,
|
|
24301
26049
|
goalDetailsApiResponseSchema,
|
|
24302
26050
|
goalsHistoryApiResponseSchema,
|
|
26051
|
+
handleActivityFetchError,
|
|
24303
26052
|
handleGoalFetchError,
|
|
24304
26053
|
handleLessonDetailsFetchError,
|
|
26054
|
+
handleModelFetchError,
|
|
24305
26055
|
historyApiResponseSchema,
|
|
24306
26056
|
isDeadlinePassed,
|
|
24307
26057
|
isFormValid,
|
|
24308
26058
|
isStepValid,
|
|
26059
|
+
mapActivityStatusToDisplay,
|
|
24309
26060
|
mapApiStatusToInternal,
|
|
24310
26061
|
mapInternalStatusToApi,
|
|
24311
26062
|
mapQuestionTypeToEnum,
|
|
@@ -24315,7 +26066,9 @@ var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
|
24315
26066
|
syncDropdownState,
|
|
24316
26067
|
toggleArrayItem,
|
|
24317
26068
|
toggleSingleValue,
|
|
26069
|
+
transformActivityToTableItem,
|
|
24318
26070
|
transformGoalToTableItem,
|
|
26071
|
+
transformModelToTableItem,
|
|
24319
26072
|
useAlertFormStore,
|
|
24320
26073
|
useApiConfig,
|
|
24321
26074
|
useAppContent,
|
|
@@ -24326,6 +26079,8 @@ var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
|
24326
26079
|
useAuthStore,
|
|
24327
26080
|
useBreadcrumb,
|
|
24328
26081
|
useBreadcrumbBuilder,
|
|
26082
|
+
useChat,
|
|
26083
|
+
useChatRooms,
|
|
24329
26084
|
useInstitutionId,
|
|
24330
26085
|
useMobile,
|
|
24331
26086
|
useQuestionFiltersStore,
|