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.
- package/dist/ActivityCardQuestionBanks/index.css +20 -0
- package/dist/ActivityCardQuestionBanks/index.css.map +1 -1
- package/dist/ActivityCardQuestionPreview/index.css +20 -0
- package/dist/ActivityCardQuestionPreview/index.css.map +1 -1
- package/dist/ActivityDetails/index.css +20 -0
- package/dist/ActivityDetails/index.css.map +1 -1
- package/dist/ActivityFilters/index.css +20 -0
- package/dist/ActivityFilters/index.css.map +1 -1
- package/dist/ActivityPreview/index.css +20 -0
- package/dist/ActivityPreview/index.css.map +1 -1
- package/dist/AlertManager/index.css +20 -0
- package/dist/AlertManager/index.css.map +1 -1
- package/dist/RecommendedLessonsHistory/index.css +19327 -0
- package/dist/RecommendedLessonsHistory/index.css.map +1 -0
- package/dist/RecommendedLessonsHistory/index.d.ts +2 -0
- package/dist/RecommendedLessonsHistory/index.d.ts.map +1 -0
- package/dist/RecommendedLessonsHistory/index.js +6775 -0
- package/dist/RecommendedLessonsHistory/index.js.map +1 -0
- package/dist/RecommendedLessonsHistory/index.mjs +6815 -0
- package/dist/RecommendedLessonsHistory/index.mjs.map +1 -0
- package/dist/SendActivityModal/index.css +20 -0
- package/dist/SendActivityModal/index.css.map +1 -1
- package/dist/SendActivityModal/index.js +16 -1
- package/dist/SendActivityModal/index.js.map +1 -1
- package/dist/SendActivityModal/index.mjs +16 -1
- package/dist/SendActivityModal/index.mjs.map +1 -1
- package/dist/TableProvider/index.css +20 -0
- package/dist/TableProvider/index.css.map +1 -1
- package/dist/hooks/useRecommendedLessons/index.d.ts +355 -0
- package/dist/hooks/useRecommendedLessons/index.d.ts.map +1 -0
- package/dist/hooks/useRecommendedLessons/index.js +195 -0
- package/dist/hooks/useRecommendedLessons/index.js.map +1 -0
- package/dist/hooks/useRecommendedLessons/index.mjs +155 -0
- package/dist/hooks/useRecommendedLessons/index.mjs.map +1 -0
- package/dist/hooks/useRecommendedLessons.d.ts +355 -0
- package/dist/hooks/useRecommendedLessons.d.ts.map +1 -0
- package/dist/index.css +20 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +714 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +701 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +20 -0
- package/dist/styles.css.map +1 -1
- package/dist/types/recommendedLessons/index.d.ts +182 -0
- package/dist/types/recommendedLessons/index.d.ts.map +1 -0
- package/dist/types/recommendedLessons/index.js +75 -0
- package/dist/types/recommendedLessons/index.js.map +1 -0
- package/dist/types/recommendedLessons/index.mjs +45 -0
- package/dist/types/recommendedLessons/index.mjs.map +1 -0
- package/dist/types/recommendedLessons.d.ts +182 -0
- package/dist/types/recommendedLessons.d.ts.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// src/hooks/useRecommendedLessons.ts
|
|
2
|
+
import { useState, useCallback } from "react";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import dayjs from "dayjs";
|
|
5
|
+
var goalSubjectSchema = z.object({
|
|
6
|
+
id: z.string().uuid(),
|
|
7
|
+
name: z.string()
|
|
8
|
+
}).nullable();
|
|
9
|
+
var goalCreatorSchema = z.object({
|
|
10
|
+
id: z.string().uuid(),
|
|
11
|
+
name: z.string()
|
|
12
|
+
}).nullable();
|
|
13
|
+
var goalStatsSchema = z.object({
|
|
14
|
+
totalStudents: z.number(),
|
|
15
|
+
completedCount: z.number(),
|
|
16
|
+
completionPercentage: z.number()
|
|
17
|
+
});
|
|
18
|
+
var goalBreakdownSchema = z.object({
|
|
19
|
+
classId: z.string().uuid(),
|
|
20
|
+
className: z.string(),
|
|
21
|
+
schoolId: z.string(),
|
|
22
|
+
schoolName: z.string(),
|
|
23
|
+
studentCount: z.number(),
|
|
24
|
+
completedCount: z.number()
|
|
25
|
+
});
|
|
26
|
+
var goalDataSchema = z.object({
|
|
27
|
+
id: z.string().uuid(),
|
|
28
|
+
title: z.string(),
|
|
29
|
+
startDate: z.string().nullable(),
|
|
30
|
+
finalDate: z.string().nullable(),
|
|
31
|
+
createdAt: z.string(),
|
|
32
|
+
progress: z.number(),
|
|
33
|
+
totalLessons: z.number()
|
|
34
|
+
});
|
|
35
|
+
var goalHistoryItemSchema = z.object({
|
|
36
|
+
goal: goalDataSchema,
|
|
37
|
+
subject: goalSubjectSchema,
|
|
38
|
+
creator: goalCreatorSchema,
|
|
39
|
+
stats: goalStatsSchema,
|
|
40
|
+
breakdown: z.array(goalBreakdownSchema)
|
|
41
|
+
});
|
|
42
|
+
var goalsHistoryApiResponseSchema = z.object({
|
|
43
|
+
message: z.string(),
|
|
44
|
+
data: z.object({
|
|
45
|
+
goals: z.array(goalHistoryItemSchema),
|
|
46
|
+
total: z.number()
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
var determineGoalStatus = (finalDate, completionPercentage) => {
|
|
50
|
+
if (completionPercentage === 100) {
|
|
51
|
+
return "CONCLU\xCDDA" /* CONCLUIDA */;
|
|
52
|
+
}
|
|
53
|
+
if (finalDate) {
|
|
54
|
+
const now = dayjs();
|
|
55
|
+
const deadline = dayjs(finalDate);
|
|
56
|
+
if (deadline.isBefore(now)) {
|
|
57
|
+
return "VENCIDA" /* VENCIDA */;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return "ATIVA" /* ATIVA */;
|
|
61
|
+
};
|
|
62
|
+
var transformGoalToTableItem = (item) => {
|
|
63
|
+
const firstBreakdown = item.breakdown[0];
|
|
64
|
+
const schoolName = firstBreakdown?.schoolName || "-";
|
|
65
|
+
const className = firstBreakdown?.className || "-";
|
|
66
|
+
const classDisplay = item.breakdown.length > 1 ? `${item.breakdown.length} turmas` : className;
|
|
67
|
+
return {
|
|
68
|
+
id: item.goal.id,
|
|
69
|
+
startDate: item.goal.startDate ? dayjs(item.goal.startDate).format("DD/MM") : "-",
|
|
70
|
+
deadline: item.goal.finalDate ? dayjs(item.goal.finalDate).format("DD/MM") : "-",
|
|
71
|
+
title: item.goal.title,
|
|
72
|
+
school: schoolName,
|
|
73
|
+
year: "-",
|
|
74
|
+
// API doesn't provide year directly
|
|
75
|
+
subject: item.subject?.name || "-",
|
|
76
|
+
class: classDisplay,
|
|
77
|
+
status: determineGoalStatus(
|
|
78
|
+
item.goal.finalDate,
|
|
79
|
+
item.stats.completionPercentage
|
|
80
|
+
),
|
|
81
|
+
completionPercentage: item.stats.completionPercentage
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
var handleGoalFetchError = (error) => {
|
|
85
|
+
if (error instanceof z.ZodError) {
|
|
86
|
+
console.error("Erro ao validar dados de hist\xF3rico de aulas:", error);
|
|
87
|
+
return "Erro ao validar dados de hist\xF3rico de aulas";
|
|
88
|
+
}
|
|
89
|
+
console.error("Erro ao carregar hist\xF3rico de aulas:", error);
|
|
90
|
+
return "Erro ao carregar hist\xF3rico de aulas";
|
|
91
|
+
};
|
|
92
|
+
var createUseRecommendedLessonsHistory = (fetchGoalsHistory) => {
|
|
93
|
+
return () => {
|
|
94
|
+
const [state, setState] = useState({
|
|
95
|
+
goals: [],
|
|
96
|
+
loading: false,
|
|
97
|
+
error: null,
|
|
98
|
+
pagination: {
|
|
99
|
+
total: 0,
|
|
100
|
+
page: 1,
|
|
101
|
+
limit: 10,
|
|
102
|
+
totalPages: 0
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const fetchGoals = useCallback(
|
|
106
|
+
async (filters) => {
|
|
107
|
+
setState((prev) => ({ ...prev, loading: true, error: null }));
|
|
108
|
+
try {
|
|
109
|
+
const responseData = await fetchGoalsHistory(filters);
|
|
110
|
+
const validatedData = goalsHistoryApiResponseSchema.parse(responseData);
|
|
111
|
+
const tableItems = validatedData.data.goals.map(
|
|
112
|
+
transformGoalToTableItem
|
|
113
|
+
);
|
|
114
|
+
const page = filters?.page || 1;
|
|
115
|
+
const limit = filters?.limit || 10;
|
|
116
|
+
const total = validatedData.data.total;
|
|
117
|
+
const totalPages = Math.ceil(total / limit);
|
|
118
|
+
setState({
|
|
119
|
+
goals: tableItems,
|
|
120
|
+
loading: false,
|
|
121
|
+
error: null,
|
|
122
|
+
pagination: {
|
|
123
|
+
total,
|
|
124
|
+
page,
|
|
125
|
+
limit,
|
|
126
|
+
totalPages
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
} catch (error) {
|
|
130
|
+
const errorMessage = handleGoalFetchError(error);
|
|
131
|
+
setState((prev) => ({
|
|
132
|
+
...prev,
|
|
133
|
+
loading: false,
|
|
134
|
+
error: errorMessage
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
[fetchGoalsHistory]
|
|
139
|
+
);
|
|
140
|
+
return {
|
|
141
|
+
...state,
|
|
142
|
+
fetchGoals
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
var createRecommendedLessonsHistoryHook = createUseRecommendedLessonsHistory;
|
|
147
|
+
export {
|
|
148
|
+
createRecommendedLessonsHistoryHook,
|
|
149
|
+
createUseRecommendedLessonsHistory,
|
|
150
|
+
determineGoalStatus,
|
|
151
|
+
goalsHistoryApiResponseSchema,
|
|
152
|
+
handleGoalFetchError,
|
|
153
|
+
transformGoalToTableItem
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=index.mjs.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,SAAS,UAAU,mBAAmB;AACtC,SAAS,SAAS;AAClB,OAAO,WAAW;AAclB,IAAM,oBAAoB,EACvB,OAAO;AAAA,EACN,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,MAAM,EAAE,OAAO;AACjB,CAAC,EACA,SAAS;AAEZ,IAAM,oBAAoB,EACvB,OAAO;AAAA,EACN,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,MAAM,EAAE,OAAO;AACjB,CAAC,EACA,SAAS;AAEZ,IAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,eAAe,EAAE,OAAO;AAAA,EACxB,gBAAgB,EAA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B,MAAM,YAAY;AAGlD,gBAAM,aAAa,cAAc,KAAK,MAAM;AAAA,YAC1C;AAAA,UACF;AAGA,gBAAM,OAAO,SAAS,QAAQ;AAC9B,gBAAM,QAAQ,SAAS,SAAS;AAChC,gBAAM,QAAQ,cAAc,KAAK;AACjC,gBAAM,aAAa,KAAK,KAAK,QAAQ,KAAK;AAG1C,mBAAS;AAAA,YACP,OAAO;AAAA,YACP,SAAS;AAAA,YACT,OAAO;AAAA,YACP,YAAY;AAAA,cACV;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH,SAAS,OAAO;AACd,gBAAM,eAAe,qBAAqB,KAAK;AAC/C,mBAAS,CAAC,UAAU;AAAA,YAClB,GAAG;AAAA,YACH,SAAS;AAAA,YACT,OAAO;AAAA,UACT,EAAE;AAAA,QACJ;AAAA,MACF;AAAA,MACA,CAAC,iBAAiB;AAAA,IACpB;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAKO,IAAM,sCACX;","names":[]}
|
|
@@ -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"}
|
package/dist/index.css
CHANGED
|
@@ -604,6 +604,9 @@
|
|
|
604
604
|
.isolate {
|
|
605
605
|
isolation: isolate;
|
|
606
606
|
}
|
|
607
|
+
.z-0 {
|
|
608
|
+
z-index: 0;
|
|
609
|
+
}
|
|
607
610
|
.z-10 {
|
|
608
611
|
z-index: 10;
|
|
609
612
|
}
|
|
@@ -1329,6 +1332,9 @@
|
|
|
1329
1332
|
.max-w-\[1150px\] {
|
|
1330
1333
|
max-width: 1150px;
|
|
1331
1334
|
}
|
|
1335
|
+
.max-w-\[1350px\] {
|
|
1336
|
+
max-width: 1350px;
|
|
1337
|
+
}
|
|
1332
1338
|
.max-w-full {
|
|
1333
1339
|
max-width: 100%;
|
|
1334
1340
|
}
|
|
@@ -1705,6 +1711,9 @@
|
|
|
1705
1711
|
margin-inline-end: calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-x-reverse)));
|
|
1706
1712
|
}
|
|
1707
1713
|
}
|
|
1714
|
+
.self-center {
|
|
1715
|
+
align-self: center;
|
|
1716
|
+
}
|
|
1708
1717
|
.self-start {
|
|
1709
1718
|
align-self: flex-start;
|
|
1710
1719
|
}
|
|
@@ -16575,6 +16584,11 @@
|
|
|
16575
16584
|
width: calc(var(--spacing) * 3.5);
|
|
16576
16585
|
}
|
|
16577
16586
|
}
|
|
16587
|
+
.lg\:w-auto {
|
|
16588
|
+
@media (width >= 64rem) {
|
|
16589
|
+
width: auto;
|
|
16590
|
+
}
|
|
16591
|
+
}
|
|
16578
16592
|
.lg\:max-w-\[1000px\] {
|
|
16579
16593
|
@media (width >= 64rem) {
|
|
16580
16594
|
max-width: 1000px;
|
|
@@ -18672,6 +18686,12 @@
|
|
|
18672
18686
|
padding-left: calc(var(--spacing) * 96);
|
|
18673
18687
|
}
|
|
18674
18688
|
}
|
|
18689
|
+
.lg\:text-2xl {
|
|
18690
|
+
@media (width >= 64rem) {
|
|
18691
|
+
font-size: var(--text-2xl);
|
|
18692
|
+
line-height: var(--tw-leading, var(--text-2xl--line-height));
|
|
18693
|
+
}
|
|
18694
|
+
}
|
|
18675
18695
|
.xl\:max-w-none {
|
|
18676
18696
|
@media (width >= 80rem) {
|
|
18677
18697
|
max-width: none;
|