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.mjs
CHANGED
|
@@ -4985,6 +4985,11 @@ var Toaster = () => {
|
|
|
4985
4985
|
toast.id
|
|
4986
4986
|
)) });
|
|
4987
4987
|
};
|
|
4988
|
+
var useToast = () => {
|
|
4989
|
+
const addToast = ToastStore_default((state) => state.addToast);
|
|
4990
|
+
const removeToast = ToastStore_default((state) => state.removeToast);
|
|
4991
|
+
return { addToast, removeToast };
|
|
4992
|
+
};
|
|
4988
4993
|
var Toaster_default = Toaster;
|
|
4989
4994
|
|
|
4990
4995
|
// src/components/Search/Search.tsx
|
|
@@ -22421,26 +22426,26 @@ var SendActivityModal_default = SendActivityModal;
|
|
|
22421
22426
|
import { useState as useState44, useCallback as useCallback20, useMemo as useMemo25, useRef as useRef25 } from "react";
|
|
22422
22427
|
import { Plus as Plus3, CaretRight as CaretRight10, Trash as Trash2, PencilSimple as PencilSimple2 } from "phosphor-react";
|
|
22423
22428
|
|
|
22424
|
-
// src/types/
|
|
22425
|
-
var
|
|
22426
|
-
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
return
|
|
22430
|
-
})(
|
|
22431
|
-
var
|
|
22432
|
-
|
|
22433
|
-
|
|
22434
|
-
|
|
22435
|
-
return
|
|
22436
|
-
})(
|
|
22437
|
-
var
|
|
22438
|
-
|
|
22439
|
-
|
|
22440
|
-
|
|
22441
|
-
return
|
|
22442
|
-
})(
|
|
22443
|
-
var
|
|
22429
|
+
// src/types/common.ts
|
|
22430
|
+
var GenericApiStatus = /* @__PURE__ */ ((GenericApiStatus2) => {
|
|
22431
|
+
GenericApiStatus2["A_VENCER"] = "A_VENCER";
|
|
22432
|
+
GenericApiStatus2["VENCIDA"] = "VENCIDA";
|
|
22433
|
+
GenericApiStatus2["CONCLUIDA"] = "CONCLUIDA";
|
|
22434
|
+
return GenericApiStatus2;
|
|
22435
|
+
})(GenericApiStatus || {});
|
|
22436
|
+
var GenericDisplayStatus = /* @__PURE__ */ ((GenericDisplayStatus4) => {
|
|
22437
|
+
GenericDisplayStatus4["ATIVA"] = "ATIVA";
|
|
22438
|
+
GenericDisplayStatus4["VENCIDA"] = "VENCIDA";
|
|
22439
|
+
GenericDisplayStatus4["CONCLUIDA"] = "CONCLU\xCDDA";
|
|
22440
|
+
return GenericDisplayStatus4;
|
|
22441
|
+
})(GenericDisplayStatus || {});
|
|
22442
|
+
var BadgeActionType = /* @__PURE__ */ ((BadgeActionType4) => {
|
|
22443
|
+
BadgeActionType4["SUCCESS"] = "success";
|
|
22444
|
+
BadgeActionType4["WARNING"] = "warning";
|
|
22445
|
+
BadgeActionType4["ERROR"] = "error";
|
|
22446
|
+
return BadgeActionType4;
|
|
22447
|
+
})(BadgeActionType || {});
|
|
22448
|
+
var getStatusBadgeAction2 = (status) => {
|
|
22444
22449
|
const actionMap = {
|
|
22445
22450
|
["CONCLU\xCDDA" /* CONCLUIDA */]: "success" /* SUCCESS */,
|
|
22446
22451
|
["ATIVA" /* ATIVA */]: "warning" /* WARNING */,
|
|
@@ -22448,6 +22453,17 @@ var getGoalStatusBadgeAction = (status) => {
|
|
|
22448
22453
|
};
|
|
22449
22454
|
return actionMap[status] ?? "warning" /* WARNING */;
|
|
22450
22455
|
};
|
|
22456
|
+
var mapApiStatusToDisplay = (apiStatus) => {
|
|
22457
|
+
const statusMap = {
|
|
22458
|
+
["A_VENCER" /* A_VENCER */]: "ATIVA" /* ATIVA */,
|
|
22459
|
+
["VENCIDA" /* VENCIDA */]: "VENCIDA" /* VENCIDA */,
|
|
22460
|
+
["CONCLUIDA" /* CONCLUIDA */]: "CONCLU\xCDDA" /* CONCLUIDA */
|
|
22461
|
+
};
|
|
22462
|
+
return statusMap[apiStatus];
|
|
22463
|
+
};
|
|
22464
|
+
|
|
22465
|
+
// src/types/recommendedLessons.ts
|
|
22466
|
+
var getGoalStatusBadgeAction = (status) => getStatusBadgeAction2(status);
|
|
22451
22467
|
var GOAL_FILTER_STATUS_OPTIONS = [
|
|
22452
22468
|
{ id: "VENCIDA" /* VENCIDA */, name: "Vencida" },
|
|
22453
22469
|
{ id: "A_VENCER" /* A_VENCER */, name: "Ativa" }
|
|
@@ -23997,13 +24013,1707 @@ var createUseRecommendedLessonDetails = (apiClient) => {
|
|
|
23997
24013
|
};
|
|
23998
24014
|
};
|
|
23999
24015
|
var createRecommendedLessonDetailsHook = createUseRecommendedLessonDetails;
|
|
24016
|
+
|
|
24017
|
+
// src/components/ActivitiesHistory/ActivitiesHistory.tsx
|
|
24018
|
+
import { useState as useState49 } from "react";
|
|
24019
|
+
|
|
24020
|
+
// src/components/ActivitiesHistory/tabs/HistoryTab.tsx
|
|
24021
|
+
import { useCallback as useCallback24, useMemo as useMemo28, useRef as useRef26 } from "react";
|
|
24022
|
+
import { Plus as Plus4 } from "phosphor-react";
|
|
24023
|
+
|
|
24024
|
+
// src/components/ActivitiesHistory/components/ErrorDisplay.tsx
|
|
24025
|
+
import { jsx as jsx95 } from "react/jsx-runtime";
|
|
24026
|
+
var ErrorDisplay = ({ error }) => /* @__PURE__ */ jsx95("div", { className: "flex items-center justify-center bg-background rounded-xl w-full min-h-[705px]", children: /* @__PURE__ */ jsx95(Text_default, { size: "lg", color: "text-error-500", children: error }) });
|
|
24027
|
+
|
|
24028
|
+
// src/components/ActivitiesHistory/config/historyTableColumns.tsx
|
|
24029
|
+
import { CaretRight as CaretRight11 } from "phosphor-react";
|
|
24030
|
+
|
|
24031
|
+
// src/components/ActivitiesHistory/utils/renderSubjectCell.tsx
|
|
24032
|
+
import { jsx as jsx96, jsxs as jsxs78 } from "react/jsx-runtime";
|
|
24033
|
+
var renderSubjectCell = (subjectName, mapSubjectNameToEnum, showEmptyDash = false) => {
|
|
24034
|
+
if (!subjectName) {
|
|
24035
|
+
return showEmptyDash ? /* @__PURE__ */ jsx96(Text_default, { size: "sm", color: "text-text-400", children: "-" }) : null;
|
|
24036
|
+
}
|
|
24037
|
+
const subjectEnum = mapSubjectNameToEnum?.(subjectName);
|
|
24038
|
+
if (!subjectEnum) {
|
|
24039
|
+
return /* @__PURE__ */ jsx96(Text_default, { size: "sm", className: "truncate", title: subjectName, children: subjectName });
|
|
24040
|
+
}
|
|
24041
|
+
const subjectInfo = getSubjectInfo(subjectEnum);
|
|
24042
|
+
return /* @__PURE__ */ jsxs78("div", { className: "flex items-center gap-2", title: subjectName, children: [
|
|
24043
|
+
/* @__PURE__ */ jsx96(
|
|
24044
|
+
"span",
|
|
24045
|
+
{
|
|
24046
|
+
className: cn(
|
|
24047
|
+
"w-[21px] h-[21px] flex items-center justify-center rounded-sm text-text-950 shrink-0",
|
|
24048
|
+
subjectInfo.colorClass
|
|
24049
|
+
),
|
|
24050
|
+
children: subjectInfo.icon
|
|
24051
|
+
}
|
|
24052
|
+
),
|
|
24053
|
+
/* @__PURE__ */ jsx96(Text_default, { size: "sm", className: "truncate", children: subjectName })
|
|
24054
|
+
] });
|
|
24055
|
+
};
|
|
24056
|
+
|
|
24057
|
+
// src/components/ActivitiesHistory/utils/renderTruncatedText.tsx
|
|
24058
|
+
import { jsx as jsx97 } from "react/jsx-runtime";
|
|
24059
|
+
var renderTruncatedText = (value) => {
|
|
24060
|
+
const text = typeof value === "string" ? value : "";
|
|
24061
|
+
return /* @__PURE__ */ jsx97(Text_default, { size: "sm", title: text, children: text });
|
|
24062
|
+
};
|
|
24063
|
+
|
|
24064
|
+
// src/components/ActivitiesHistory/utils/filterBuilders.ts
|
|
24065
|
+
var isNonEmptyArray2 = (param) => Array.isArray(param) && param.length > 0;
|
|
24066
|
+
var isValidApiStatus = (value) => Object.values(GenericApiStatus).includes(value);
|
|
24067
|
+
var buildHistoryFiltersFromParams = (params) => {
|
|
24068
|
+
const filters = {
|
|
24069
|
+
page: params.page,
|
|
24070
|
+
limit: params.limit
|
|
24071
|
+
};
|
|
24072
|
+
if (params.search) {
|
|
24073
|
+
filters.search = params.search;
|
|
24074
|
+
}
|
|
24075
|
+
if (isNonEmptyArray2(params.status) && isValidApiStatus(params.status[0])) {
|
|
24076
|
+
filters.status = params.status[0];
|
|
24077
|
+
}
|
|
24078
|
+
if (isNonEmptyArray2(params.school)) {
|
|
24079
|
+
filters.schoolId = params.school[0];
|
|
24080
|
+
}
|
|
24081
|
+
if (isNonEmptyArray2(params.subject)) {
|
|
24082
|
+
filters.subjectId = params.subject[0];
|
|
24083
|
+
}
|
|
24084
|
+
return filters;
|
|
24085
|
+
};
|
|
24086
|
+
var buildModelsFiltersFromParams = (params) => {
|
|
24087
|
+
const filters = {
|
|
24088
|
+
page: params.page,
|
|
24089
|
+
limit: params.limit
|
|
24090
|
+
};
|
|
24091
|
+
if (params.search) {
|
|
24092
|
+
filters.search = params.search;
|
|
24093
|
+
}
|
|
24094
|
+
if (isNonEmptyArray2(params.subject)) {
|
|
24095
|
+
filters.subjectId = params.subject[0];
|
|
24096
|
+
}
|
|
24097
|
+
return filters;
|
|
24098
|
+
};
|
|
24099
|
+
|
|
24100
|
+
// src/components/ActivitiesHistory/utils/filterOptions.ts
|
|
24101
|
+
var getSchoolOptions2 = (data) => {
|
|
24102
|
+
if (!data?.schools) return [];
|
|
24103
|
+
return data.schools.map((school) => ({
|
|
24104
|
+
id: school.id,
|
|
24105
|
+
name: school.name
|
|
24106
|
+
}));
|
|
24107
|
+
};
|
|
24108
|
+
var getSubjectOptions2 = (data) => {
|
|
24109
|
+
if (!data?.subjects) return [];
|
|
24110
|
+
return data.subjects.map((subject) => ({
|
|
24111
|
+
id: subject.id,
|
|
24112
|
+
name: subject.name
|
|
24113
|
+
}));
|
|
24114
|
+
};
|
|
24115
|
+
|
|
24116
|
+
// src/types/activitiesHistory.ts
|
|
24117
|
+
var ActivityDraftType = /* @__PURE__ */ ((ActivityDraftType2) => {
|
|
24118
|
+
ActivityDraftType2["MODELO"] = "MODELO";
|
|
24119
|
+
ActivityDraftType2["RASCUNHO"] = "RASCUNHO";
|
|
24120
|
+
return ActivityDraftType2;
|
|
24121
|
+
})(ActivityDraftType || {});
|
|
24122
|
+
var getActivityStatusBadgeAction = (status) => getStatusBadgeAction2(status);
|
|
24123
|
+
var ACTIVITY_FILTER_STATUS_OPTIONS = [
|
|
24124
|
+
{ id: "A_VENCER" /* A_VENCER */, name: "A Vencer" },
|
|
24125
|
+
{ id: "VENCIDA" /* VENCIDA */, name: "Vencida" },
|
|
24126
|
+
{ id: "CONCLUIDA" /* CONCLUIDA */, name: "Conclu\xEDda" }
|
|
24127
|
+
];
|
|
24128
|
+
var mapActivityStatusToDisplay = (apiStatus) => mapApiStatusToDisplay(apiStatus);
|
|
24129
|
+
|
|
24130
|
+
// src/components/ActivitiesHistory/config/historyTableColumns.tsx
|
|
24131
|
+
import { jsx as jsx98 } from "react/jsx-runtime";
|
|
24132
|
+
var createHistoryTableColumns = (mapSubjectNameToEnum) => [
|
|
24133
|
+
{
|
|
24134
|
+
key: "startDate",
|
|
24135
|
+
label: "In\xEDcio",
|
|
24136
|
+
sortable: true
|
|
24137
|
+
},
|
|
24138
|
+
{
|
|
24139
|
+
key: "deadline",
|
|
24140
|
+
label: "Prazo",
|
|
24141
|
+
sortable: true
|
|
24142
|
+
},
|
|
24143
|
+
{
|
|
24144
|
+
key: "title",
|
|
24145
|
+
label: "T\xEDtulo",
|
|
24146
|
+
sortable: true,
|
|
24147
|
+
className: "max-w-[200px] truncate",
|
|
24148
|
+
render: renderTruncatedText
|
|
24149
|
+
},
|
|
24150
|
+
{
|
|
24151
|
+
key: "school",
|
|
24152
|
+
label: "Escola",
|
|
24153
|
+
sortable: true,
|
|
24154
|
+
className: "max-w-[150px] truncate",
|
|
24155
|
+
render: renderTruncatedText
|
|
24156
|
+
},
|
|
24157
|
+
{
|
|
24158
|
+
key: "year",
|
|
24159
|
+
label: "Ano",
|
|
24160
|
+
sortable: true
|
|
24161
|
+
},
|
|
24162
|
+
{
|
|
24163
|
+
key: "subject",
|
|
24164
|
+
label: "Mat\xE9ria",
|
|
24165
|
+
sortable: true,
|
|
24166
|
+
className: "max-w-[140px]",
|
|
24167
|
+
render: (value) => {
|
|
24168
|
+
const subjectName = typeof value === "string" ? value : "";
|
|
24169
|
+
return renderSubjectCell(subjectName, mapSubjectNameToEnum, false);
|
|
24170
|
+
}
|
|
24171
|
+
},
|
|
24172
|
+
{
|
|
24173
|
+
key: "class",
|
|
24174
|
+
label: "Turma",
|
|
24175
|
+
sortable: true
|
|
24176
|
+
},
|
|
24177
|
+
{
|
|
24178
|
+
key: "status",
|
|
24179
|
+
label: "Status",
|
|
24180
|
+
sortable: true,
|
|
24181
|
+
render: (value) => {
|
|
24182
|
+
const status = typeof value === "string" ? value : "";
|
|
24183
|
+
if (!status) {
|
|
24184
|
+
return /* @__PURE__ */ jsx98(Text_default, { size: "sm", color: "text-text-500", children: "-" });
|
|
24185
|
+
}
|
|
24186
|
+
return /* @__PURE__ */ jsx98(
|
|
24187
|
+
Badge_default,
|
|
24188
|
+
{
|
|
24189
|
+
variant: "solid",
|
|
24190
|
+
action: getActivityStatusBadgeAction(status),
|
|
24191
|
+
size: "small",
|
|
24192
|
+
children: status
|
|
24193
|
+
}
|
|
24194
|
+
);
|
|
24195
|
+
}
|
|
24196
|
+
},
|
|
24197
|
+
{
|
|
24198
|
+
key: "completionPercentage",
|
|
24199
|
+
label: "Conclus\xE3o",
|
|
24200
|
+
sortable: true,
|
|
24201
|
+
render: (value) => /* @__PURE__ */ jsx98(
|
|
24202
|
+
ProgressBar_default,
|
|
24203
|
+
{
|
|
24204
|
+
value: Number(value),
|
|
24205
|
+
variant: "blue",
|
|
24206
|
+
size: "medium",
|
|
24207
|
+
layout: "compact",
|
|
24208
|
+
showPercentage: true,
|
|
24209
|
+
compactWidth: "w-[100px]"
|
|
24210
|
+
}
|
|
24211
|
+
)
|
|
24212
|
+
},
|
|
24213
|
+
{
|
|
24214
|
+
key: "navigation",
|
|
24215
|
+
label: "",
|
|
24216
|
+
sortable: false,
|
|
24217
|
+
className: "w-12",
|
|
24218
|
+
render: () => /* @__PURE__ */ jsx98("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx98(CaretRight11, { size: 20, className: "text-text-600" }) })
|
|
24219
|
+
}
|
|
24220
|
+
];
|
|
24221
|
+
|
|
24222
|
+
// src/components/ActivitiesHistory/config/historyFiltersConfig.ts
|
|
24223
|
+
var createHistoryFiltersConfig = (userData) => [
|
|
24224
|
+
{
|
|
24225
|
+
key: "status",
|
|
24226
|
+
label: "STATUS",
|
|
24227
|
+
categories: [
|
|
24228
|
+
{
|
|
24229
|
+
key: "status",
|
|
24230
|
+
label: "Status da Atividade",
|
|
24231
|
+
selectedIds: [],
|
|
24232
|
+
itens: ACTIVITY_FILTER_STATUS_OPTIONS
|
|
24233
|
+
}
|
|
24234
|
+
]
|
|
24235
|
+
},
|
|
24236
|
+
{
|
|
24237
|
+
key: "academic",
|
|
24238
|
+
label: "DADOS ACAD\xCAMICOS",
|
|
24239
|
+
categories: [
|
|
24240
|
+
{
|
|
24241
|
+
key: "school",
|
|
24242
|
+
label: "Escola",
|
|
24243
|
+
selectedIds: [],
|
|
24244
|
+
itens: getSchoolOptions2(userData)
|
|
24245
|
+
}
|
|
24246
|
+
]
|
|
24247
|
+
},
|
|
24248
|
+
{
|
|
24249
|
+
key: "content",
|
|
24250
|
+
label: "CONTE\xDADO",
|
|
24251
|
+
categories: [
|
|
24252
|
+
{
|
|
24253
|
+
key: "subject",
|
|
24254
|
+
label: "Mat\xE9ria",
|
|
24255
|
+
selectedIds: [],
|
|
24256
|
+
itens: getSubjectOptions2(userData)
|
|
24257
|
+
}
|
|
24258
|
+
]
|
|
24259
|
+
}
|
|
24260
|
+
];
|
|
24261
|
+
|
|
24262
|
+
// src/hooks/useActivitiesHistory.ts
|
|
24263
|
+
import { useState as useState46, useCallback as useCallback23 } from "react";
|
|
24264
|
+
import { z as z6 } from "zod";
|
|
24265
|
+
import dayjs4 from "dayjs";
|
|
24266
|
+
|
|
24267
|
+
// src/utils/hookErrorHandler.ts
|
|
24268
|
+
import { z as z5 } from "zod";
|
|
24269
|
+
var createFetchErrorHandler = (validationErrorMessage, genericErrorMessage) => (error) => {
|
|
24270
|
+
if (error instanceof z5.ZodError) {
|
|
24271
|
+
console.error(validationErrorMessage, error);
|
|
24272
|
+
return validationErrorMessage;
|
|
24273
|
+
}
|
|
24274
|
+
console.error(genericErrorMessage, error);
|
|
24275
|
+
return genericErrorMessage;
|
|
24276
|
+
};
|
|
24277
|
+
|
|
24278
|
+
// src/hooks/useActivitiesHistory.ts
|
|
24279
|
+
var activityHistoryResponseSchema = z6.object({
|
|
24280
|
+
id: z6.string().uuid(),
|
|
24281
|
+
title: z6.string(),
|
|
24282
|
+
startDate: z6.string().nullable(),
|
|
24283
|
+
finalDate: z6.string().nullable(),
|
|
24284
|
+
status: z6.nativeEnum(GenericApiStatus),
|
|
24285
|
+
completionPercentage: z6.number().min(0).max(100),
|
|
24286
|
+
subjectId: z6.string().uuid(),
|
|
24287
|
+
schoolId: z6.string().optional(),
|
|
24288
|
+
schoolName: z6.string().optional(),
|
|
24289
|
+
year: z6.string().optional(),
|
|
24290
|
+
className: z6.string().optional(),
|
|
24291
|
+
subjectName: z6.string().optional()
|
|
24292
|
+
});
|
|
24293
|
+
var activitiesHistoryApiResponseSchema = z6.object({
|
|
24294
|
+
message: z6.string(),
|
|
24295
|
+
data: z6.object({
|
|
24296
|
+
activities: z6.array(activityHistoryResponseSchema),
|
|
24297
|
+
pagination: z6.object({
|
|
24298
|
+
total: z6.number(),
|
|
24299
|
+
page: z6.number(),
|
|
24300
|
+
limit: z6.number(),
|
|
24301
|
+
totalPages: z6.number()
|
|
24302
|
+
})
|
|
24303
|
+
})
|
|
24304
|
+
});
|
|
24305
|
+
var DEFAULT_ACTIVITIES_PAGINATION = {
|
|
24306
|
+
total: 0,
|
|
24307
|
+
page: 1,
|
|
24308
|
+
limit: 10,
|
|
24309
|
+
totalPages: 0
|
|
24310
|
+
};
|
|
24311
|
+
var transformActivityToTableItem = (activity) => {
|
|
24312
|
+
return {
|
|
24313
|
+
id: activity.id,
|
|
24314
|
+
startDate: activity.startDate ? dayjs4(activity.startDate).format("DD/MM") : "-",
|
|
24315
|
+
deadline: activity.finalDate ? dayjs4(activity.finalDate).format("DD/MM") : "-",
|
|
24316
|
+
title: activity.title,
|
|
24317
|
+
school: activity.schoolName || "-",
|
|
24318
|
+
year: activity.year || "-",
|
|
24319
|
+
subject: activity.subjectName || "-",
|
|
24320
|
+
class: activity.className || "-",
|
|
24321
|
+
status: mapActivityStatusToDisplay(activity.status),
|
|
24322
|
+
completionPercentage: activity.completionPercentage
|
|
24323
|
+
};
|
|
24324
|
+
};
|
|
24325
|
+
var handleActivityFetchError = createFetchErrorHandler(
|
|
24326
|
+
"Erro ao validar dados de hist\xF3rico de atividades",
|
|
24327
|
+
"Erro ao carregar hist\xF3rico de atividades"
|
|
24328
|
+
);
|
|
24329
|
+
var createUseActivitiesHistory = (fetchActivitiesHistory) => {
|
|
24330
|
+
return () => {
|
|
24331
|
+
const [state, setState] = useState46({
|
|
24332
|
+
activities: [],
|
|
24333
|
+
loading: false,
|
|
24334
|
+
error: null,
|
|
24335
|
+
pagination: DEFAULT_ACTIVITIES_PAGINATION
|
|
24336
|
+
});
|
|
24337
|
+
const fetchActivities = useCallback23(
|
|
24338
|
+
async (filters) => {
|
|
24339
|
+
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
24340
|
+
try {
|
|
24341
|
+
const responseData = await fetchActivitiesHistory(filters);
|
|
24342
|
+
const validatedData = activitiesHistoryApiResponseSchema.parse(responseData);
|
|
24343
|
+
const tableItems = validatedData.data.activities.map(
|
|
24344
|
+
transformActivityToTableItem
|
|
24345
|
+
);
|
|
24346
|
+
setState({
|
|
24347
|
+
activities: tableItems,
|
|
24348
|
+
loading: false,
|
|
24349
|
+
error: null,
|
|
24350
|
+
pagination: validatedData.data.pagination
|
|
24351
|
+
});
|
|
24352
|
+
} catch (error) {
|
|
24353
|
+
const errorMessage = handleActivityFetchError(error);
|
|
24354
|
+
setState((prev) => ({
|
|
24355
|
+
...prev,
|
|
24356
|
+
loading: false,
|
|
24357
|
+
error: errorMessage
|
|
24358
|
+
}));
|
|
24359
|
+
}
|
|
24360
|
+
},
|
|
24361
|
+
[fetchActivitiesHistory]
|
|
24362
|
+
);
|
|
24363
|
+
return {
|
|
24364
|
+
...state,
|
|
24365
|
+
fetchActivities
|
|
24366
|
+
};
|
|
24367
|
+
};
|
|
24368
|
+
};
|
|
24369
|
+
var createActivitiesHistoryHook = createUseActivitiesHistory;
|
|
24370
|
+
|
|
24371
|
+
// src/components/ActivitiesHistory/tabs/HistoryTab.tsx
|
|
24372
|
+
import { jsx as jsx99, jsxs as jsxs79 } from "react/jsx-runtime";
|
|
24373
|
+
var HistoryTab = ({
|
|
24374
|
+
fetchActivitiesHistory,
|
|
24375
|
+
onCreateActivity,
|
|
24376
|
+
onRowClick,
|
|
24377
|
+
emptyStateImage,
|
|
24378
|
+
noSearchImage,
|
|
24379
|
+
mapSubjectNameToEnum,
|
|
24380
|
+
userFilterData
|
|
24381
|
+
}) => {
|
|
24382
|
+
const fetchActivitiesHistoryRef = useRef26(fetchActivitiesHistory);
|
|
24383
|
+
fetchActivitiesHistoryRef.current = fetchActivitiesHistory;
|
|
24384
|
+
const useActivitiesHistory = useMemo28(
|
|
24385
|
+
() => createUseActivitiesHistory(
|
|
24386
|
+
(filters) => fetchActivitiesHistoryRef.current(filters)
|
|
24387
|
+
),
|
|
24388
|
+
[]
|
|
24389
|
+
);
|
|
24390
|
+
const {
|
|
24391
|
+
activities,
|
|
24392
|
+
loading,
|
|
24393
|
+
error,
|
|
24394
|
+
pagination,
|
|
24395
|
+
fetchActivities
|
|
24396
|
+
} = useActivitiesHistory();
|
|
24397
|
+
const historyFilterConfigs = useMemo28(
|
|
24398
|
+
() => createHistoryFiltersConfig(userFilterData),
|
|
24399
|
+
[userFilterData]
|
|
24400
|
+
);
|
|
24401
|
+
const historyTableColumns = useMemo28(
|
|
24402
|
+
() => createHistoryTableColumns(mapSubjectNameToEnum),
|
|
24403
|
+
[mapSubjectNameToEnum]
|
|
24404
|
+
);
|
|
24405
|
+
const handleParamsChange = useCallback24(
|
|
24406
|
+
(params) => {
|
|
24407
|
+
const filters = buildHistoryFiltersFromParams(params);
|
|
24408
|
+
fetchActivities(filters);
|
|
24409
|
+
},
|
|
24410
|
+
[fetchActivities]
|
|
24411
|
+
);
|
|
24412
|
+
if (error) {
|
|
24413
|
+
return /* @__PURE__ */ jsx99(ErrorDisplay, { error });
|
|
24414
|
+
}
|
|
24415
|
+
return /* @__PURE__ */ jsx99("div", { className: "w-full", children: /* @__PURE__ */ jsx99(
|
|
24416
|
+
TableProvider,
|
|
24417
|
+
{
|
|
24418
|
+
data: activities,
|
|
24419
|
+
headers: historyTableColumns,
|
|
24420
|
+
loading,
|
|
24421
|
+
variant: "borderless",
|
|
24422
|
+
enableSearch: true,
|
|
24423
|
+
enableFilters: true,
|
|
24424
|
+
enableTableSort: true,
|
|
24425
|
+
enablePagination: true,
|
|
24426
|
+
enableRowClick: true,
|
|
24427
|
+
initialFilters: historyFilterConfigs,
|
|
24428
|
+
paginationConfig: {
|
|
24429
|
+
itemLabel: "atividades",
|
|
24430
|
+
itemsPerPageOptions: [10, 20, 50, 100],
|
|
24431
|
+
defaultItemsPerPage: 10,
|
|
24432
|
+
totalItems: pagination.total,
|
|
24433
|
+
totalPages: pagination.totalPages
|
|
24434
|
+
},
|
|
24435
|
+
searchPlaceholder: "Buscar atividade",
|
|
24436
|
+
noSearchResultState: {
|
|
24437
|
+
image: noSearchImage
|
|
24438
|
+
},
|
|
24439
|
+
emptyState: {
|
|
24440
|
+
component: /* @__PURE__ */ jsx99(
|
|
24441
|
+
EmptyState_default,
|
|
24442
|
+
{
|
|
24443
|
+
image: emptyStateImage,
|
|
24444
|
+
title: "Incentive sua turma ao aprendizado",
|
|
24445
|
+
description: "Crie uma nova atividade e ajude seus alunos a colocarem o conte\xFAdo em pr\xE1tica!",
|
|
24446
|
+
buttonText: "Criar atividade",
|
|
24447
|
+
buttonIcon: /* @__PURE__ */ jsx99(Plus4, { size: 18 }),
|
|
24448
|
+
buttonVariant: "outline",
|
|
24449
|
+
buttonAction: "primary",
|
|
24450
|
+
onButtonClick: onCreateActivity
|
|
24451
|
+
}
|
|
24452
|
+
)
|
|
24453
|
+
},
|
|
24454
|
+
onParamsChange: handleParamsChange,
|
|
24455
|
+
onRowClick,
|
|
24456
|
+
children: (renderProps) => {
|
|
24457
|
+
const {
|
|
24458
|
+
controls,
|
|
24459
|
+
table,
|
|
24460
|
+
pagination: paginationComponent
|
|
24461
|
+
} = renderProps;
|
|
24462
|
+
return /* @__PURE__ */ jsxs79("div", { className: "space-y-4", children: [
|
|
24463
|
+
/* @__PURE__ */ jsxs79("div", { className: "flex items-center justify-between gap-4", children: [
|
|
24464
|
+
/* @__PURE__ */ jsx99(
|
|
24465
|
+
Button_default,
|
|
24466
|
+
{
|
|
24467
|
+
variant: "solid",
|
|
24468
|
+
action: "primary",
|
|
24469
|
+
size: "medium",
|
|
24470
|
+
onClick: onCreateActivity,
|
|
24471
|
+
iconLeft: /* @__PURE__ */ jsx99(Plus4, { size: 18, weight: "bold" }),
|
|
24472
|
+
children: "Criar atividade"
|
|
24473
|
+
}
|
|
24474
|
+
),
|
|
24475
|
+
controls
|
|
24476
|
+
] }),
|
|
24477
|
+
/* @__PURE__ */ jsxs79("div", { className: "bg-background rounded-xl p-6 space-y-4", children: [
|
|
24478
|
+
table,
|
|
24479
|
+
paginationComponent
|
|
24480
|
+
] })
|
|
24481
|
+
] });
|
|
24482
|
+
}
|
|
24483
|
+
}
|
|
24484
|
+
) });
|
|
24485
|
+
};
|
|
24486
|
+
|
|
24487
|
+
// src/components/ActivitiesHistory/tabs/ModelsTab.tsx
|
|
24488
|
+
import { useState as useState48, useCallback as useCallback26, useMemo as useMemo29, useRef as useRef27, useEffect as useEffect45 } from "react";
|
|
24489
|
+
import { Plus as Plus5 } from "phosphor-react";
|
|
24490
|
+
|
|
24491
|
+
// src/components/ActivitiesHistory/config/modelsTableColumns.tsx
|
|
24492
|
+
import { Trash as Trash3, PencilSimple as PencilSimple3, PaperPlaneTilt as PaperPlaneTilt3 } from "phosphor-react";
|
|
24493
|
+
import { jsx as jsx100, jsxs as jsxs80 } from "react/jsx-runtime";
|
|
24494
|
+
var createModelsTableColumns = (mapSubjectNameToEnum, onSendActivity, onEditModel, onDeleteModel) => [
|
|
24495
|
+
{
|
|
24496
|
+
key: "title",
|
|
24497
|
+
label: "T\xEDtulo",
|
|
24498
|
+
sortable: true,
|
|
24499
|
+
className: "max-w-[400px]",
|
|
24500
|
+
render: (value) => {
|
|
24501
|
+
const title = typeof value === "string" ? value : "";
|
|
24502
|
+
return /* @__PURE__ */ jsx100(Text_default, { size: "sm", title, className: "truncate block", children: title });
|
|
24503
|
+
}
|
|
24504
|
+
},
|
|
24505
|
+
{
|
|
24506
|
+
key: "savedAt",
|
|
24507
|
+
label: "Salvo em",
|
|
24508
|
+
sortable: true,
|
|
24509
|
+
className: "w-[120px]"
|
|
24510
|
+
},
|
|
24511
|
+
{
|
|
24512
|
+
key: "subject",
|
|
24513
|
+
label: "Mat\xE9ria",
|
|
24514
|
+
sortable: true,
|
|
24515
|
+
className: "max-w-[160px]",
|
|
24516
|
+
render: (value) => {
|
|
24517
|
+
const subjectName = typeof value === "string" ? value : "";
|
|
24518
|
+
return renderSubjectCell(subjectName, mapSubjectNameToEnum, true);
|
|
24519
|
+
}
|
|
24520
|
+
},
|
|
24521
|
+
{
|
|
24522
|
+
key: "actions",
|
|
24523
|
+
label: "",
|
|
24524
|
+
sortable: false,
|
|
24525
|
+
className: "w-[220px]",
|
|
24526
|
+
render: (_value, row) => {
|
|
24527
|
+
const handleSend = (e) => {
|
|
24528
|
+
e.stopPropagation();
|
|
24529
|
+
onSendActivity?.(row);
|
|
24530
|
+
};
|
|
24531
|
+
const handleEdit = (e) => {
|
|
24532
|
+
e.stopPropagation();
|
|
24533
|
+
onEditModel?.(row);
|
|
24534
|
+
};
|
|
24535
|
+
const handleDelete = (e) => {
|
|
24536
|
+
e.stopPropagation();
|
|
24537
|
+
onDeleteModel(row);
|
|
24538
|
+
};
|
|
24539
|
+
return /* @__PURE__ */ jsxs80("div", { className: "flex items-center gap-2 justify-end", children: [
|
|
24540
|
+
onSendActivity && /* @__PURE__ */ jsx100(
|
|
24541
|
+
Button_default,
|
|
24542
|
+
{
|
|
24543
|
+
variant: "outline",
|
|
24544
|
+
action: "primary",
|
|
24545
|
+
size: "small",
|
|
24546
|
+
iconLeft: /* @__PURE__ */ jsx100(PaperPlaneTilt3, { size: 16 }),
|
|
24547
|
+
onClick: handleSend,
|
|
24548
|
+
"aria-label": "Enviar atividade",
|
|
24549
|
+
children: "Enviar atividade"
|
|
24550
|
+
}
|
|
24551
|
+
),
|
|
24552
|
+
/* @__PURE__ */ jsx100(
|
|
24553
|
+
IconButton_default,
|
|
24554
|
+
{
|
|
24555
|
+
icon: /* @__PURE__ */ jsx100(Trash3, { size: 20 }),
|
|
24556
|
+
size: "md",
|
|
24557
|
+
onClick: handleDelete,
|
|
24558
|
+
"aria-label": "Deletar modelo",
|
|
24559
|
+
className: "text-text-600 hover:text-error-500 hover:bg-transparent"
|
|
24560
|
+
}
|
|
24561
|
+
),
|
|
24562
|
+
onEditModel && /* @__PURE__ */ jsx100(
|
|
24563
|
+
IconButton_default,
|
|
24564
|
+
{
|
|
24565
|
+
icon: /* @__PURE__ */ jsx100(PencilSimple3, { size: 20 }),
|
|
24566
|
+
size: "md",
|
|
24567
|
+
onClick: handleEdit,
|
|
24568
|
+
"aria-label": "Editar modelo",
|
|
24569
|
+
className: "text-text-600 hover:text-primary-700 hover:bg-transparent"
|
|
24570
|
+
}
|
|
24571
|
+
)
|
|
24572
|
+
] });
|
|
24573
|
+
}
|
|
24574
|
+
}
|
|
24575
|
+
];
|
|
24576
|
+
|
|
24577
|
+
// src/components/ActivitiesHistory/config/modelsFiltersConfig.ts
|
|
24578
|
+
var createModelsFiltersConfig = (userData) => [
|
|
24579
|
+
{
|
|
24580
|
+
key: "content",
|
|
24581
|
+
label: "CONTE\xDADO",
|
|
24582
|
+
categories: [
|
|
24583
|
+
{
|
|
24584
|
+
key: "subject",
|
|
24585
|
+
label: "Mat\xE9ria",
|
|
24586
|
+
selectedIds: [],
|
|
24587
|
+
itens: getSubjectOptions2(userData)
|
|
24588
|
+
}
|
|
24589
|
+
]
|
|
24590
|
+
}
|
|
24591
|
+
];
|
|
24592
|
+
|
|
24593
|
+
// src/hooks/useActivityModels.ts
|
|
24594
|
+
import { useState as useState47, useCallback as useCallback25 } from "react";
|
|
24595
|
+
import { z as z7 } from "zod";
|
|
24596
|
+
import dayjs5 from "dayjs";
|
|
24597
|
+
var activityDraftFiltersSchema = z7.object({
|
|
24598
|
+
questionTypes: z7.array(z7.string()).optional(),
|
|
24599
|
+
questionBanks: z7.array(z7.string()).optional(),
|
|
24600
|
+
subjects: z7.array(z7.string()).optional(),
|
|
24601
|
+
topics: z7.array(z7.string()).optional(),
|
|
24602
|
+
subtopics: z7.array(z7.string()).optional(),
|
|
24603
|
+
contents: z7.array(z7.string()).optional()
|
|
24604
|
+
}).nullable();
|
|
24605
|
+
var activityModelResponseSchema = z7.object({
|
|
24606
|
+
id: z7.string().uuid(),
|
|
24607
|
+
type: z7.nativeEnum(ActivityDraftType),
|
|
24608
|
+
title: z7.string().nullable(),
|
|
24609
|
+
creatorUserInstitutionId: z7.string().uuid().nullable(),
|
|
24610
|
+
subjectId: z7.string().uuid().nullable(),
|
|
24611
|
+
filters: activityDraftFiltersSchema,
|
|
24612
|
+
createdAt: z7.string(),
|
|
24613
|
+
updatedAt: z7.string()
|
|
24614
|
+
});
|
|
24615
|
+
var activityModelsApiResponseSchema = z7.object({
|
|
24616
|
+
message: z7.string(),
|
|
24617
|
+
data: z7.object({
|
|
24618
|
+
activityDrafts: z7.array(activityModelResponseSchema),
|
|
24619
|
+
total: z7.number()
|
|
24620
|
+
})
|
|
24621
|
+
});
|
|
24622
|
+
var DEFAULT_MODELS_PAGINATION = {
|
|
24623
|
+
total: 0,
|
|
24624
|
+
page: 1,
|
|
24625
|
+
limit: 10,
|
|
24626
|
+
totalPages: 0
|
|
24627
|
+
};
|
|
24628
|
+
var transformModelToTableItem = (model, subjectsMap) => {
|
|
24629
|
+
const subjectName = model.subjectId ? subjectsMap?.get(model.subjectId) || "" : "";
|
|
24630
|
+
return {
|
|
24631
|
+
id: model.id,
|
|
24632
|
+
title: model.title || "Sem t\xEDtulo",
|
|
24633
|
+
savedAt: dayjs5(model.createdAt).format("DD/MM/YYYY"),
|
|
24634
|
+
subject: subjectName,
|
|
24635
|
+
subjectId: model.subjectId
|
|
24636
|
+
};
|
|
24637
|
+
};
|
|
24638
|
+
var handleModelFetchError = createFetchErrorHandler(
|
|
24639
|
+
"Erro ao validar dados de modelos de atividades",
|
|
24640
|
+
"Erro ao carregar modelos de atividades"
|
|
24641
|
+
);
|
|
24642
|
+
var createUseActivityModels = (fetchActivityModels, deleteActivityModel) => {
|
|
24643
|
+
return () => {
|
|
24644
|
+
const [state, setState] = useState47({
|
|
24645
|
+
models: [],
|
|
24646
|
+
loading: false,
|
|
24647
|
+
error: null,
|
|
24648
|
+
pagination: DEFAULT_MODELS_PAGINATION
|
|
24649
|
+
});
|
|
24650
|
+
const fetchModels = useCallback25(
|
|
24651
|
+
async (filters, subjectsMap) => {
|
|
24652
|
+
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
24653
|
+
try {
|
|
24654
|
+
const responseData = await fetchActivityModels(filters);
|
|
24655
|
+
const validatedData = activityModelsApiResponseSchema.parse(responseData);
|
|
24656
|
+
const tableItems = validatedData.data.activityDrafts.map(
|
|
24657
|
+
(model) => transformModelToTableItem(model, subjectsMap)
|
|
24658
|
+
);
|
|
24659
|
+
const limit = filters?.limit || 10;
|
|
24660
|
+
const page = filters?.page || 1;
|
|
24661
|
+
const total = validatedData.data.total;
|
|
24662
|
+
const totalPages = Math.ceil(total / limit);
|
|
24663
|
+
setState({
|
|
24664
|
+
models: tableItems,
|
|
24665
|
+
loading: false,
|
|
24666
|
+
error: null,
|
|
24667
|
+
pagination: {
|
|
24668
|
+
total,
|
|
24669
|
+
page,
|
|
24670
|
+
limit,
|
|
24671
|
+
totalPages
|
|
24672
|
+
}
|
|
24673
|
+
});
|
|
24674
|
+
} catch (error) {
|
|
24675
|
+
const errorMessage = handleModelFetchError(error);
|
|
24676
|
+
setState((prev) => ({
|
|
24677
|
+
...prev,
|
|
24678
|
+
loading: false,
|
|
24679
|
+
error: errorMessage
|
|
24680
|
+
}));
|
|
24681
|
+
}
|
|
24682
|
+
},
|
|
24683
|
+
[fetchActivityModels]
|
|
24684
|
+
);
|
|
24685
|
+
const deleteModel = useCallback25(
|
|
24686
|
+
async (id) => {
|
|
24687
|
+
try {
|
|
24688
|
+
await deleteActivityModel(id);
|
|
24689
|
+
return true;
|
|
24690
|
+
} catch (error) {
|
|
24691
|
+
console.error("Erro ao deletar modelo:", error);
|
|
24692
|
+
return false;
|
|
24693
|
+
}
|
|
24694
|
+
},
|
|
24695
|
+
[deleteActivityModel]
|
|
24696
|
+
);
|
|
24697
|
+
return {
|
|
24698
|
+
...state,
|
|
24699
|
+
fetchModels,
|
|
24700
|
+
deleteModel
|
|
24701
|
+
};
|
|
24702
|
+
};
|
|
24703
|
+
};
|
|
24704
|
+
var createActivityModelsHook = createUseActivityModels;
|
|
24705
|
+
|
|
24706
|
+
// src/components/ActivitiesHistory/tabs/ModelsTab.tsx
|
|
24707
|
+
import { Fragment as Fragment23, jsx as jsx101, jsxs as jsxs81 } from "react/jsx-runtime";
|
|
24708
|
+
var ModelsTab = ({
|
|
24709
|
+
fetchActivityModels,
|
|
24710
|
+
deleteActivityModel,
|
|
24711
|
+
onCreateModel,
|
|
24712
|
+
onSendActivity,
|
|
24713
|
+
onEditModel,
|
|
24714
|
+
emptyStateImage,
|
|
24715
|
+
noSearchImage,
|
|
24716
|
+
mapSubjectNameToEnum,
|
|
24717
|
+
userFilterData,
|
|
24718
|
+
subjectsMap
|
|
24719
|
+
}) => {
|
|
24720
|
+
const [deleteDialogOpen, setDeleteDialogOpen] = useState48(false);
|
|
24721
|
+
const [modelToDelete, setModelToDelete] = useState48(null);
|
|
24722
|
+
const { addToast } = useToast();
|
|
24723
|
+
const fetchActivityModelsRef = useRef27(fetchActivityModels);
|
|
24724
|
+
fetchActivityModelsRef.current = fetchActivityModels;
|
|
24725
|
+
const deleteActivityModelRef = useRef27(deleteActivityModel);
|
|
24726
|
+
deleteActivityModelRef.current = deleteActivityModel;
|
|
24727
|
+
const subjectsMapRef = useRef27(subjectsMap);
|
|
24728
|
+
subjectsMapRef.current = subjectsMap;
|
|
24729
|
+
const useActivityModels = useMemo29(
|
|
24730
|
+
() => createUseActivityModels(
|
|
24731
|
+
(filters) => fetchActivityModelsRef.current(filters),
|
|
24732
|
+
(id) => deleteActivityModelRef.current(id)
|
|
24733
|
+
),
|
|
24734
|
+
[]
|
|
24735
|
+
);
|
|
24736
|
+
const {
|
|
24737
|
+
models,
|
|
24738
|
+
loading: modelsLoading,
|
|
24739
|
+
error: modelsError,
|
|
24740
|
+
pagination: modelsPagination,
|
|
24741
|
+
fetchModels,
|
|
24742
|
+
deleteModel
|
|
24743
|
+
} = useActivityModels();
|
|
24744
|
+
const modelsFilterConfigs = useMemo29(
|
|
24745
|
+
() => createModelsFiltersConfig(userFilterData),
|
|
24746
|
+
[userFilterData]
|
|
24747
|
+
);
|
|
24748
|
+
const handleDeleteClick = useCallback26((model) => {
|
|
24749
|
+
setModelToDelete(model);
|
|
24750
|
+
setDeleteDialogOpen(true);
|
|
24751
|
+
}, []);
|
|
24752
|
+
const modelsTableColumns = useMemo29(
|
|
24753
|
+
() => createModelsTableColumns(
|
|
24754
|
+
mapSubjectNameToEnum,
|
|
24755
|
+
onSendActivity,
|
|
24756
|
+
onEditModel,
|
|
24757
|
+
handleDeleteClick
|
|
24758
|
+
),
|
|
24759
|
+
[mapSubjectNameToEnum, onSendActivity, onEditModel, handleDeleteClick]
|
|
24760
|
+
);
|
|
24761
|
+
const handleParamsChange = useCallback26(
|
|
24762
|
+
(params) => {
|
|
24763
|
+
const filters = buildModelsFiltersFromParams(params);
|
|
24764
|
+
fetchModels(filters, subjectsMapRef.current);
|
|
24765
|
+
},
|
|
24766
|
+
[fetchModels]
|
|
24767
|
+
);
|
|
24768
|
+
useEffect45(() => {
|
|
24769
|
+
fetchModels({ page: 1, limit: 10 }, subjectsMapRef.current);
|
|
24770
|
+
}, [fetchModels]);
|
|
24771
|
+
const handleConfirmDelete = useCallback26(async () => {
|
|
24772
|
+
if (modelToDelete) {
|
|
24773
|
+
const success = await deleteModel(modelToDelete.id);
|
|
24774
|
+
if (success) {
|
|
24775
|
+
addToast({ title: "Modelo deletado com sucesso", action: "success" });
|
|
24776
|
+
fetchModels({ page: 1, limit: 10 }, subjectsMapRef.current);
|
|
24777
|
+
} else {
|
|
24778
|
+
addToast({ title: "Erro ao deletar modelo", action: "warning" });
|
|
24779
|
+
}
|
|
24780
|
+
}
|
|
24781
|
+
setDeleteDialogOpen(false);
|
|
24782
|
+
setModelToDelete(null);
|
|
24783
|
+
}, [modelToDelete, deleteModel, fetchModels, addToast]);
|
|
24784
|
+
const handleCancelDelete = useCallback26(() => {
|
|
24785
|
+
setDeleteDialogOpen(false);
|
|
24786
|
+
setModelToDelete(null);
|
|
24787
|
+
}, []);
|
|
24788
|
+
return /* @__PURE__ */ jsxs81(Fragment23, { children: [
|
|
24789
|
+
/* @__PURE__ */ jsx101(Toaster_default, {}),
|
|
24790
|
+
modelsError ? /* @__PURE__ */ jsx101(ErrorDisplay, { error: modelsError }) : /* @__PURE__ */ jsx101("div", { className: "w-full", "data-testid": "activity-models-tab", children: /* @__PURE__ */ jsx101(
|
|
24791
|
+
TableProvider,
|
|
24792
|
+
{
|
|
24793
|
+
data: models,
|
|
24794
|
+
headers: modelsTableColumns,
|
|
24795
|
+
loading: modelsLoading,
|
|
24796
|
+
variant: "borderless",
|
|
24797
|
+
enableSearch: true,
|
|
24798
|
+
enableFilters: true,
|
|
24799
|
+
enableTableSort: true,
|
|
24800
|
+
enablePagination: true,
|
|
24801
|
+
initialFilters: modelsFilterConfigs,
|
|
24802
|
+
paginationConfig: {
|
|
24803
|
+
itemLabel: "modelos",
|
|
24804
|
+
itemsPerPageOptions: [10, 20, 50, 100],
|
|
24805
|
+
defaultItemsPerPage: 10,
|
|
24806
|
+
totalItems: modelsPagination.total,
|
|
24807
|
+
totalPages: modelsPagination.totalPages
|
|
24808
|
+
},
|
|
24809
|
+
searchPlaceholder: "Buscar modelo",
|
|
24810
|
+
noSearchResultState: {
|
|
24811
|
+
image: noSearchImage
|
|
24812
|
+
},
|
|
24813
|
+
emptyState: {
|
|
24814
|
+
component: /* @__PURE__ */ jsx101(
|
|
24815
|
+
EmptyState_default,
|
|
24816
|
+
{
|
|
24817
|
+
image: emptyStateImage,
|
|
24818
|
+
title: "Crie modelos para agilizar suas atividades",
|
|
24819
|
+
description: "Salve modelos de atividades para reutilizar e enviar rapidamente para suas turmas!",
|
|
24820
|
+
buttonText: "Criar modelo",
|
|
24821
|
+
buttonIcon: /* @__PURE__ */ jsx101(Plus5, { size: 18 }),
|
|
24822
|
+
buttonVariant: "outline",
|
|
24823
|
+
buttonAction: "primary",
|
|
24824
|
+
onButtonClick: onCreateModel
|
|
24825
|
+
}
|
|
24826
|
+
)
|
|
24827
|
+
},
|
|
24828
|
+
onParamsChange: handleParamsChange,
|
|
24829
|
+
children: (renderProps) => {
|
|
24830
|
+
const {
|
|
24831
|
+
controls,
|
|
24832
|
+
table,
|
|
24833
|
+
pagination: paginationComponent
|
|
24834
|
+
} = renderProps;
|
|
24835
|
+
return /* @__PURE__ */ jsxs81("div", { className: "space-y-4", children: [
|
|
24836
|
+
/* @__PURE__ */ jsxs81("div", { className: "flex items-center justify-between gap-4", children: [
|
|
24837
|
+
/* @__PURE__ */ jsx101(
|
|
24838
|
+
Button_default,
|
|
24839
|
+
{
|
|
24840
|
+
variant: "solid",
|
|
24841
|
+
action: "primary",
|
|
24842
|
+
size: "medium",
|
|
24843
|
+
onClick: onCreateModel,
|
|
24844
|
+
iconLeft: /* @__PURE__ */ jsx101(Plus5, { size: 18, weight: "bold" }),
|
|
24845
|
+
children: "Criar modelo"
|
|
24846
|
+
}
|
|
24847
|
+
),
|
|
24848
|
+
controls
|
|
24849
|
+
] }),
|
|
24850
|
+
/* @__PURE__ */ jsxs81("div", { className: "bg-background rounded-xl p-6 space-y-4", children: [
|
|
24851
|
+
table,
|
|
24852
|
+
paginationComponent
|
|
24853
|
+
] })
|
|
24854
|
+
] });
|
|
24855
|
+
}
|
|
24856
|
+
}
|
|
24857
|
+
) }),
|
|
24858
|
+
/* @__PURE__ */ jsx101(
|
|
24859
|
+
AlertDialog,
|
|
24860
|
+
{
|
|
24861
|
+
isOpen: deleteDialogOpen,
|
|
24862
|
+
onChangeOpen: setDeleteDialogOpen,
|
|
24863
|
+
title: "Deletar modelo",
|
|
24864
|
+
description: `Tem certeza que deseja deletar o modelo "${modelToDelete?.title}"? Esta a\xE7\xE3o n\xE3o pode ser desfeita.`,
|
|
24865
|
+
submitButtonLabel: "Deletar",
|
|
24866
|
+
cancelButtonLabel: "Cancelar",
|
|
24867
|
+
onSubmit: handleConfirmDelete,
|
|
24868
|
+
onCancel: handleCancelDelete
|
|
24869
|
+
}
|
|
24870
|
+
)
|
|
24871
|
+
] });
|
|
24872
|
+
};
|
|
24873
|
+
|
|
24874
|
+
// src/components/ActivitiesHistory/tabs/DraftsTab.tsx
|
|
24875
|
+
import { jsx as jsx102 } from "react/jsx-runtime";
|
|
24876
|
+
var DraftsTab = () => {
|
|
24877
|
+
return /* @__PURE__ */ jsx102("div", { className: "flex items-center justify-center bg-background rounded-xl w-full min-h-[705px]", children: /* @__PURE__ */ jsx102(Text_default, { size: "lg", color: "text-text-600", children: "Rascunhos em desenvolvimento" }) });
|
|
24878
|
+
};
|
|
24879
|
+
|
|
24880
|
+
// src/components/ActivitiesHistory/ActivitiesHistory.tsx
|
|
24881
|
+
import { jsx as jsx103, jsxs as jsxs82 } from "react/jsx-runtime";
|
|
24882
|
+
var PAGE_TITLES = {
|
|
24883
|
+
["history" /* HISTORY */]: "Hist\xF3rico de atividades",
|
|
24884
|
+
["drafts" /* DRAFTS */]: "Rascunhos",
|
|
24885
|
+
["models" /* MODELS */]: "Modelos de atividades"
|
|
24886
|
+
};
|
|
24887
|
+
var ActivitiesHistory = ({
|
|
24888
|
+
fetchActivitiesHistory,
|
|
24889
|
+
fetchActivityModels,
|
|
24890
|
+
deleteActivityModel,
|
|
24891
|
+
onCreateActivity,
|
|
24892
|
+
onCreateModel,
|
|
24893
|
+
onRowClick,
|
|
24894
|
+
onSendActivity,
|
|
24895
|
+
onEditModel,
|
|
24896
|
+
emptyStateImage,
|
|
24897
|
+
noSearchImage,
|
|
24898
|
+
mapSubjectNameToEnum,
|
|
24899
|
+
userFilterData,
|
|
24900
|
+
subjectsMap
|
|
24901
|
+
}) => {
|
|
24902
|
+
const [activeTab, setActiveTab] = useState49("history" /* HISTORY */);
|
|
24903
|
+
return /* @__PURE__ */ jsxs82(
|
|
24904
|
+
"div",
|
|
24905
|
+
{
|
|
24906
|
+
"data-testid": "activities-history",
|
|
24907
|
+
className: "flex flex-col w-full h-auto relative justify-center items-center mb-5 overflow-hidden",
|
|
24908
|
+
children: [
|
|
24909
|
+
/* @__PURE__ */ jsx103("span", { className: "absolute top-0 left-0 h-[150px] w-full z-0" }),
|
|
24910
|
+
/* @__PURE__ */ jsxs82("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: [
|
|
24911
|
+
/* @__PURE__ */ jsxs82("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: [
|
|
24912
|
+
/* @__PURE__ */ jsx103(
|
|
24913
|
+
Text_default,
|
|
24914
|
+
{
|
|
24915
|
+
as: "h1",
|
|
24916
|
+
weight: "bold",
|
|
24917
|
+
className: "leading-[28px] tracking-[0.2px] text-xl lg:text-2xl",
|
|
24918
|
+
children: PAGE_TITLES[activeTab]
|
|
24919
|
+
}
|
|
24920
|
+
),
|
|
24921
|
+
/* @__PURE__ */ jsx103("div", { className: "flex-shrink-0 lg:w-auto self-center sm:self-auto", children: /* @__PURE__ */ jsx103(
|
|
24922
|
+
Menu,
|
|
24923
|
+
{
|
|
24924
|
+
defaultValue: "history" /* HISTORY */,
|
|
24925
|
+
value: activeTab,
|
|
24926
|
+
onValueChange: (value) => setActiveTab(value),
|
|
24927
|
+
variant: "menu2",
|
|
24928
|
+
className: "bg-transparent shadow-none px-0",
|
|
24929
|
+
children: /* @__PURE__ */ jsxs82(
|
|
24930
|
+
MenuContent,
|
|
24931
|
+
{
|
|
24932
|
+
variant: "menu2",
|
|
24933
|
+
className: "w-full lg:w-auto max-w-full min-w-0",
|
|
24934
|
+
children: [
|
|
24935
|
+
/* @__PURE__ */ jsx103(
|
|
24936
|
+
MenuItem,
|
|
24937
|
+
{
|
|
24938
|
+
variant: "menu2",
|
|
24939
|
+
value: "history" /* HISTORY */,
|
|
24940
|
+
"data-testid": "menu-item-history",
|
|
24941
|
+
className: "whitespace-nowrap flex-1 lg:flex-none",
|
|
24942
|
+
children: "Hist\xF3rico"
|
|
24943
|
+
}
|
|
24944
|
+
),
|
|
24945
|
+
/* @__PURE__ */ jsx103(
|
|
24946
|
+
MenuItem,
|
|
24947
|
+
{
|
|
24948
|
+
variant: "menu2",
|
|
24949
|
+
value: "drafts" /* DRAFTS */,
|
|
24950
|
+
"data-testid": "menu-item-drafts",
|
|
24951
|
+
className: "whitespace-nowrap flex-1 lg:flex-none",
|
|
24952
|
+
children: "Rascunhos"
|
|
24953
|
+
}
|
|
24954
|
+
),
|
|
24955
|
+
/* @__PURE__ */ jsx103(
|
|
24956
|
+
MenuItem,
|
|
24957
|
+
{
|
|
24958
|
+
variant: "menu2",
|
|
24959
|
+
value: "models" /* MODELS */,
|
|
24960
|
+
"data-testid": "menu-item-models",
|
|
24961
|
+
className: "whitespace-nowrap flex-1 lg:flex-none",
|
|
24962
|
+
children: "Modelos"
|
|
24963
|
+
}
|
|
24964
|
+
)
|
|
24965
|
+
]
|
|
24966
|
+
}
|
|
24967
|
+
)
|
|
24968
|
+
}
|
|
24969
|
+
) })
|
|
24970
|
+
] }),
|
|
24971
|
+
/* @__PURE__ */ jsxs82("div", { className: "flex flex-col items-center w-full min-h-0 flex-1", children: [
|
|
24972
|
+
activeTab === "history" /* HISTORY */ && /* @__PURE__ */ jsx103(
|
|
24973
|
+
HistoryTab,
|
|
24974
|
+
{
|
|
24975
|
+
fetchActivitiesHistory,
|
|
24976
|
+
onCreateActivity,
|
|
24977
|
+
onRowClick,
|
|
24978
|
+
emptyStateImage,
|
|
24979
|
+
noSearchImage,
|
|
24980
|
+
mapSubjectNameToEnum,
|
|
24981
|
+
userFilterData
|
|
24982
|
+
}
|
|
24983
|
+
),
|
|
24984
|
+
activeTab === "drafts" /* DRAFTS */ && /* @__PURE__ */ jsx103(DraftsTab, {}),
|
|
24985
|
+
activeTab === "models" /* MODELS */ && /* @__PURE__ */ jsx103(
|
|
24986
|
+
ModelsTab,
|
|
24987
|
+
{
|
|
24988
|
+
fetchActivityModels,
|
|
24989
|
+
deleteActivityModel,
|
|
24990
|
+
onCreateModel,
|
|
24991
|
+
onSendActivity,
|
|
24992
|
+
onEditModel,
|
|
24993
|
+
emptyStateImage,
|
|
24994
|
+
noSearchImage,
|
|
24995
|
+
mapSubjectNameToEnum,
|
|
24996
|
+
userFilterData,
|
|
24997
|
+
subjectsMap
|
|
24998
|
+
}
|
|
24999
|
+
)
|
|
25000
|
+
] })
|
|
25001
|
+
] })
|
|
25002
|
+
]
|
|
25003
|
+
}
|
|
25004
|
+
);
|
|
25005
|
+
};
|
|
25006
|
+
|
|
25007
|
+
// src/hooks/useChat.ts
|
|
25008
|
+
import { useState as useState50, useEffect as useEffect46, useCallback as useCallback27, useRef as useRef28 } from "react";
|
|
25009
|
+
var WS_STATES = {
|
|
25010
|
+
CONNECTING: 0,
|
|
25011
|
+
OPEN: 1,
|
|
25012
|
+
CLOSING: 2,
|
|
25013
|
+
CLOSED: 3
|
|
25014
|
+
};
|
|
25015
|
+
function useChat({
|
|
25016
|
+
wsUrl,
|
|
25017
|
+
token,
|
|
25018
|
+
roomId,
|
|
25019
|
+
userId,
|
|
25020
|
+
onConnect,
|
|
25021
|
+
onDisconnect,
|
|
25022
|
+
onError,
|
|
25023
|
+
autoReconnect = true,
|
|
25024
|
+
reconnectInterval = 3e3,
|
|
25025
|
+
maxReconnectAttempts = 5
|
|
25026
|
+
}) {
|
|
25027
|
+
const [isConnected, setIsConnected] = useState50(false);
|
|
25028
|
+
const [messages, setMessages] = useState50([]);
|
|
25029
|
+
const [participants, setParticipants] = useState50([]);
|
|
25030
|
+
const [error, setError] = useState50(null);
|
|
25031
|
+
const wsRef = useRef28(null);
|
|
25032
|
+
const reconnectAttemptsRef = useRef28(0);
|
|
25033
|
+
const reconnectTimeoutRef = useRef28(
|
|
25034
|
+
null
|
|
25035
|
+
);
|
|
25036
|
+
const isManualDisconnectRef = useRef28(false);
|
|
25037
|
+
const sendWsMessage = useCallback27((message) => {
|
|
25038
|
+
if (wsRef.current?.readyState === WS_STATES.OPEN) {
|
|
25039
|
+
wsRef.current.send(JSON.stringify(message));
|
|
25040
|
+
}
|
|
25041
|
+
}, []);
|
|
25042
|
+
const sendMessage = useCallback27(
|
|
25043
|
+
(content) => {
|
|
25044
|
+
const trimmedContent = content.trim();
|
|
25045
|
+
if (!trimmedContent) return;
|
|
25046
|
+
sendWsMessage({
|
|
25047
|
+
type: "message",
|
|
25048
|
+
payload: { content: trimmedContent }
|
|
25049
|
+
});
|
|
25050
|
+
},
|
|
25051
|
+
[sendWsMessage]
|
|
25052
|
+
);
|
|
25053
|
+
const leave = useCallback27(() => {
|
|
25054
|
+
isManualDisconnectRef.current = true;
|
|
25055
|
+
sendWsMessage({ type: "leave" });
|
|
25056
|
+
wsRef.current?.close(1e3, "User left");
|
|
25057
|
+
}, [sendWsMessage]);
|
|
25058
|
+
const handleMessage = useCallback27(
|
|
25059
|
+
(event) => {
|
|
25060
|
+
try {
|
|
25061
|
+
const data = JSON.parse(event.data);
|
|
25062
|
+
switch (data.type) {
|
|
25063
|
+
case "history":
|
|
25064
|
+
if (data.payload.messages) {
|
|
25065
|
+
setMessages(data.payload.messages);
|
|
25066
|
+
}
|
|
25067
|
+
break;
|
|
25068
|
+
case "participants":
|
|
25069
|
+
if (data.payload.participants) {
|
|
25070
|
+
setParticipants(data.payload.participants);
|
|
25071
|
+
}
|
|
25072
|
+
break;
|
|
25073
|
+
case "new_message":
|
|
25074
|
+
if (data.payload.message) {
|
|
25075
|
+
setMessages((prev) => [...prev, data.payload.message]);
|
|
25076
|
+
}
|
|
25077
|
+
break;
|
|
25078
|
+
case "user_joined":
|
|
25079
|
+
if (data.payload.user) {
|
|
25080
|
+
const user = data.payload.user;
|
|
25081
|
+
setParticipants((prev) => {
|
|
25082
|
+
const exists = prev.some(
|
|
25083
|
+
(p) => p.userInstitutionId === user.userInstitutionId
|
|
25084
|
+
);
|
|
25085
|
+
if (exists) {
|
|
25086
|
+
return prev.map(
|
|
25087
|
+
(p) => p.userInstitutionId === user.userInstitutionId ? { ...p, isOnline: true } : p
|
|
25088
|
+
);
|
|
25089
|
+
}
|
|
25090
|
+
return [
|
|
25091
|
+
...prev,
|
|
25092
|
+
{
|
|
25093
|
+
userInstitutionId: user.userInstitutionId,
|
|
25094
|
+
name: user.name,
|
|
25095
|
+
photo: user.photo,
|
|
25096
|
+
role: user.role,
|
|
25097
|
+
isOnline: true
|
|
25098
|
+
}
|
|
25099
|
+
];
|
|
25100
|
+
});
|
|
25101
|
+
}
|
|
25102
|
+
break;
|
|
25103
|
+
case "user_left":
|
|
25104
|
+
if (data.payload.user) {
|
|
25105
|
+
const user = data.payload.user;
|
|
25106
|
+
setParticipants(
|
|
25107
|
+
(prev) => prev.map(
|
|
25108
|
+
(p) => p.userInstitutionId === user.userInstitutionId ? { ...p, isOnline: false } : p
|
|
25109
|
+
)
|
|
25110
|
+
);
|
|
25111
|
+
}
|
|
25112
|
+
break;
|
|
25113
|
+
case "error": {
|
|
25114
|
+
const errorMessage = data.payload.message_text || "Erro desconhecido";
|
|
25115
|
+
setError(new Error(errorMessage));
|
|
25116
|
+
onError?.(new Error(errorMessage));
|
|
25117
|
+
break;
|
|
25118
|
+
}
|
|
25119
|
+
}
|
|
25120
|
+
} catch (err) {
|
|
25121
|
+
console.error("Error parsing WebSocket message:", err);
|
|
25122
|
+
}
|
|
25123
|
+
},
|
|
25124
|
+
[onError]
|
|
25125
|
+
);
|
|
25126
|
+
const connect = useCallback27(() => {
|
|
25127
|
+
const url = new URL(wsUrl);
|
|
25128
|
+
url.searchParams.set("roomId", roomId);
|
|
25129
|
+
url.searchParams.set("token", token);
|
|
25130
|
+
if (wsRef.current) {
|
|
25131
|
+
wsRef.current.close();
|
|
25132
|
+
}
|
|
25133
|
+
const ws = new WebSocket(url.toString());
|
|
25134
|
+
wsRef.current = ws;
|
|
25135
|
+
ws.onopen = () => {
|
|
25136
|
+
setIsConnected(true);
|
|
25137
|
+
setError(null);
|
|
25138
|
+
reconnectAttemptsRef.current = 0;
|
|
25139
|
+
onConnect?.();
|
|
25140
|
+
};
|
|
25141
|
+
ws.onmessage = handleMessage;
|
|
25142
|
+
ws.onerror = () => {
|
|
25143
|
+
const error2 = new Error("Erro na conex\xE3o WebSocket");
|
|
25144
|
+
setError(error2);
|
|
25145
|
+
onError?.(error2);
|
|
25146
|
+
};
|
|
25147
|
+
ws.onclose = (event) => {
|
|
25148
|
+
setIsConnected(false);
|
|
25149
|
+
onDisconnect?.();
|
|
25150
|
+
if (autoReconnect && !isManualDisconnectRef.current && reconnectAttemptsRef.current < maxReconnectAttempts && event.code !== 4001 && // Unauthorized
|
|
25151
|
+
event.code !== 4002 && // Missing roomId
|
|
25152
|
+
event.code !== 4003) {
|
|
25153
|
+
reconnectAttemptsRef.current += 1;
|
|
25154
|
+
reconnectTimeoutRef.current = setTimeout(() => {
|
|
25155
|
+
connect();
|
|
25156
|
+
}, reconnectInterval);
|
|
25157
|
+
}
|
|
25158
|
+
};
|
|
25159
|
+
}, [
|
|
25160
|
+
wsUrl,
|
|
25161
|
+
roomId,
|
|
25162
|
+
token,
|
|
25163
|
+
handleMessage,
|
|
25164
|
+
onConnect,
|
|
25165
|
+
onDisconnect,
|
|
25166
|
+
onError,
|
|
25167
|
+
autoReconnect,
|
|
25168
|
+
reconnectInterval,
|
|
25169
|
+
maxReconnectAttempts
|
|
25170
|
+
]);
|
|
25171
|
+
const reconnect = useCallback27(() => {
|
|
25172
|
+
isManualDisconnectRef.current = false;
|
|
25173
|
+
reconnectAttemptsRef.current = 0;
|
|
25174
|
+
connect();
|
|
25175
|
+
}, [connect]);
|
|
25176
|
+
useEffect46(() => {
|
|
25177
|
+
isManualDisconnectRef.current = false;
|
|
25178
|
+
connect();
|
|
25179
|
+
return () => {
|
|
25180
|
+
isManualDisconnectRef.current = true;
|
|
25181
|
+
if (reconnectTimeoutRef.current) {
|
|
25182
|
+
clearTimeout(reconnectTimeoutRef.current);
|
|
25183
|
+
}
|
|
25184
|
+
wsRef.current?.close(1e3, "Component unmounted");
|
|
25185
|
+
};
|
|
25186
|
+
}, [connect]);
|
|
25187
|
+
return {
|
|
25188
|
+
isConnected,
|
|
25189
|
+
messages,
|
|
25190
|
+
participants,
|
|
25191
|
+
sendMessage,
|
|
25192
|
+
leave,
|
|
25193
|
+
error,
|
|
25194
|
+
reconnect,
|
|
25195
|
+
currentUserId: userId
|
|
25196
|
+
};
|
|
25197
|
+
}
|
|
25198
|
+
function createUseChat(baseWsUrl) {
|
|
25199
|
+
return (options) => useChat({ ...options, wsUrl: baseWsUrl });
|
|
25200
|
+
}
|
|
25201
|
+
|
|
25202
|
+
// src/hooks/useChatRooms.ts
|
|
25203
|
+
import { useState as useState51, useCallback as useCallback28 } from "react";
|
|
25204
|
+
function useChatRooms({
|
|
25205
|
+
apiClient
|
|
25206
|
+
}) {
|
|
25207
|
+
const [rooms, setRooms] = useState51([]);
|
|
25208
|
+
const [availableUsers, setAvailableUsers] = useState51([]);
|
|
25209
|
+
const [loading, setLoading] = useState51(false);
|
|
25210
|
+
const [error, setError] = useState51(null);
|
|
25211
|
+
const fetchRooms = useCallback28(async () => {
|
|
25212
|
+
setLoading(true);
|
|
25213
|
+
setError(null);
|
|
25214
|
+
try {
|
|
25215
|
+
const response = await apiClient.get("/chat/rooms");
|
|
25216
|
+
setRooms(response.data.rooms);
|
|
25217
|
+
} catch (err) {
|
|
25218
|
+
const error2 = err instanceof Error ? err : new Error("Erro ao carregar salas");
|
|
25219
|
+
setError(error2);
|
|
25220
|
+
console.error("Error fetching chat rooms:", err);
|
|
25221
|
+
} finally {
|
|
25222
|
+
setLoading(false);
|
|
25223
|
+
}
|
|
25224
|
+
}, [apiClient]);
|
|
25225
|
+
const fetchAvailableUsers = useCallback28(async () => {
|
|
25226
|
+
setLoading(true);
|
|
25227
|
+
setError(null);
|
|
25228
|
+
try {
|
|
25229
|
+
const response = await apiClient.get(
|
|
25230
|
+
"/chat/available-users"
|
|
25231
|
+
);
|
|
25232
|
+
setAvailableUsers(response.data.users);
|
|
25233
|
+
} catch (err) {
|
|
25234
|
+
const error2 = err instanceof Error ? err : new Error("Erro ao carregar usu\xE1rios");
|
|
25235
|
+
setError(error2);
|
|
25236
|
+
console.error("Error fetching available users:", err);
|
|
25237
|
+
} finally {
|
|
25238
|
+
setLoading(false);
|
|
25239
|
+
}
|
|
25240
|
+
}, [apiClient]);
|
|
25241
|
+
const createRoom = useCallback28(
|
|
25242
|
+
async (participantIds) => {
|
|
25243
|
+
setLoading(true);
|
|
25244
|
+
setError(null);
|
|
25245
|
+
try {
|
|
25246
|
+
const response = await apiClient.post(
|
|
25247
|
+
"/chat/rooms",
|
|
25248
|
+
{
|
|
25249
|
+
participantIds
|
|
25250
|
+
}
|
|
25251
|
+
);
|
|
25252
|
+
await fetchRooms();
|
|
25253
|
+
return response.data.room;
|
|
25254
|
+
} catch (err) {
|
|
25255
|
+
const error2 = err instanceof Error ? err : new Error("Erro ao criar sala");
|
|
25256
|
+
setError(error2);
|
|
25257
|
+
console.error("Error creating chat room:", err);
|
|
25258
|
+
return null;
|
|
25259
|
+
} finally {
|
|
25260
|
+
setLoading(false);
|
|
25261
|
+
}
|
|
25262
|
+
},
|
|
25263
|
+
[apiClient, fetchRooms]
|
|
25264
|
+
);
|
|
25265
|
+
const clearError = useCallback28(() => {
|
|
25266
|
+
setError(null);
|
|
25267
|
+
}, []);
|
|
25268
|
+
return {
|
|
25269
|
+
rooms,
|
|
25270
|
+
availableUsers,
|
|
25271
|
+
loading,
|
|
25272
|
+
error,
|
|
25273
|
+
fetchRooms,
|
|
25274
|
+
fetchAvailableUsers,
|
|
25275
|
+
createRoom,
|
|
25276
|
+
clearError
|
|
25277
|
+
};
|
|
25278
|
+
}
|
|
25279
|
+
function createUseChatRooms(apiClient) {
|
|
25280
|
+
return () => useChatRooms({ apiClient });
|
|
25281
|
+
}
|
|
25282
|
+
|
|
25283
|
+
// src/types/chat.ts
|
|
25284
|
+
var PROFILE_ROLES = /* @__PURE__ */ ((PROFILE_ROLES2) => {
|
|
25285
|
+
PROFILE_ROLES2["SUPER_ADMIN"] = "SUPER_ADMIN";
|
|
25286
|
+
PROFILE_ROLES2["GENERAL_MANAGER"] = "GENERAL_MANAGER";
|
|
25287
|
+
PROFILE_ROLES2["REGIONAL_MANAGER"] = "REGIONAL_MANAGER";
|
|
25288
|
+
PROFILE_ROLES2["UNIT_MANAGER"] = "UNIT_MANAGER";
|
|
25289
|
+
PROFILE_ROLES2["TEACHER"] = "TEACHER";
|
|
25290
|
+
PROFILE_ROLES2["STUDENT"] = "STUDENT";
|
|
25291
|
+
return PROFILE_ROLES2;
|
|
25292
|
+
})(PROFILE_ROLES || {});
|
|
25293
|
+
var CHAT_MESSAGE_TYPES = {
|
|
25294
|
+
TEXT: "text",
|
|
25295
|
+
SYSTEM: "system"
|
|
25296
|
+
};
|
|
25297
|
+
|
|
25298
|
+
// src/components/Chat/Chat.tsx
|
|
25299
|
+
import { useState as useState52, useEffect as useEffect47, useCallback as useCallback29 } from "react";
|
|
25300
|
+
import {
|
|
25301
|
+
PaperPlaneTiltIcon as PaperPlaneTiltIcon2,
|
|
25302
|
+
XIcon,
|
|
25303
|
+
PlusIcon,
|
|
25304
|
+
UsersIcon
|
|
25305
|
+
} from "@phosphor-icons/react";
|
|
25306
|
+
import { jsx as jsx104, jsxs as jsxs83 } from "react/jsx-runtime";
|
|
25307
|
+
var RoomItem = ({
|
|
25308
|
+
room,
|
|
25309
|
+
onClick,
|
|
25310
|
+
isActive
|
|
25311
|
+
}) => /* @__PURE__ */ jsx104(
|
|
25312
|
+
Button_default,
|
|
25313
|
+
{
|
|
25314
|
+
variant: "link",
|
|
25315
|
+
onClick,
|
|
25316
|
+
className: cn(
|
|
25317
|
+
"w-full p-3 rounded-lg text-left transition-colors justify-start h-auto",
|
|
25318
|
+
"hover:bg-background-100",
|
|
25319
|
+
isActive && "bg-primary-50 border-l-4 border-primary-500"
|
|
25320
|
+
),
|
|
25321
|
+
children: /* @__PURE__ */ jsxs83("div", { className: "flex items-start gap-3 w-full", children: [
|
|
25322
|
+
/* @__PURE__ */ jsx104("div", { className: "w-10 h-10 rounded-full bg-primary-100 flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsx104(UsersIcon, { size: 20, className: "text-primary-600" }) }),
|
|
25323
|
+
/* @__PURE__ */ jsxs83("div", { className: "flex-1 min-w-0", children: [
|
|
25324
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "sm", weight: "semibold", className: "text-text-900 truncate", children: room.name }),
|
|
25325
|
+
room.lastMessage && /* @__PURE__ */ jsxs83(Text_default, { size: "xs", className: "text-text-500 truncate mt-1", children: [
|
|
25326
|
+
room.lastMessage.senderName,
|
|
25327
|
+
": ",
|
|
25328
|
+
room.lastMessage.content
|
|
25329
|
+
] }),
|
|
25330
|
+
/* @__PURE__ */ jsxs83(Text_default, { size: "xs", className: "text-text-400 mt-1", children: [
|
|
25331
|
+
room.participantCount,
|
|
25332
|
+
" participantes"
|
|
25333
|
+
] })
|
|
25334
|
+
] })
|
|
25335
|
+
] })
|
|
25336
|
+
}
|
|
25337
|
+
);
|
|
25338
|
+
var MessageBubble = ({
|
|
25339
|
+
message,
|
|
25340
|
+
isOwn
|
|
25341
|
+
}) => /* @__PURE__ */ jsxs83("div", { className: cn("flex gap-2 mb-3", isOwn && "flex-row-reverse"), children: [
|
|
25342
|
+
!isOwn && /* @__PURE__ */ jsx104("div", { className: "w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center flex-shrink-0", children: message.senderPhoto ? /* @__PURE__ */ jsx104(
|
|
25343
|
+
"img",
|
|
25344
|
+
{
|
|
25345
|
+
src: message.senderPhoto,
|
|
25346
|
+
alt: message.senderName,
|
|
25347
|
+
className: "w-8 h-8 rounded-full object-cover"
|
|
25348
|
+
}
|
|
25349
|
+
) : /* @__PURE__ */ jsx104(Text_default, { size: "xs", weight: "bold", className: "text-gray-600", children: message.senderName.charAt(0).toUpperCase() }) }),
|
|
25350
|
+
/* @__PURE__ */ jsxs83("div", { className: cn("max-w-[70%]", isOwn && "items-end"), children: [
|
|
25351
|
+
!isOwn && /* @__PURE__ */ jsx104(Text_default, { size: "xs", className: "text-text-500 mb-1", children: message.senderName }),
|
|
25352
|
+
/* @__PURE__ */ jsx104(
|
|
25353
|
+
"div",
|
|
25354
|
+
{
|
|
25355
|
+
className: cn(
|
|
25356
|
+
"px-4 py-2 rounded-2xl",
|
|
25357
|
+
isOwn ? "bg-primary-500 text-white rounded-br-md" : "bg-background-100 text-text-900 rounded-bl-md"
|
|
25358
|
+
),
|
|
25359
|
+
children: /* @__PURE__ */ jsx104(Text_default, { size: "sm", children: message.content })
|
|
25360
|
+
}
|
|
25361
|
+
),
|
|
25362
|
+
/* @__PURE__ */ jsx104(
|
|
25363
|
+
Text_default,
|
|
25364
|
+
{
|
|
25365
|
+
size: "xs",
|
|
25366
|
+
className: cn("text-text-400 mt-1", isOwn && "text-right"),
|
|
25367
|
+
children: new Date(message.createdAt).toLocaleTimeString("pt-BR", {
|
|
25368
|
+
hour: "2-digit",
|
|
25369
|
+
minute: "2-digit"
|
|
25370
|
+
})
|
|
25371
|
+
}
|
|
25372
|
+
)
|
|
25373
|
+
] })
|
|
25374
|
+
] });
|
|
25375
|
+
var ParticipantItem = ({ participant }) => /* @__PURE__ */ jsxs83("div", { className: "flex items-center gap-2 py-2", children: [
|
|
25376
|
+
/* @__PURE__ */ jsxs83("div", { className: "relative", children: [
|
|
25377
|
+
/* @__PURE__ */ jsx104("div", { className: "w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center", children: participant.photo ? /* @__PURE__ */ jsx104(
|
|
25378
|
+
"img",
|
|
25379
|
+
{
|
|
25380
|
+
src: participant.photo,
|
|
25381
|
+
alt: participant.name,
|
|
25382
|
+
className: "w-8 h-8 rounded-full object-cover"
|
|
25383
|
+
}
|
|
25384
|
+
) : /* @__PURE__ */ jsx104(Text_default, { size: "xs", weight: "bold", className: "text-gray-600", children: participant.name.charAt(0).toUpperCase() }) }),
|
|
25385
|
+
participant.isOnline && /* @__PURE__ */ jsx104("div", { className: "absolute bottom-0 right-0 w-3 h-3 bg-green-500 rounded-full border-2 border-white" })
|
|
25386
|
+
] }),
|
|
25387
|
+
/* @__PURE__ */ jsxs83("div", { className: "flex-1 min-w-0", children: [
|
|
25388
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "sm", className: "text-text-900 truncate", children: participant.name }),
|
|
25389
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "xs", className: "text-text-500", children: participant.role })
|
|
25390
|
+
] })
|
|
25391
|
+
] });
|
|
25392
|
+
var UserSelector = ({
|
|
25393
|
+
users,
|
|
25394
|
+
selectedIds,
|
|
25395
|
+
onToggle
|
|
25396
|
+
}) => /* @__PURE__ */ jsx104("div", { className: "space-y-2 max-h-64 overflow-y-auto", children: users.map((user) => /* @__PURE__ */ jsxs83(
|
|
25397
|
+
Button_default,
|
|
25398
|
+
{
|
|
25399
|
+
variant: "link",
|
|
25400
|
+
onClick: () => onToggle(user.userInstitutionId),
|
|
25401
|
+
className: cn(
|
|
25402
|
+
"w-full flex items-center gap-3 p-3 rounded-lg transition-colors justify-start h-auto",
|
|
25403
|
+
selectedIds.has(user.userInstitutionId) ? "bg-primary-50 border border-primary-500" : "bg-background-50 hover:bg-background-100 border border-transparent"
|
|
25404
|
+
),
|
|
25405
|
+
children: [
|
|
25406
|
+
/* @__PURE__ */ jsx104("div", { className: "w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center", children: user.photo ? /* @__PURE__ */ jsx104(
|
|
25407
|
+
"img",
|
|
25408
|
+
{
|
|
25409
|
+
src: user.photo,
|
|
25410
|
+
alt: user.name,
|
|
25411
|
+
className: "w-10 h-10 rounded-full object-cover"
|
|
25412
|
+
}
|
|
25413
|
+
) : /* @__PURE__ */ jsx104(Text_default, { size: "sm", weight: "bold", className: "text-gray-600", children: user.name.charAt(0).toUpperCase() }) }),
|
|
25414
|
+
/* @__PURE__ */ jsxs83("div", { className: "flex-1 text-left", children: [
|
|
25415
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "sm", weight: "medium", className: "text-text-900", children: user.name }),
|
|
25416
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "xs", className: "text-text-500", children: user.profileName })
|
|
25417
|
+
] }),
|
|
25418
|
+
/* @__PURE__ */ jsx104(
|
|
25419
|
+
"div",
|
|
25420
|
+
{
|
|
25421
|
+
className: cn(
|
|
25422
|
+
"w-5 h-5 rounded-full border-2 flex items-center justify-center",
|
|
25423
|
+
selectedIds.has(user.userInstitutionId) ? "bg-primary-500 border-primary-500" : "border-gray-300"
|
|
25424
|
+
),
|
|
25425
|
+
children: selectedIds.has(user.userInstitutionId) && /* @__PURE__ */ jsx104("div", { className: "w-2 h-2 bg-white rounded-full" })
|
|
25426
|
+
}
|
|
25427
|
+
)
|
|
25428
|
+
]
|
|
25429
|
+
},
|
|
25430
|
+
user.userInstitutionId
|
|
25431
|
+
)) });
|
|
25432
|
+
function Chat({
|
|
25433
|
+
apiClient,
|
|
25434
|
+
wsUrl,
|
|
25435
|
+
token,
|
|
25436
|
+
userId,
|
|
25437
|
+
userName,
|
|
25438
|
+
userPhoto,
|
|
25439
|
+
userRole,
|
|
25440
|
+
className
|
|
25441
|
+
}) {
|
|
25442
|
+
const [view, setView] = useState52("list");
|
|
25443
|
+
const [selectedRoom, setSelectedRoom] = useState52(
|
|
25444
|
+
null
|
|
25445
|
+
);
|
|
25446
|
+
const [selectedUserIds, setSelectedUserIds] = useState52(
|
|
25447
|
+
/* @__PURE__ */ new Set()
|
|
25448
|
+
);
|
|
25449
|
+
const [messageInput, setMessageInput] = useState52("");
|
|
25450
|
+
const [showCreateModal, setShowCreateModal] = useState52(false);
|
|
25451
|
+
const {
|
|
25452
|
+
rooms,
|
|
25453
|
+
availableUsers,
|
|
25454
|
+
loading: roomsLoading,
|
|
25455
|
+
error: roomsError,
|
|
25456
|
+
fetchRooms,
|
|
25457
|
+
fetchAvailableUsers,
|
|
25458
|
+
createRoom
|
|
25459
|
+
} = useChatRooms({ apiClient });
|
|
25460
|
+
const {
|
|
25461
|
+
isConnected,
|
|
25462
|
+
messages,
|
|
25463
|
+
participants,
|
|
25464
|
+
sendMessage,
|
|
25465
|
+
error: chatError
|
|
25466
|
+
} = useChat({
|
|
25467
|
+
wsUrl,
|
|
25468
|
+
token,
|
|
25469
|
+
roomId: selectedRoom?.id || "",
|
|
25470
|
+
userId,
|
|
25471
|
+
onConnect: () => console.log("Connected to chat"),
|
|
25472
|
+
onDisconnect: () => console.log("Disconnected from chat"),
|
|
25473
|
+
onError: (err) => console.error("Chat error:", err)
|
|
25474
|
+
});
|
|
25475
|
+
const getRoleLabel = () => {
|
|
25476
|
+
return userRole === "TEACHER" /* TEACHER */ ? "Professor" : "Aluno";
|
|
25477
|
+
};
|
|
25478
|
+
useEffect47(() => {
|
|
25479
|
+
fetchRooms();
|
|
25480
|
+
}, [fetchRooms]);
|
|
25481
|
+
const handleSelectRoom = useCallback29((room) => {
|
|
25482
|
+
setSelectedRoom(room);
|
|
25483
|
+
setView("room");
|
|
25484
|
+
}, []);
|
|
25485
|
+
const handleOpenCreateModal = useCallback29(async () => {
|
|
25486
|
+
await fetchAvailableUsers();
|
|
25487
|
+
setSelectedUserIds(/* @__PURE__ */ new Set());
|
|
25488
|
+
setShowCreateModal(true);
|
|
25489
|
+
}, [fetchAvailableUsers]);
|
|
25490
|
+
const handleToggleUser = useCallback29((id) => {
|
|
25491
|
+
setSelectedUserIds((prev) => {
|
|
25492
|
+
const next = new Set(prev);
|
|
25493
|
+
if (next.has(id)) {
|
|
25494
|
+
next.delete(id);
|
|
25495
|
+
} else {
|
|
25496
|
+
next.add(id);
|
|
25497
|
+
}
|
|
25498
|
+
return next;
|
|
25499
|
+
});
|
|
25500
|
+
}, []);
|
|
25501
|
+
const handleCreateRoom = useCallback29(async () => {
|
|
25502
|
+
if (selectedUserIds.size === 0) return;
|
|
25503
|
+
const room = await createRoom(Array.from(selectedUserIds));
|
|
25504
|
+
if (room) {
|
|
25505
|
+
setShowCreateModal(false);
|
|
25506
|
+
setSelectedUserIds(/* @__PURE__ */ new Set());
|
|
25507
|
+
await fetchRooms();
|
|
25508
|
+
}
|
|
25509
|
+
}, [selectedUserIds, createRoom, fetchRooms]);
|
|
25510
|
+
const handleSendMessage = useCallback29(() => {
|
|
25511
|
+
if (!messageInput.trim()) return;
|
|
25512
|
+
sendMessage(messageInput);
|
|
25513
|
+
setMessageInput("");
|
|
25514
|
+
}, [messageInput, sendMessage]);
|
|
25515
|
+
const handleBackToList = useCallback29(() => {
|
|
25516
|
+
setSelectedRoom(null);
|
|
25517
|
+
setView("list");
|
|
25518
|
+
}, []);
|
|
25519
|
+
const renderMessagesContent = () => {
|
|
25520
|
+
if (chatError) {
|
|
25521
|
+
return /* @__PURE__ */ jsx104("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxs83("div", { className: "text-center", children: [
|
|
25522
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "sm", className: "text-red-500 mb-2", children: "Erro de conexao com o chat" }),
|
|
25523
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "xs", className: "text-text-500", children: "Tentando reconectar..." })
|
|
25524
|
+
] }) });
|
|
25525
|
+
}
|
|
25526
|
+
if (messages.length === 0) {
|
|
25527
|
+
return /* @__PURE__ */ jsx104("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsx104(Text_default, { size: "sm", className: "text-text-500", children: "Nenhuma mensagem ainda. Comece a conversa!" }) });
|
|
25528
|
+
}
|
|
25529
|
+
return messages.map((message) => /* @__PURE__ */ jsx104(
|
|
25530
|
+
MessageBubble,
|
|
25531
|
+
{
|
|
25532
|
+
message,
|
|
25533
|
+
isOwn: message.senderId === userId
|
|
25534
|
+
},
|
|
25535
|
+
message.id
|
|
25536
|
+
));
|
|
25537
|
+
};
|
|
25538
|
+
const renderRoomList = () => /* @__PURE__ */ jsxs83("div", { className: "flex flex-col h-full", children: [
|
|
25539
|
+
/* @__PURE__ */ jsxs83("div", { className: "p-4 border-b border-background-200 flex items-center justify-between", children: [
|
|
25540
|
+
/* @__PURE__ */ jsxs83("div", { className: "flex items-center gap-3", children: [
|
|
25541
|
+
/* @__PURE__ */ jsx104("div", { className: "w-10 h-10 rounded-full bg-primary-100 flex items-center justify-center flex-shrink-0", children: userPhoto ? /* @__PURE__ */ jsx104(
|
|
25542
|
+
"img",
|
|
25543
|
+
{
|
|
25544
|
+
src: userPhoto,
|
|
25545
|
+
alt: userName,
|
|
25546
|
+
className: "w-10 h-10 rounded-full object-cover"
|
|
25547
|
+
}
|
|
25548
|
+
) : /* @__PURE__ */ jsx104(Text_default, { size: "sm", weight: "bold", className: "text-primary-600", children: userName.charAt(0).toUpperCase() }) }),
|
|
25549
|
+
/* @__PURE__ */ jsxs83("div", { children: [
|
|
25550
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "lg", weight: "bold", className: "text-text-900", children: "Conversas" }),
|
|
25551
|
+
/* @__PURE__ */ jsxs83(Text_default, { size: "xs", className: "text-text-500", children: [
|
|
25552
|
+
userName,
|
|
25553
|
+
" - ",
|
|
25554
|
+
getRoleLabel()
|
|
25555
|
+
] })
|
|
25556
|
+
] })
|
|
25557
|
+
] }),
|
|
25558
|
+
/* @__PURE__ */ jsx104(
|
|
25559
|
+
Button_default,
|
|
25560
|
+
{
|
|
25561
|
+
variant: "solid",
|
|
25562
|
+
size: "small",
|
|
25563
|
+
onClick: handleOpenCreateModal,
|
|
25564
|
+
iconLeft: /* @__PURE__ */ jsx104(PlusIcon, { size: 16 }),
|
|
25565
|
+
children: "Nova conversa"
|
|
25566
|
+
}
|
|
25567
|
+
)
|
|
25568
|
+
] }),
|
|
25569
|
+
/* @__PURE__ */ jsxs83("div", { className: "flex-1 overflow-y-auto p-2", children: [
|
|
25570
|
+
roomsError && /* @__PURE__ */ jsxs83("div", { className: "p-4 text-center", children: [
|
|
25571
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "sm", className: "text-red-500 mb-2", children: "Erro ao carregar conversas" }),
|
|
25572
|
+
/* @__PURE__ */ jsx104(Button_default, { variant: "outline", size: "small", onClick: fetchRooms, children: "Tentar novamente" })
|
|
25573
|
+
] }),
|
|
25574
|
+
!roomsError && roomsLoading && /* @__PURE__ */ jsx104("div", { className: "space-y-3 p-2", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs83("div", { className: "flex items-center gap-3", children: [
|
|
25575
|
+
/* @__PURE__ */ jsx104(SkeletonRounded, { className: "w-10 h-10" }),
|
|
25576
|
+
/* @__PURE__ */ jsxs83("div", { className: "flex-1", children: [
|
|
25577
|
+
/* @__PURE__ */ jsx104(SkeletonText, { className: "w-3/4 h-4 mb-2" }),
|
|
25578
|
+
/* @__PURE__ */ jsx104(SkeletonText, { className: "w-1/2 h-3" })
|
|
25579
|
+
] })
|
|
25580
|
+
] }, i)) }),
|
|
25581
|
+
!roomsError && !roomsLoading && rooms.length === 0 && /* @__PURE__ */ jsx104(
|
|
25582
|
+
EmptyState_default,
|
|
25583
|
+
{
|
|
25584
|
+
title: "Nenhuma conversa",
|
|
25585
|
+
description: "Comece uma nova conversa clicando no botao acima"
|
|
25586
|
+
}
|
|
25587
|
+
),
|
|
25588
|
+
!roomsError && !roomsLoading && rooms.length > 0 && /* @__PURE__ */ jsx104("div", { className: "space-y-1", children: rooms.map((room) => /* @__PURE__ */ jsx104(
|
|
25589
|
+
RoomItem,
|
|
25590
|
+
{
|
|
25591
|
+
room,
|
|
25592
|
+
onClick: () => handleSelectRoom(room),
|
|
25593
|
+
isActive: selectedRoom?.id === room.id
|
|
25594
|
+
},
|
|
25595
|
+
room.id
|
|
25596
|
+
)) })
|
|
25597
|
+
] })
|
|
25598
|
+
] });
|
|
25599
|
+
const renderChatRoom = () => {
|
|
25600
|
+
if (!selectedRoom) return null;
|
|
25601
|
+
return /* @__PURE__ */ jsxs83("div", { className: "flex h-full", children: [
|
|
25602
|
+
/* @__PURE__ */ jsxs83("div", { className: "flex-1 flex flex-col", children: [
|
|
25603
|
+
/* @__PURE__ */ jsxs83("div", { className: "p-4 border-b border-background-200 flex items-center gap-3", children: [
|
|
25604
|
+
/* @__PURE__ */ jsx104(Button_default, { variant: "link", size: "small", onClick: handleBackToList, children: /* @__PURE__ */ jsx104(XIcon, { size: 20 }) }),
|
|
25605
|
+
/* @__PURE__ */ jsxs83("div", { className: "flex-1", children: [
|
|
25606
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "md", weight: "semibold", className: "text-text-900", children: selectedRoom.name }),
|
|
25607
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "xs", className: "text-text-500", children: isConnected ? "Conectado" : "Conectando..." })
|
|
25608
|
+
] })
|
|
25609
|
+
] }),
|
|
25610
|
+
/* @__PURE__ */ jsx104("div", { className: "flex-1 overflow-y-auto p-4", children: renderMessagesContent() }),
|
|
25611
|
+
/* @__PURE__ */ jsx104("div", { className: "p-4 border-t border-background-200", children: /* @__PURE__ */ jsxs83("div", { className: "flex gap-2", children: [
|
|
25612
|
+
/* @__PURE__ */ jsx104(
|
|
25613
|
+
Input_default,
|
|
25614
|
+
{
|
|
25615
|
+
placeholder: "Digite sua mensagem...",
|
|
25616
|
+
value: messageInput,
|
|
25617
|
+
onChange: (e) => setMessageInput(e.target.value),
|
|
25618
|
+
onKeyDown: (e) => {
|
|
25619
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
25620
|
+
e.preventDefault();
|
|
25621
|
+
handleSendMessage();
|
|
25622
|
+
}
|
|
25623
|
+
},
|
|
25624
|
+
className: "flex-1"
|
|
25625
|
+
}
|
|
25626
|
+
),
|
|
25627
|
+
/* @__PURE__ */ jsx104(
|
|
25628
|
+
Button_default,
|
|
25629
|
+
{
|
|
25630
|
+
variant: "solid",
|
|
25631
|
+
onClick: handleSendMessage,
|
|
25632
|
+
disabled: !messageInput.trim() || !isConnected,
|
|
25633
|
+
children: /* @__PURE__ */ jsx104(PaperPlaneTiltIcon2, { size: 20 })
|
|
25634
|
+
}
|
|
25635
|
+
)
|
|
25636
|
+
] }) })
|
|
25637
|
+
] }),
|
|
25638
|
+
/* @__PURE__ */ jsxs83("div", { className: "w-64 border-l border-background-200 p-4 hidden lg:block", children: [
|
|
25639
|
+
/* @__PURE__ */ jsxs83(Text_default, { size: "sm", weight: "semibold", className: "text-text-900 mb-3", children: [
|
|
25640
|
+
"Participantes (",
|
|
25641
|
+
participants.length,
|
|
25642
|
+
")"
|
|
25643
|
+
] }),
|
|
25644
|
+
/* @__PURE__ */ jsx104("div", { className: "space-y-1", children: participants.map((participant) => /* @__PURE__ */ jsx104(
|
|
25645
|
+
ParticipantItem,
|
|
25646
|
+
{
|
|
25647
|
+
participant
|
|
25648
|
+
},
|
|
25649
|
+
participant.userInstitutionId
|
|
25650
|
+
)) })
|
|
25651
|
+
] })
|
|
25652
|
+
] });
|
|
25653
|
+
};
|
|
25654
|
+
return /* @__PURE__ */ jsxs83(
|
|
25655
|
+
"div",
|
|
25656
|
+
{
|
|
25657
|
+
className: cn(
|
|
25658
|
+
"bg-background rounded-xl border border-background-200 h-[600px]",
|
|
25659
|
+
className
|
|
25660
|
+
),
|
|
25661
|
+
children: [
|
|
25662
|
+
view === "list" && renderRoomList(),
|
|
25663
|
+
view === "room" && renderChatRoom(),
|
|
25664
|
+
/* @__PURE__ */ jsx104(
|
|
25665
|
+
Modal_default,
|
|
25666
|
+
{
|
|
25667
|
+
isOpen: showCreateModal,
|
|
25668
|
+
onClose: () => setShowCreateModal(false),
|
|
25669
|
+
title: "Nova conversa",
|
|
25670
|
+
children: /* @__PURE__ */ jsxs83("div", { className: "p-4", children: [
|
|
25671
|
+
/* @__PURE__ */ jsx104(Text_default, { size: "sm", className: "text-text-600 mb-4", children: "Selecione os participantes para iniciar uma conversa" }),
|
|
25672
|
+
roomsLoading && /* @__PURE__ */ jsx104("div", { className: "space-y-3", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs83("div", { className: "flex items-center gap-3", children: [
|
|
25673
|
+
/* @__PURE__ */ jsx104(SkeletonRounded, { className: "w-10 h-10" }),
|
|
25674
|
+
/* @__PURE__ */ jsx104(SkeletonText, { className: "flex-1 h-4" })
|
|
25675
|
+
] }, i)) }),
|
|
25676
|
+
!roomsLoading && availableUsers.length === 0 && /* @__PURE__ */ jsx104(Text_default, { size: "sm", className: "text-text-500 text-center py-4", children: "Nenhum usuario disponivel para chat" }),
|
|
25677
|
+
!roomsLoading && availableUsers.length > 0 && /* @__PURE__ */ jsx104(
|
|
25678
|
+
UserSelector,
|
|
25679
|
+
{
|
|
25680
|
+
users: availableUsers,
|
|
25681
|
+
selectedIds: selectedUserIds,
|
|
25682
|
+
onToggle: handleToggleUser
|
|
25683
|
+
}
|
|
25684
|
+
),
|
|
25685
|
+
/* @__PURE__ */ jsxs83("div", { className: "flex justify-end gap-2 mt-6", children: [
|
|
25686
|
+
/* @__PURE__ */ jsx104(Button_default, { variant: "outline", onClick: () => setShowCreateModal(false), children: "Cancelar" }),
|
|
25687
|
+
/* @__PURE__ */ jsx104(
|
|
25688
|
+
Button_default,
|
|
25689
|
+
{
|
|
25690
|
+
variant: "solid",
|
|
25691
|
+
onClick: handleCreateRoom,
|
|
25692
|
+
disabled: selectedUserIds.size === 0 || roomsLoading,
|
|
25693
|
+
children: "Criar conversa"
|
|
25694
|
+
}
|
|
25695
|
+
)
|
|
25696
|
+
] })
|
|
25697
|
+
] })
|
|
25698
|
+
}
|
|
25699
|
+
)
|
|
25700
|
+
]
|
|
25701
|
+
}
|
|
25702
|
+
);
|
|
25703
|
+
}
|
|
24000
25704
|
export {
|
|
24001
25705
|
ACTIVITY_AVAILABILITY,
|
|
25706
|
+
ACTIVITY_FILTER_STATUS_OPTIONS,
|
|
24002
25707
|
ANSWER_STATUS,
|
|
24003
25708
|
AccordionGroup,
|
|
25709
|
+
ActivitiesHistory,
|
|
25710
|
+
GenericApiStatus as ActivityApiStatus,
|
|
25711
|
+
BadgeActionType as ActivityBadgeActionType,
|
|
24004
25712
|
ActivityCardQuestionBanks,
|
|
24005
25713
|
ActivityCardQuestionPreview,
|
|
24006
25714
|
ActivityDetails,
|
|
25715
|
+
GenericDisplayStatus as ActivityDisplayStatus,
|
|
25716
|
+
ActivityDraftType,
|
|
24007
25717
|
ActivityFilters,
|
|
24008
25718
|
ActivityFiltersPopover,
|
|
24009
25719
|
ActivityPreview,
|
|
@@ -24016,6 +25726,7 @@ export {
|
|
|
24016
25726
|
Badge_default as Badge,
|
|
24017
25727
|
BreadcrumbMenu,
|
|
24018
25728
|
Button_default as Button,
|
|
25729
|
+
CHAT_MESSAGE_TYPES,
|
|
24019
25730
|
QUESTION_STATUS2 as CORRECTION_QUESTION_STATUS,
|
|
24020
25731
|
Calendar_default as Calendar,
|
|
24021
25732
|
CardAccordation,
|
|
@@ -24030,6 +25741,7 @@ export {
|
|
|
24030
25741
|
CardStatus,
|
|
24031
25742
|
CardTest,
|
|
24032
25743
|
CardTopic,
|
|
25744
|
+
Chat,
|
|
24033
25745
|
CheckBox_default as CheckBox,
|
|
24034
25746
|
CheckboxGroup,
|
|
24035
25747
|
CheckboxList_default as CheckboxList,
|
|
@@ -24037,6 +25749,8 @@ export {
|
|
|
24037
25749
|
Chips_default as Chips,
|
|
24038
25750
|
CorrectActivityModal_default as CorrectActivityModal,
|
|
24039
25751
|
CreateActivity,
|
|
25752
|
+
DEFAULT_ACTIVITIES_PAGINATION,
|
|
25753
|
+
DEFAULT_MODELS_PAGINATION,
|
|
24040
25754
|
DIFFICULTY_LEVEL_ENUM,
|
|
24041
25755
|
DateTimeInput_default as DateTimeInput,
|
|
24042
25756
|
Divider_default as Divider,
|
|
@@ -24052,9 +25766,9 @@ export {
|
|
|
24052
25766
|
FilterModal,
|
|
24053
25767
|
GOAL_FILTER_STATUS_OPTIONS,
|
|
24054
25768
|
GOAL_STATUS_OPTIONS,
|
|
24055
|
-
GoalApiStatus,
|
|
24056
|
-
GoalBadgeActionType,
|
|
24057
|
-
GoalDisplayStatus,
|
|
25769
|
+
GenericApiStatus as GoalApiStatus,
|
|
25770
|
+
BadgeActionType as GoalBadgeActionType,
|
|
25771
|
+
GenericDisplayStatus as GoalDisplayStatus,
|
|
24058
25772
|
IconButton_default as IconButton,
|
|
24059
25773
|
IconRender_default as IconRender,
|
|
24060
25774
|
IconRoundedButton_default as IconRoundedButton,
|
|
@@ -24074,6 +25788,7 @@ export {
|
|
|
24074
25788
|
NotFound_default as NotFound,
|
|
24075
25789
|
NotificationCard_default as NotificationCard,
|
|
24076
25790
|
NotificationEntityType,
|
|
25791
|
+
PROFILE_ROLES,
|
|
24077
25792
|
ProfileMenuFooter,
|
|
24078
25793
|
ProfileMenuHeader,
|
|
24079
25794
|
ProfileMenuInfo,
|
|
@@ -24158,16 +25873,25 @@ export {
|
|
|
24158
25873
|
Toast_default as Toast,
|
|
24159
25874
|
Toaster_default as Toaster,
|
|
24160
25875
|
VideoPlayer_default as VideoPlayer,
|
|
25876
|
+
WS_STATES,
|
|
24161
25877
|
Whiteboard_default as Whiteboard,
|
|
25878
|
+
activitiesHistoryApiResponseSchema,
|
|
25879
|
+
activityModelsApiResponseSchema,
|
|
24162
25880
|
cn,
|
|
24163
25881
|
convertActivityFiltersToQuestionsFilter,
|
|
25882
|
+
createActivitiesHistoryHook,
|
|
24164
25883
|
createActivityFiltersDataHook,
|
|
25884
|
+
createActivityModelsHook,
|
|
24165
25885
|
createNotificationStore,
|
|
24166
25886
|
createNotificationsHook,
|
|
24167
25887
|
createQuestionsListHook,
|
|
24168
25888
|
createRecommendedLessonDetailsHook,
|
|
24169
25889
|
createRecommendedLessonsHistoryHook,
|
|
25890
|
+
createUseActivitiesHistory,
|
|
24170
25891
|
createUseActivityFiltersData,
|
|
25892
|
+
createUseActivityModels,
|
|
25893
|
+
createUseChat,
|
|
25894
|
+
createUseChatRooms,
|
|
24171
25895
|
createUseNotificationStore,
|
|
24172
25896
|
createUseNotifications,
|
|
24173
25897
|
createUseQuestionsList,
|
|
@@ -24183,6 +25907,7 @@ export {
|
|
|
24183
25907
|
formatTimeAgo,
|
|
24184
25908
|
formatTimeSpent,
|
|
24185
25909
|
generateFileId,
|
|
25910
|
+
getActivityStatusBadgeAction,
|
|
24186
25911
|
getCategoryIcon,
|
|
24187
25912
|
getCategoryText,
|
|
24188
25913
|
getDeviceType,
|
|
@@ -24203,12 +25928,15 @@ export {
|
|
|
24203
25928
|
goalApiResponseSchema,
|
|
24204
25929
|
goalDetailsApiResponseSchema,
|
|
24205
25930
|
goalsHistoryApiResponseSchema,
|
|
25931
|
+
handleActivityFetchError,
|
|
24206
25932
|
handleGoalFetchError,
|
|
24207
25933
|
handleLessonDetailsFetchError,
|
|
25934
|
+
handleModelFetchError,
|
|
24208
25935
|
historyApiResponseSchema,
|
|
24209
25936
|
isDeadlinePassed,
|
|
24210
25937
|
isFormValid,
|
|
24211
25938
|
isStepValid,
|
|
25939
|
+
mapActivityStatusToDisplay,
|
|
24212
25940
|
mapApiStatusToInternal,
|
|
24213
25941
|
mapInternalStatusToApi,
|
|
24214
25942
|
mapQuestionTypeToEnum,
|
|
@@ -24218,7 +25946,9 @@ export {
|
|
|
24218
25946
|
syncDropdownState,
|
|
24219
25947
|
toggleArrayItem,
|
|
24220
25948
|
toggleSingleValue,
|
|
25949
|
+
transformActivityToTableItem,
|
|
24221
25950
|
transformGoalToTableItem,
|
|
25951
|
+
transformModelToTableItem,
|
|
24222
25952
|
useAlertFormStore,
|
|
24223
25953
|
useApiConfig,
|
|
24224
25954
|
useAppContent,
|
|
@@ -24229,6 +25959,8 @@ export {
|
|
|
24229
25959
|
useAuthStore,
|
|
24230
25960
|
useBreadcrumb,
|
|
24231
25961
|
useBreadcrumbBuilder,
|
|
25962
|
+
useChat,
|
|
25963
|
+
useChatRooms,
|
|
24232
25964
|
useInstitutionId,
|
|
24233
25965
|
useMobile,
|
|
24234
25966
|
useQuestionFiltersStore,
|