analytica-frontend-lib 1.2.45 → 1.2.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/ActivityCardQuestionBanks/index.css +20 -0
  2. package/dist/ActivityCardQuestionBanks/index.css.map +1 -1
  3. package/dist/ActivityCardQuestionPreview/index.css +20 -0
  4. package/dist/ActivityCardQuestionPreview/index.css.map +1 -1
  5. package/dist/ActivityDetails/index.css +20 -0
  6. package/dist/ActivityDetails/index.css.map +1 -1
  7. package/dist/ActivityFilters/index.css +20 -0
  8. package/dist/ActivityFilters/index.css.map +1 -1
  9. package/dist/ActivityPreview/index.css +20 -0
  10. package/dist/ActivityPreview/index.css.map +1 -1
  11. package/dist/AlertManager/index.css +20 -0
  12. package/dist/AlertManager/index.css.map +1 -1
  13. package/dist/RecommendedLessonsHistory/index.css +19327 -0
  14. package/dist/RecommendedLessonsHistory/index.css.map +1 -0
  15. package/dist/RecommendedLessonsHistory/index.d.ts +2 -0
  16. package/dist/RecommendedLessonsHistory/index.d.ts.map +1 -0
  17. package/dist/RecommendedLessonsHistory/index.js +6775 -0
  18. package/dist/RecommendedLessonsHistory/index.js.map +1 -0
  19. package/dist/RecommendedLessonsHistory/index.mjs +6815 -0
  20. package/dist/RecommendedLessonsHistory/index.mjs.map +1 -0
  21. package/dist/SendActivityModal/index.css +20 -0
  22. package/dist/SendActivityModal/index.css.map +1 -1
  23. package/dist/SendActivityModal/index.js +16 -1
  24. package/dist/SendActivityModal/index.js.map +1 -1
  25. package/dist/SendActivityModal/index.mjs +16 -1
  26. package/dist/SendActivityModal/index.mjs.map +1 -1
  27. package/dist/TableProvider/index.css +20 -0
  28. package/dist/TableProvider/index.css.map +1 -1
  29. package/dist/hooks/useRecommendedLessons/index.d.ts +355 -0
  30. package/dist/hooks/useRecommendedLessons/index.d.ts.map +1 -0
  31. package/dist/hooks/useRecommendedLessons/index.js +195 -0
  32. package/dist/hooks/useRecommendedLessons/index.js.map +1 -0
  33. package/dist/hooks/useRecommendedLessons/index.mjs +155 -0
  34. package/dist/hooks/useRecommendedLessons/index.mjs.map +1 -0
  35. package/dist/hooks/useRecommendedLessons.d.ts +355 -0
  36. package/dist/hooks/useRecommendedLessons.d.ts.map +1 -0
  37. package/dist/index.css +20 -0
  38. package/dist/index.css.map +1 -1
  39. package/dist/index.d.ts +7 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +714 -1
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +701 -1
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/styles.css +20 -0
  46. package/dist/styles.css.map +1 -1
  47. package/dist/types/recommendedLessons/index.d.ts +182 -0
  48. package/dist/types/recommendedLessons/index.d.ts.map +1 -0
  49. package/dist/types/recommendedLessons/index.js +75 -0
  50. package/dist/types/recommendedLessons/index.js.map +1 -0
  51. package/dist/types/recommendedLessons/index.mjs +45 -0
  52. package/dist/types/recommendedLessons/index.mjs.map +1 -0
  53. package/dist/types/recommendedLessons.d.ts +182 -0
  54. package/dist/types/recommendedLessons.d.ts.map +1 -0
  55. package/package.json +2 -1
@@ -0,0 +1,355 @@
1
+ import { z } from 'zod';
2
+ import { GoalDisplayStatus } from '../types/recommendedLessons';
3
+ import type { GoalHistoryItem, GoalTableItem, GoalsHistoryApiResponse, GoalHistoryFilters, GoalHistoryPagination } from '../types/recommendedLessons';
4
+ export declare const goalsHistoryApiResponseSchema: z.ZodObject<{
5
+ message: z.ZodString;
6
+ data: z.ZodObject<{
7
+ goals: z.ZodArray<z.ZodObject<{
8
+ goal: z.ZodObject<{
9
+ id: z.ZodString;
10
+ title: z.ZodString;
11
+ startDate: z.ZodNullable<z.ZodString>;
12
+ finalDate: z.ZodNullable<z.ZodString>;
13
+ createdAt: z.ZodString;
14
+ progress: z.ZodNumber;
15
+ totalLessons: z.ZodNumber;
16
+ }, "strip", z.ZodTypeAny, {
17
+ id: string;
18
+ title: string;
19
+ progress: number;
20
+ createdAt: string;
21
+ startDate: string | null;
22
+ finalDate: string | null;
23
+ totalLessons: number;
24
+ }, {
25
+ id: string;
26
+ title: string;
27
+ progress: number;
28
+ createdAt: string;
29
+ startDate: string | null;
30
+ finalDate: string | null;
31
+ totalLessons: number;
32
+ }>;
33
+ subject: z.ZodNullable<z.ZodObject<{
34
+ id: z.ZodString;
35
+ name: z.ZodString;
36
+ }, "strip", z.ZodTypeAny, {
37
+ id: string;
38
+ name: string;
39
+ }, {
40
+ id: string;
41
+ name: string;
42
+ }>>;
43
+ creator: z.ZodNullable<z.ZodObject<{
44
+ id: z.ZodString;
45
+ name: z.ZodString;
46
+ }, "strip", z.ZodTypeAny, {
47
+ id: string;
48
+ name: string;
49
+ }, {
50
+ id: string;
51
+ name: string;
52
+ }>>;
53
+ stats: z.ZodObject<{
54
+ totalStudents: z.ZodNumber;
55
+ completedCount: z.ZodNumber;
56
+ completionPercentage: z.ZodNumber;
57
+ }, "strip", z.ZodTypeAny, {
58
+ completionPercentage: number;
59
+ totalStudents: number;
60
+ completedCount: number;
61
+ }, {
62
+ completionPercentage: number;
63
+ totalStudents: number;
64
+ completedCount: number;
65
+ }>;
66
+ breakdown: z.ZodArray<z.ZodObject<{
67
+ classId: z.ZodString;
68
+ className: z.ZodString;
69
+ schoolId: z.ZodString;
70
+ schoolName: z.ZodString;
71
+ studentCount: z.ZodNumber;
72
+ completedCount: z.ZodNumber;
73
+ }, "strip", z.ZodTypeAny, {
74
+ className: string;
75
+ schoolName: string;
76
+ schoolId: string;
77
+ classId: string;
78
+ completedCount: number;
79
+ studentCount: number;
80
+ }, {
81
+ className: string;
82
+ schoolName: string;
83
+ schoolId: string;
84
+ classId: string;
85
+ completedCount: number;
86
+ studentCount: number;
87
+ }>, "many">;
88
+ }, "strip", z.ZodTypeAny, {
89
+ goal: {
90
+ id: string;
91
+ title: string;
92
+ progress: number;
93
+ createdAt: string;
94
+ startDate: string | null;
95
+ finalDate: string | null;
96
+ totalLessons: number;
97
+ };
98
+ subject: {
99
+ id: string;
100
+ name: string;
101
+ } | null;
102
+ creator: {
103
+ id: string;
104
+ name: string;
105
+ } | null;
106
+ stats: {
107
+ completionPercentage: number;
108
+ totalStudents: number;
109
+ completedCount: number;
110
+ };
111
+ breakdown: {
112
+ className: string;
113
+ schoolName: string;
114
+ schoolId: string;
115
+ classId: string;
116
+ completedCount: number;
117
+ studentCount: number;
118
+ }[];
119
+ }, {
120
+ goal: {
121
+ id: string;
122
+ title: string;
123
+ progress: number;
124
+ createdAt: string;
125
+ startDate: string | null;
126
+ finalDate: string | null;
127
+ totalLessons: number;
128
+ };
129
+ subject: {
130
+ id: string;
131
+ name: string;
132
+ } | null;
133
+ creator: {
134
+ id: string;
135
+ name: string;
136
+ } | null;
137
+ stats: {
138
+ completionPercentage: number;
139
+ totalStudents: number;
140
+ completedCount: number;
141
+ };
142
+ breakdown: {
143
+ className: string;
144
+ schoolName: string;
145
+ schoolId: string;
146
+ classId: string;
147
+ completedCount: number;
148
+ studentCount: number;
149
+ }[];
150
+ }>, "many">;
151
+ total: z.ZodNumber;
152
+ }, "strip", z.ZodTypeAny, {
153
+ total: number;
154
+ goals: {
155
+ goal: {
156
+ id: string;
157
+ title: string;
158
+ progress: number;
159
+ createdAt: string;
160
+ startDate: string | null;
161
+ finalDate: string | null;
162
+ totalLessons: number;
163
+ };
164
+ subject: {
165
+ id: string;
166
+ name: string;
167
+ } | null;
168
+ creator: {
169
+ id: string;
170
+ name: string;
171
+ } | null;
172
+ stats: {
173
+ completionPercentage: number;
174
+ totalStudents: number;
175
+ completedCount: number;
176
+ };
177
+ breakdown: {
178
+ className: string;
179
+ schoolName: string;
180
+ schoolId: string;
181
+ classId: string;
182
+ completedCount: number;
183
+ studentCount: number;
184
+ }[];
185
+ }[];
186
+ }, {
187
+ total: number;
188
+ goals: {
189
+ goal: {
190
+ id: string;
191
+ title: string;
192
+ progress: number;
193
+ createdAt: string;
194
+ startDate: string | null;
195
+ finalDate: string | null;
196
+ totalLessons: number;
197
+ };
198
+ subject: {
199
+ id: string;
200
+ name: string;
201
+ } | null;
202
+ creator: {
203
+ id: string;
204
+ name: string;
205
+ } | null;
206
+ stats: {
207
+ completionPercentage: number;
208
+ totalStudents: number;
209
+ completedCount: number;
210
+ };
211
+ breakdown: {
212
+ className: string;
213
+ schoolName: string;
214
+ schoolId: string;
215
+ classId: string;
216
+ completedCount: number;
217
+ studentCount: number;
218
+ }[];
219
+ }[];
220
+ }>;
221
+ }, "strip", z.ZodTypeAny, {
222
+ data: {
223
+ total: number;
224
+ goals: {
225
+ goal: {
226
+ id: string;
227
+ title: string;
228
+ progress: number;
229
+ createdAt: string;
230
+ startDate: string | null;
231
+ finalDate: string | null;
232
+ totalLessons: number;
233
+ };
234
+ subject: {
235
+ id: string;
236
+ name: string;
237
+ } | null;
238
+ creator: {
239
+ id: string;
240
+ name: string;
241
+ } | null;
242
+ stats: {
243
+ completionPercentage: number;
244
+ totalStudents: number;
245
+ completedCount: number;
246
+ };
247
+ breakdown: {
248
+ className: string;
249
+ schoolName: string;
250
+ schoolId: string;
251
+ classId: string;
252
+ completedCount: number;
253
+ studentCount: number;
254
+ }[];
255
+ }[];
256
+ };
257
+ message: string;
258
+ }, {
259
+ data: {
260
+ total: number;
261
+ goals: {
262
+ goal: {
263
+ id: string;
264
+ title: string;
265
+ progress: number;
266
+ createdAt: string;
267
+ startDate: string | null;
268
+ finalDate: string | null;
269
+ totalLessons: number;
270
+ };
271
+ subject: {
272
+ id: string;
273
+ name: string;
274
+ } | null;
275
+ creator: {
276
+ id: string;
277
+ name: string;
278
+ } | null;
279
+ stats: {
280
+ completionPercentage: number;
281
+ totalStudents: number;
282
+ completedCount: number;
283
+ };
284
+ breakdown: {
285
+ className: string;
286
+ schoolName: string;
287
+ schoolId: string;
288
+ classId: string;
289
+ completedCount: number;
290
+ studentCount: number;
291
+ }[];
292
+ }[];
293
+ };
294
+ message: string;
295
+ }>;
296
+ /**
297
+ * Hook state interface
298
+ */
299
+ export interface UseRecommendedLessonsHistoryState {
300
+ goals: GoalTableItem[];
301
+ loading: boolean;
302
+ error: string | null;
303
+ pagination: GoalHistoryPagination;
304
+ }
305
+ /**
306
+ * Hook return type
307
+ */
308
+ export interface UseRecommendedLessonsHistoryReturn extends UseRecommendedLessonsHistoryState {
309
+ fetchGoals: (filters?: GoalHistoryFilters) => Promise<void>;
310
+ }
311
+ /**
312
+ * Determine status based on dates and completion
313
+ * @param finalDate - Goal final date
314
+ * @param completionPercentage - Completion percentage
315
+ * @returns Display status for UI
316
+ */
317
+ export declare const determineGoalStatus: (finalDate: string | null, completionPercentage: number) => GoalDisplayStatus;
318
+ /**
319
+ * Transform API response to table item format
320
+ * @param item - Goal history item from API response
321
+ * @returns Formatted goal for table display
322
+ */
323
+ export declare const transformGoalToTableItem: (item: GoalHistoryItem) => GoalTableItem;
324
+ /**
325
+ * Handle errors during goal fetch
326
+ * @param error - Error object
327
+ * @returns Error message for UI display
328
+ */
329
+ export declare const handleGoalFetchError: (error: unknown) => string;
330
+ /**
331
+ * Factory function to create useRecommendedLessonsHistory hook
332
+ *
333
+ * @param fetchGoalsHistory - Function to fetch goals from API
334
+ * @returns Hook for managing recommended lessons history
335
+ *
336
+ * @example
337
+ * ```tsx
338
+ * // In your app setup
339
+ * const fetchGoalsHistory = async (filters) => {
340
+ * const response = await api.get('/recommended-class/history', { params: filters });
341
+ * return response.data;
342
+ * };
343
+ *
344
+ * const useGoalsHistory = createUseRecommendedLessonsHistory(fetchGoalsHistory);
345
+ *
346
+ * // In your component
347
+ * const { goals, loading, error, pagination, fetchGoals } = useGoalsHistory();
348
+ * ```
349
+ */
350
+ export declare const createUseRecommendedLessonsHistory: (fetchGoalsHistory: (filters?: GoalHistoryFilters) => Promise<GoalsHistoryApiResponse>) => () => UseRecommendedLessonsHistoryReturn;
351
+ /**
352
+ * Alias for createUseRecommendedLessonsHistory
353
+ */
354
+ export declare const createRecommendedLessonsHistoryHook: (fetchGoalsHistory: (filters?: GoalHistoryFilters) => Promise<GoalsHistoryApiResponse>) => () => UseRecommendedLessonsHistoryReturn;
355
+ //# sourceMappingURL=useRecommendedLessons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRecommendedLessons.d.ts","sourceRoot":"","sources":["../../src/hooks/useRecommendedLessons.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,6BAA6B,CAAC;AAqDrC,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMxC,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,qBAAqB,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,kCACf,SAAQ,iCAAiC;IACzC,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,MAAM,GAAG,IAAI,EACxB,sBAAsB,MAAM,KAC3B,iBAcF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,eAAe,KACpB,aA6BF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,KAAG,MAQrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,kCAAkC,GAC7C,mBAAmB,CACjB,OAAO,CAAC,EAAE,kBAAkB,KACzB,OAAO,CAAC,uBAAuB,CAAC,WAE1B,kCAqEZ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC,sBA9E3B,CACjB,OAAO,CAAC,EAAE,kBAAkB,KACzB,OAAO,CAAC,uBAAuB,CAAC,WAE1B,kCA2EuB,CAAC"}
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/hooks/useRecommendedLessons.ts
31
+ var useRecommendedLessons_exports = {};
32
+ __export(useRecommendedLessons_exports, {
33
+ createRecommendedLessonsHistoryHook: () => createRecommendedLessonsHistoryHook,
34
+ createUseRecommendedLessonsHistory: () => createUseRecommendedLessonsHistory,
35
+ determineGoalStatus: () => determineGoalStatus,
36
+ goalsHistoryApiResponseSchema: () => goalsHistoryApiResponseSchema,
37
+ handleGoalFetchError: () => handleGoalFetchError,
38
+ transformGoalToTableItem: () => transformGoalToTableItem
39
+ });
40
+ module.exports = __toCommonJS(useRecommendedLessons_exports);
41
+ var import_react = require("react");
42
+ var import_zod = require("zod");
43
+ var import_dayjs = __toESM(require("dayjs"));
44
+ var goalSubjectSchema = import_zod.z.object({
45
+ id: import_zod.z.string().uuid(),
46
+ name: import_zod.z.string()
47
+ }).nullable();
48
+ var goalCreatorSchema = import_zod.z.object({
49
+ id: import_zod.z.string().uuid(),
50
+ name: import_zod.z.string()
51
+ }).nullable();
52
+ var goalStatsSchema = import_zod.z.object({
53
+ totalStudents: import_zod.z.number(),
54
+ completedCount: import_zod.z.number(),
55
+ completionPercentage: import_zod.z.number()
56
+ });
57
+ var goalBreakdownSchema = import_zod.z.object({
58
+ classId: import_zod.z.string().uuid(),
59
+ className: import_zod.z.string(),
60
+ schoolId: import_zod.z.string(),
61
+ schoolName: import_zod.z.string(),
62
+ studentCount: import_zod.z.number(),
63
+ completedCount: import_zod.z.number()
64
+ });
65
+ var goalDataSchema = import_zod.z.object({
66
+ id: import_zod.z.string().uuid(),
67
+ title: import_zod.z.string(),
68
+ startDate: import_zod.z.string().nullable(),
69
+ finalDate: import_zod.z.string().nullable(),
70
+ createdAt: import_zod.z.string(),
71
+ progress: import_zod.z.number(),
72
+ totalLessons: import_zod.z.number()
73
+ });
74
+ var goalHistoryItemSchema = import_zod.z.object({
75
+ goal: goalDataSchema,
76
+ subject: goalSubjectSchema,
77
+ creator: goalCreatorSchema,
78
+ stats: goalStatsSchema,
79
+ breakdown: import_zod.z.array(goalBreakdownSchema)
80
+ });
81
+ var goalsHistoryApiResponseSchema = import_zod.z.object({
82
+ message: import_zod.z.string(),
83
+ data: import_zod.z.object({
84
+ goals: import_zod.z.array(goalHistoryItemSchema),
85
+ total: import_zod.z.number()
86
+ })
87
+ });
88
+ var determineGoalStatus = (finalDate, completionPercentage) => {
89
+ if (completionPercentage === 100) {
90
+ return "CONCLU\xCDDA" /* CONCLUIDA */;
91
+ }
92
+ if (finalDate) {
93
+ const now = (0, import_dayjs.default)();
94
+ const deadline = (0, import_dayjs.default)(finalDate);
95
+ if (deadline.isBefore(now)) {
96
+ return "VENCIDA" /* VENCIDA */;
97
+ }
98
+ }
99
+ return "ATIVA" /* ATIVA */;
100
+ };
101
+ var transformGoalToTableItem = (item) => {
102
+ const firstBreakdown = item.breakdown[0];
103
+ const schoolName = firstBreakdown?.schoolName || "-";
104
+ const className = firstBreakdown?.className || "-";
105
+ const classDisplay = item.breakdown.length > 1 ? `${item.breakdown.length} turmas` : className;
106
+ return {
107
+ id: item.goal.id,
108
+ startDate: item.goal.startDate ? (0, import_dayjs.default)(item.goal.startDate).format("DD/MM") : "-",
109
+ deadline: item.goal.finalDate ? (0, import_dayjs.default)(item.goal.finalDate).format("DD/MM") : "-",
110
+ title: item.goal.title,
111
+ school: schoolName,
112
+ year: "-",
113
+ // API doesn't provide year directly
114
+ subject: item.subject?.name || "-",
115
+ class: classDisplay,
116
+ status: determineGoalStatus(
117
+ item.goal.finalDate,
118
+ item.stats.completionPercentage
119
+ ),
120
+ completionPercentage: item.stats.completionPercentage
121
+ };
122
+ };
123
+ var handleGoalFetchError = (error) => {
124
+ if (error instanceof import_zod.z.ZodError) {
125
+ console.error("Erro ao validar dados de hist\xF3rico de aulas:", error);
126
+ return "Erro ao validar dados de hist\xF3rico de aulas";
127
+ }
128
+ console.error("Erro ao carregar hist\xF3rico de aulas:", error);
129
+ return "Erro ao carregar hist\xF3rico de aulas";
130
+ };
131
+ var createUseRecommendedLessonsHistory = (fetchGoalsHistory) => {
132
+ return () => {
133
+ const [state, setState] = (0, import_react.useState)({
134
+ goals: [],
135
+ loading: false,
136
+ error: null,
137
+ pagination: {
138
+ total: 0,
139
+ page: 1,
140
+ limit: 10,
141
+ totalPages: 0
142
+ }
143
+ });
144
+ const fetchGoals = (0, import_react.useCallback)(
145
+ async (filters) => {
146
+ setState((prev) => ({ ...prev, loading: true, error: null }));
147
+ try {
148
+ const responseData = await fetchGoalsHistory(filters);
149
+ const validatedData = goalsHistoryApiResponseSchema.parse(responseData);
150
+ const tableItems = validatedData.data.goals.map(
151
+ transformGoalToTableItem
152
+ );
153
+ const page = filters?.page || 1;
154
+ const limit = filters?.limit || 10;
155
+ const total = validatedData.data.total;
156
+ const totalPages = Math.ceil(total / limit);
157
+ setState({
158
+ goals: tableItems,
159
+ loading: false,
160
+ error: null,
161
+ pagination: {
162
+ total,
163
+ page,
164
+ limit,
165
+ totalPages
166
+ }
167
+ });
168
+ } catch (error) {
169
+ const errorMessage = handleGoalFetchError(error);
170
+ setState((prev) => ({
171
+ ...prev,
172
+ loading: false,
173
+ error: errorMessage
174
+ }));
175
+ }
176
+ },
177
+ [fetchGoalsHistory]
178
+ );
179
+ return {
180
+ ...state,
181
+ fetchGoals
182
+ };
183
+ };
184
+ };
185
+ var createRecommendedLessonsHistoryHook = createUseRecommendedLessonsHistory;
186
+ // Annotate the CommonJS export names for ESM import in node:
187
+ 0 && (module.exports = {
188
+ createRecommendedLessonsHistoryHook,
189
+ createUseRecommendedLessonsHistory,
190
+ determineGoalStatus,
191
+ goalsHistoryApiResponseSchema,
192
+ handleGoalFetchError,
193
+ transformGoalToTableItem
194
+ });
195
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/useRecommendedLessons.ts"],"sourcesContent":["import { useState, useCallback } from 'react';\nimport { z } from 'zod';\nimport dayjs from 'dayjs';\nimport { GoalDisplayStatus } from '../types/recommendedLessons';\nimport type {\n GoalHistoryItem,\n GoalTableItem,\n GoalsHistoryApiResponse,\n GoalHistoryFilters,\n GoalHistoryPagination,\n} from '../types/recommendedLessons';\n\n/**\n * Zod schema for goal history API response validation\n * Based on /recommended-class/history endpoint\n */\nconst goalSubjectSchema = z\n .object({\n id: z.string().uuid(),\n name: z.string(),\n })\n .nullable();\n\nconst goalCreatorSchema = z\n .object({\n id: z.string().uuid(),\n name: z.string(),\n })\n .nullable();\n\nconst goalStatsSchema = z.object({\n totalStudents: z.number(),\n completedCount: z.number(),\n completionPercentage: z.number(),\n});\n\nconst goalBreakdownSchema = z.object({\n classId: z.string().uuid(),\n className: z.string(),\n schoolId: z.string(),\n schoolName: z.string(),\n studentCount: z.number(),\n completedCount: z.number(),\n});\n\nconst goalDataSchema = z.object({\n id: z.string().uuid(),\n title: z.string(),\n startDate: z.string().nullable(),\n finalDate: z.string().nullable(),\n createdAt: z.string(),\n progress: z.number(),\n totalLessons: z.number(),\n});\n\nconst goalHistoryItemSchema = z.object({\n goal: goalDataSchema,\n subject: goalSubjectSchema,\n creator: goalCreatorSchema,\n stats: goalStatsSchema,\n breakdown: z.array(goalBreakdownSchema),\n});\n\nexport const goalsHistoryApiResponseSchema = z.object({\n message: z.string(),\n data: z.object({\n goals: z.array(goalHistoryItemSchema),\n total: z.number(),\n }),\n});\n\n/**\n * Hook state interface\n */\nexport interface UseRecommendedLessonsHistoryState {\n goals: GoalTableItem[];\n loading: boolean;\n error: string | null;\n pagination: GoalHistoryPagination;\n}\n\n/**\n * Hook return type\n */\nexport interface UseRecommendedLessonsHistoryReturn\n extends UseRecommendedLessonsHistoryState {\n fetchGoals: (filters?: GoalHistoryFilters) => Promise<void>;\n}\n\n/**\n * Determine status based on dates and completion\n * @param finalDate - Goal final date\n * @param completionPercentage - Completion percentage\n * @returns Display status for UI\n */\nexport const determineGoalStatus = (\n finalDate: string | null,\n completionPercentage: number\n): GoalDisplayStatus => {\n if (completionPercentage === 100) {\n return GoalDisplayStatus.CONCLUIDA;\n }\n\n if (finalDate) {\n const now = dayjs();\n const deadline = dayjs(finalDate);\n if (deadline.isBefore(now)) {\n return GoalDisplayStatus.VENCIDA;\n }\n }\n\n return GoalDisplayStatus.ATIVA;\n};\n\n/**\n * Transform API response to table item format\n * @param item - Goal history item from API response\n * @returns Formatted goal for table display\n */\nexport const transformGoalToTableItem = (\n item: GoalHistoryItem\n): GoalTableItem => {\n // Get first breakdown for school/class info (or aggregate)\n const firstBreakdown = item.breakdown[0];\n const schoolName = firstBreakdown?.schoolName || '-';\n const className = firstBreakdown?.className || '-';\n\n // If multiple classes, show count\n const classDisplay =\n item.breakdown.length > 1 ? `${item.breakdown.length} turmas` : className;\n\n return {\n id: item.goal.id,\n startDate: item.goal.startDate\n ? dayjs(item.goal.startDate).format('DD/MM')\n : '-',\n deadline: item.goal.finalDate\n ? dayjs(item.goal.finalDate).format('DD/MM')\n : '-',\n title: item.goal.title,\n school: schoolName,\n year: '-', // API doesn't provide year directly\n subject: item.subject?.name || '-',\n class: classDisplay,\n status: determineGoalStatus(\n item.goal.finalDate,\n item.stats.completionPercentage\n ),\n completionPercentage: item.stats.completionPercentage,\n };\n};\n\n/**\n * Handle errors during goal fetch\n * @param error - Error object\n * @returns Error message for UI display\n */\nexport const handleGoalFetchError = (error: unknown): string => {\n if (error instanceof z.ZodError) {\n console.error('Erro ao validar dados de histórico de aulas:', error);\n return 'Erro ao validar dados de histórico de aulas';\n }\n\n console.error('Erro ao carregar histórico de aulas:', error);\n return 'Erro ao carregar histórico de aulas';\n};\n\n/**\n * Factory function to create useRecommendedLessonsHistory hook\n *\n * @param fetchGoalsHistory - Function to fetch goals from API\n * @returns Hook for managing recommended lessons history\n *\n * @example\n * ```tsx\n * // In your app setup\n * const fetchGoalsHistory = async (filters) => {\n * const response = await api.get('/recommended-class/history', { params: filters });\n * return response.data;\n * };\n *\n * const useGoalsHistory = createUseRecommendedLessonsHistory(fetchGoalsHistory);\n *\n * // In your component\n * const { goals, loading, error, pagination, fetchGoals } = useGoalsHistory();\n * ```\n */\nexport const createUseRecommendedLessonsHistory = (\n fetchGoalsHistory: (\n filters?: GoalHistoryFilters\n ) => Promise<GoalsHistoryApiResponse>\n) => {\n return (): UseRecommendedLessonsHistoryReturn => {\n const [state, setState] = useState<UseRecommendedLessonsHistoryState>({\n goals: [],\n loading: false,\n error: null,\n pagination: {\n total: 0,\n page: 1,\n limit: 10,\n totalPages: 0,\n },\n });\n\n /**\n * Fetch goals history from API\n * @param filters - Optional filters for pagination, search, sorting, etc.\n */\n const fetchGoals = useCallback(\n async (filters?: GoalHistoryFilters) => {\n setState((prev) => ({ ...prev, loading: true, error: null }));\n\n try {\n // Fetch data from API\n const responseData = await fetchGoalsHistory(filters);\n\n // Validate response with Zod\n const validatedData =\n goalsHistoryApiResponseSchema.parse(responseData);\n\n // Transform goals to table format\n const tableItems = validatedData.data.goals.map(\n transformGoalToTableItem\n );\n\n // Calculate pagination from total\n const page = filters?.page || 1;\n const limit = filters?.limit || 10;\n const total = validatedData.data.total;\n const totalPages = Math.ceil(total / limit);\n\n // Update state with validated and transformed data\n setState({\n goals: tableItems,\n loading: false,\n error: null,\n pagination: {\n total,\n page,\n limit,\n totalPages,\n },\n });\n } catch (error) {\n const errorMessage = handleGoalFetchError(error);\n setState((prev) => ({\n ...prev,\n loading: false,\n error: errorMessage,\n }));\n }\n },\n [fetchGoalsHistory]\n );\n\n return {\n ...state,\n fetchGoals,\n };\n };\n};\n\n/**\n * Alias for createUseRecommendedLessonsHistory\n */\nexport const createRecommendedLessonsHistoryHook =\n createUseRecommendedLessonsHistory;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsC;AACtC,iBAAkB;AAClB,mBAAkB;AAclB,IAAM,oBAAoB,aACvB,OAAO;AAA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