@ubkinfotech/tecaher-erp 0.1.0
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/LICENSE +21 -0
- package/README.md +413 -0
- package/lib/commonjs/core/api/apiClient.js +38 -0
- package/lib/commonjs/core/api/endpoints.js +139 -0
- package/lib/commonjs/core/api/interceptor.js +64 -0
- package/lib/commonjs/core/auth/authContext.js +30 -0
- package/lib/commonjs/core/auth/authService.js +12 -0
- package/lib/commonjs/core/hooks/useApiQuery.js +26 -0
- package/lib/commonjs/core/provider/ERPProvider.js +63 -0
- package/lib/commonjs/core/provider/types.js +5 -0
- package/lib/commonjs/core/provider/useERP.js +17 -0
- package/lib/commonjs/core/types/api.js +1 -0
- package/lib/commonjs/index.js +110 -0
- package/lib/commonjs/modules/assignment/hooks/useAssignmentList.js +16 -0
- package/lib/commonjs/modules/assignment/hooks/useHomeworkDetails.js +16 -0
- package/lib/commonjs/modules/assignment/hooks/useHomeworkSubmissions.js +16 -0
- package/lib/commonjs/modules/assignment/screens/AssignmentScreen.js +2615 -0
- package/lib/commonjs/modules/assignment/services/assignmentService.js +75 -0
- package/lib/commonjs/modules/attendance/hooks/useAttendance.js +16 -0
- package/lib/commonjs/modules/attendance/screens/AttendanceScreen.js +866 -0
- package/lib/commonjs/modules/attendance/services/attendanceService.js +31 -0
- package/lib/commonjs/modules/leaveRequest/hooks/useLeaveRequests.js +16 -0
- package/lib/commonjs/modules/leaveRequest/screens/LeaveRequestScreen.js +991 -0
- package/lib/commonjs/modules/leaveRequest/services/leaveRequestService.js +42 -0
- package/lib/commonjs/modules/marks/hooks/useMarks.js +14 -0
- package/lib/commonjs/modules/marks/screens/MarksScreen.js +1621 -0
- package/lib/commonjs/modules/marks/services/marksService.js +71 -0
- package/lib/commonjs/modules/myAttendance/hooks/useMyAttendance.js +16 -0
- package/lib/commonjs/modules/myAttendance/screens/MyAttendanceScreen.js +357 -0
- package/lib/commonjs/modules/myAttendance/services/myAttendanceService.js +11 -0
- package/lib/commonjs/modules/notes/hooks/useNotes.js +16 -0
- package/lib/commonjs/modules/notes/screens/NotesScreen.js +1287 -0
- package/lib/commonjs/modules/notes/services/notesService.js +65 -0
- package/lib/commonjs/modules/noticeboard/hooks/useNoticeboard.js +16 -0
- package/lib/commonjs/modules/noticeboard/screens/NoticeBoardScreen.js +381 -0
- package/lib/commonjs/modules/noticeboard/services/noticeboardService.js +16 -0
- package/lib/commonjs/modules/notification/hooks/useNotifications.js +16 -0
- package/lib/commonjs/modules/notification/screens/NotificationScreen.js +186 -0
- package/lib/commonjs/modules/notification/services/notificationService.js +16 -0
- package/lib/commonjs/modules/promoteStudent/hooks/usePromoteStudent.js +16 -0
- package/lib/commonjs/modules/promoteStudent/screens/PromoteStudentScreen.js +644 -0
- package/lib/commonjs/modules/promoteStudent/services/promoteStudentService.js +36 -0
- package/lib/commonjs/modules/timetable/hooks/useTimeTable.js +14 -0
- package/lib/commonjs/modules/timetable/screens/TimeTableScreen.js +258 -0
- package/lib/commonjs/modules/timetable/services/timetableService.js +16 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/shared/empty-states/EmptyState.js +45 -0
- package/lib/commonjs/shared/empty-states/ErrorState.js +45 -0
- package/lib/commonjs/shared/loaders/LoadingState.js +25 -0
- package/lib/commonjs/shared/theme/theme.js +22 -0
- package/lib/module/core/api/apiClient.js +32 -0
- package/lib/module/core/api/endpoints.js +135 -0
- package/lib/module/core/api/interceptor.js +60 -0
- package/lib/module/core/auth/authContext.js +23 -0
- package/lib/module/core/auth/authService.js +8 -0
- package/lib/module/core/hooks/useApiQuery.js +21 -0
- package/lib/module/core/provider/ERPProvider.js +56 -0
- package/lib/module/core/provider/types.js +3 -0
- package/lib/module/core/provider/useERP.js +12 -0
- package/lib/module/core/types/api.js +1 -0
- package/lib/module/index.js +17 -0
- package/lib/module/modules/assignment/hooks/useAssignmentList.js +12 -0
- package/lib/module/modules/assignment/hooks/useHomeworkDetails.js +12 -0
- package/lib/module/modules/assignment/hooks/useHomeworkSubmissions.js +12 -0
- package/lib/module/modules/assignment/screens/AssignmentScreen.js +2609 -0
- package/lib/module/modules/assignment/services/assignmentService.js +62 -0
- package/lib/module/modules/attendance/hooks/useAttendance.js +12 -0
- package/lib/module/modules/attendance/screens/AttendanceScreen.js +860 -0
- package/lib/module/modules/attendance/services/attendanceService.js +23 -0
- package/lib/module/modules/leaveRequest/hooks/useLeaveRequests.js +12 -0
- package/lib/module/modules/leaveRequest/screens/LeaveRequestScreen.js +985 -0
- package/lib/module/modules/leaveRequest/services/leaveRequestService.js +35 -0
- package/lib/module/modules/marks/hooks/useMarks.js +10 -0
- package/lib/module/modules/marks/screens/MarksScreen.js +1615 -0
- package/lib/module/modules/marks/services/marksService.js +55 -0
- package/lib/module/modules/myAttendance/hooks/useMyAttendance.js +12 -0
- package/lib/module/modules/myAttendance/screens/MyAttendanceScreen.js +351 -0
- package/lib/module/modules/myAttendance/services/myAttendanceService.js +7 -0
- package/lib/module/modules/notes/hooks/useNotes.js +12 -0
- package/lib/module/modules/notes/screens/NotesScreen.js +1281 -0
- package/lib/module/modules/notes/services/notesService.js +54 -0
- package/lib/module/modules/noticeboard/hooks/useNoticeboard.js +12 -0
- package/lib/module/modules/noticeboard/screens/NoticeBoardScreen.js +375 -0
- package/lib/module/modules/noticeboard/services/noticeboardService.js +12 -0
- package/lib/module/modules/notification/hooks/useNotifications.js +12 -0
- package/lib/module/modules/notification/screens/NotificationScreen.js +180 -0
- package/lib/module/modules/notification/services/notificationService.js +12 -0
- package/lib/module/modules/promoteStudent/hooks/usePromoteStudent.js +12 -0
- package/lib/module/modules/promoteStudent/screens/PromoteStudentScreen.js +638 -0
- package/lib/module/modules/promoteStudent/services/promoteStudentService.js +27 -0
- package/lib/module/modules/timetable/hooks/useTimeTable.js +10 -0
- package/lib/module/modules/timetable/screens/TimeTableScreen.js +252 -0
- package/lib/module/modules/timetable/services/timetableService.js +11 -0
- package/lib/module/package.json +1 -0
- package/lib/module/shared/empty-states/EmptyState.js +40 -0
- package/lib/module/shared/empty-states/ErrorState.js +40 -0
- package/lib/module/shared/loaders/LoadingState.js +20 -0
- package/lib/module/shared/theme/theme.js +18 -0
- package/lib/typescript/core/api/apiClient.d.ts +14 -0
- package/lib/typescript/core/api/endpoints.d.ts +164 -0
- package/lib/typescript/core/api/interceptor.d.ts +4 -0
- package/lib/typescript/core/auth/authContext.d.ts +11 -0
- package/lib/typescript/core/auth/authService.d.ts +9 -0
- package/lib/typescript/core/hooks/useApiQuery.d.ts +7 -0
- package/lib/typescript/core/provider/ERPProvider.d.ts +14 -0
- package/lib/typescript/core/provider/types.d.ts +34 -0
- package/lib/typescript/core/provider/useERP.d.ts +3 -0
- package/lib/typescript/core/types/api.d.ts +11 -0
- package/lib/typescript/index.d.ts +18 -0
- package/lib/typescript/modules/assignment/hooks/useAssignmentList.d.ts +3 -0
- package/lib/typescript/modules/assignment/hooks/useHomeworkDetails.d.ts +4 -0
- package/lib/typescript/modules/assignment/hooks/useHomeworkSubmissions.d.ts +4 -0
- package/lib/typescript/modules/assignment/screens/AssignmentScreen.d.ts +9 -0
- package/lib/typescript/modules/assignment/services/assignmentService.d.ts +89 -0
- package/lib/typescript/modules/attendance/hooks/useAttendance.d.ts +3 -0
- package/lib/typescript/modules/attendance/screens/AttendanceScreen.d.ts +5 -0
- package/lib/typescript/modules/attendance/services/attendanceService.d.ts +33 -0
- package/lib/typescript/modules/leaveRequest/hooks/useLeaveRequests.d.ts +3 -0
- package/lib/typescript/modules/leaveRequest/screens/LeaveRequestScreen.d.ts +5 -0
- package/lib/typescript/modules/leaveRequest/services/leaveRequestService.d.ts +39 -0
- package/lib/typescript/modules/marks/hooks/useMarks.d.ts +2 -0
- package/lib/typescript/modules/marks/screens/MarksScreen.d.ts +6 -0
- package/lib/typescript/modules/marks/services/marksService.d.ts +150 -0
- package/lib/typescript/modules/myAttendance/hooks/useMyAttendance.d.ts +3 -0
- package/lib/typescript/modules/myAttendance/screens/MyAttendanceScreen.d.ts +5 -0
- package/lib/typescript/modules/myAttendance/services/myAttendanceService.d.ts +10 -0
- package/lib/typescript/modules/notes/hooks/useNotes.d.ts +3 -0
- package/lib/typescript/modules/notes/screens/NotesScreen.d.ts +8 -0
- package/lib/typescript/modules/notes/services/notesService.d.ts +58 -0
- package/lib/typescript/modules/noticeboard/hooks/useNoticeboard.d.ts +3 -0
- package/lib/typescript/modules/noticeboard/screens/NoticeBoardScreen.d.ts +5 -0
- package/lib/typescript/modules/noticeboard/services/noticeboardService.d.ts +17 -0
- package/lib/typescript/modules/notification/hooks/useNotifications.d.ts +3 -0
- package/lib/typescript/modules/notification/screens/NotificationScreen.d.ts +5 -0
- package/lib/typescript/modules/notification/services/notificationService.d.ts +8 -0
- package/lib/typescript/modules/promoteStudent/hooks/usePromoteStudent.d.ts +3 -0
- package/lib/typescript/modules/promoteStudent/screens/PromoteStudentScreen.d.ts +5 -0
- package/lib/typescript/modules/promoteStudent/services/promoteStudentService.d.ts +40 -0
- package/lib/typescript/modules/timetable/hooks/useTimeTable.d.ts +3 -0
- package/lib/typescript/modules/timetable/screens/TimeTableScreen.d.ts +5 -0
- package/lib/typescript/modules/timetable/services/timetableService.d.ts +14 -0
- package/lib/typescript/shared/empty-states/EmptyState.d.ts +6 -0
- package/lib/typescript/shared/empty-states/ErrorState.d.ts +6 -0
- package/lib/typescript/shared/loaders/LoadingState.d.ts +3 -0
- package/lib/typescript/shared/theme/theme.d.ts +17 -0
- package/package.json +89 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTimeTable = useTimeTable;
|
|
7
|
+
var _useApiQuery = require("../../../core/hooks/useApiQuery");
|
|
8
|
+
var _timetableService = require("../services/timetableService");
|
|
9
|
+
function useTimeTable(params) {
|
|
10
|
+
return (0, _useApiQuery.useApiQuery)({
|
|
11
|
+
queryKey: ['timetable', 'classSection', params.classId, params.sectionId, params.sessionId],
|
|
12
|
+
queryFn: api => (0, _timetableService.fetchTimeTable)(api, params)
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TimeTableScreen = TimeTableScreen;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _useERP = require("../../../core/provider/useERP");
|
|
10
|
+
var _EmptyState = require("../../../shared/empty-states/EmptyState");
|
|
11
|
+
var _ErrorState = require("../../../shared/empty-states/ErrorState");
|
|
12
|
+
var _timetableService = require("../services/timetableService");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function TimeTableScreen(props) {
|
|
17
|
+
const {
|
|
18
|
+
api
|
|
19
|
+
} = (0, _useERP.useERP)();
|
|
20
|
+
const isTeacherMode = props.staffId !== undefined && props.sessionId !== undefined;
|
|
21
|
+
const missing = props.sessionId === undefined || !isTeacherMode && (!props.classId || !props.sectionId);
|
|
22
|
+
const [loading, setLoading] = (0, _react.useState)(true);
|
|
23
|
+
const [items, setItems] = (0, _react.useState)([]);
|
|
24
|
+
const [error, setError] = (0, _react.useState)(null);
|
|
25
|
+
const [selectedDay, setSelectedDay] = (0, _react.useState)(new Date().toLocaleDateString('en-US', {
|
|
26
|
+
weekday: 'long'
|
|
27
|
+
}).toLowerCase());
|
|
28
|
+
(0, _react.useEffect)(() => {
|
|
29
|
+
if (missing) {
|
|
30
|
+
setLoading(false);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
setLoading(true);
|
|
34
|
+
setError(null);
|
|
35
|
+
const load = async () => {
|
|
36
|
+
try {
|
|
37
|
+
const res = isTeacherMode ? await (0, _timetableService.fetchTeacherTimeTable)(api, {
|
|
38
|
+
staffId: props.staffId,
|
|
39
|
+
sessionId: props.sessionId
|
|
40
|
+
}) : await (0, _timetableService.fetchTimeTable)(api, {
|
|
41
|
+
classId: props.classId,
|
|
42
|
+
sectionId: props.sectionId,
|
|
43
|
+
sessionId: props.sessionId
|
|
44
|
+
});
|
|
45
|
+
const list = Array.isArray(res?.data) ? res.data : [];
|
|
46
|
+
setItems(list);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
setError(String(e?.message ?? 'Could not load time table'));
|
|
49
|
+
} finally {
|
|
50
|
+
setLoading(false);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
load().catch(() => {});
|
|
54
|
+
}, [api, isTeacherMode, missing, props.classId, props.sectionId, props.sessionId, props.staffId]);
|
|
55
|
+
const days = (0, _react.useMemo)(() => ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'], []);
|
|
56
|
+
const filtered = (0, _react.useMemo)(() => {
|
|
57
|
+
return items.filter(item => String(item?.day_name ?? '').toLowerCase() === selectedDay);
|
|
58
|
+
}, [items, selectedDay]);
|
|
59
|
+
if (missing) {
|
|
60
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EmptyState.EmptyState, {
|
|
61
|
+
title: "Missing parameters",
|
|
62
|
+
message: "Provide staffId + sessionId, or classId + sectionId + sessionId"
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (loading) {
|
|
66
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.SafeAreaView, {
|
|
67
|
+
style: styles.root,
|
|
68
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
69
|
+
style: styles.loaderWrap,
|
|
70
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
71
|
+
size: "large",
|
|
72
|
+
color: "#1D4ED8"
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (error) {
|
|
78
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorState.ErrorState, {
|
|
79
|
+
message: error
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.SafeAreaView, {
|
|
83
|
+
style: styles.root,
|
|
84
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
85
|
+
style: styles.content,
|
|
86
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
87
|
+
style: styles.title,
|
|
88
|
+
children: "Time Table"
|
|
89
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
|
|
90
|
+
horizontal: true,
|
|
91
|
+
data: days,
|
|
92
|
+
keyExtractor: item => item,
|
|
93
|
+
showsHorizontalScrollIndicator: false,
|
|
94
|
+
contentContainerStyle: styles.dayList,
|
|
95
|
+
style: styles.dayStrip,
|
|
96
|
+
renderItem: ({
|
|
97
|
+
item
|
|
98
|
+
}) => {
|
|
99
|
+
const active = selectedDay === item;
|
|
100
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
101
|
+
onPress: () => setSelectedDay(item),
|
|
102
|
+
style: [styles.dayBtn, active ? styles.dayBtnActive : null],
|
|
103
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
104
|
+
style: [styles.dayBtnText, active ? styles.dayBtnTextActive : null],
|
|
105
|
+
children: item.charAt(0).toUpperCase() + item.slice(1, 3)
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
|
|
110
|
+
data: filtered,
|
|
111
|
+
keyExtractor: (item, index) => String(item?.id ?? `${selectedDay}-${index}`),
|
|
112
|
+
contentContainerStyle: filtered.length ? styles.list : styles.emptyWrap,
|
|
113
|
+
renderItem: ({
|
|
114
|
+
item
|
|
115
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
116
|
+
style: styles.card,
|
|
117
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
118
|
+
style: styles.timeWrap,
|
|
119
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
120
|
+
style: styles.timeText,
|
|
121
|
+
children: [String(item?.time_from ?? '').slice(0, 5), " - ", String(item?.time_to ?? '').slice(0, 5)]
|
|
122
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
123
|
+
style: styles.periodText,
|
|
124
|
+
children: ["Period ", String(item?.order_no ?? '-')]
|
|
125
|
+
})]
|
|
126
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
127
|
+
style: styles.infoWrap,
|
|
128
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
129
|
+
style: styles.subjectText,
|
|
130
|
+
children: String(item?.subject_name ?? 'Subject')
|
|
131
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
132
|
+
style: styles.classText,
|
|
133
|
+
children: ["Class: ", String(item?.class_name ?? '-'), " (", String(item?.section_name ?? '-'), ")"]
|
|
134
|
+
}), item?.room_no ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
135
|
+
style: styles.roomText,
|
|
136
|
+
children: ["Room: ", String(item.room_no)]
|
|
137
|
+
}) : null]
|
|
138
|
+
})]
|
|
139
|
+
}),
|
|
140
|
+
ListEmptyComponent: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
141
|
+
style: styles.emptyText,
|
|
142
|
+
children: ["No classes scheduled for ", selectedDay]
|
|
143
|
+
})
|
|
144
|
+
})]
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const styles = _reactNative.StyleSheet.create({
|
|
149
|
+
root: {
|
|
150
|
+
flex: 1,
|
|
151
|
+
backgroundColor: '#F3F4F6'
|
|
152
|
+
},
|
|
153
|
+
content: {
|
|
154
|
+
flex: 1
|
|
155
|
+
},
|
|
156
|
+
loaderWrap: {
|
|
157
|
+
flex: 1,
|
|
158
|
+
alignItems: 'center',
|
|
159
|
+
justifyContent: 'center'
|
|
160
|
+
},
|
|
161
|
+
title: {
|
|
162
|
+
fontSize: 20,
|
|
163
|
+
fontWeight: '700',
|
|
164
|
+
color: '#111827',
|
|
165
|
+
padding: 16,
|
|
166
|
+
paddingBottom: 8
|
|
167
|
+
},
|
|
168
|
+
dayStrip: {
|
|
169
|
+
maxHeight: 66,
|
|
170
|
+
flexGrow: 0
|
|
171
|
+
},
|
|
172
|
+
dayList: {
|
|
173
|
+
paddingHorizontal: 12,
|
|
174
|
+
paddingBottom: 12,
|
|
175
|
+
alignItems: 'center'
|
|
176
|
+
},
|
|
177
|
+
dayBtn: {
|
|
178
|
+
backgroundColor: '#E5E7EB',
|
|
179
|
+
width: 86,
|
|
180
|
+
height: 52,
|
|
181
|
+
borderRadius: 22,
|
|
182
|
+
marginHorizontal: 4,
|
|
183
|
+
alignItems: 'center',
|
|
184
|
+
justifyContent: 'center'
|
|
185
|
+
},
|
|
186
|
+
dayBtnActive: {
|
|
187
|
+
backgroundColor: '#1D4ED8'
|
|
188
|
+
},
|
|
189
|
+
dayBtnText: {
|
|
190
|
+
fontSize: 14,
|
|
191
|
+
fontWeight: '600',
|
|
192
|
+
color: '#111827'
|
|
193
|
+
},
|
|
194
|
+
dayBtnTextActive: {
|
|
195
|
+
color: '#FFFFFF'
|
|
196
|
+
},
|
|
197
|
+
list: {
|
|
198
|
+
padding: 16,
|
|
199
|
+
paddingTop: 8,
|
|
200
|
+
paddingBottom: 32
|
|
201
|
+
},
|
|
202
|
+
emptyWrap: {
|
|
203
|
+
flexGrow: 1,
|
|
204
|
+
padding: 16,
|
|
205
|
+
justifyContent: 'center'
|
|
206
|
+
},
|
|
207
|
+
card: {
|
|
208
|
+
backgroundColor: '#FFFFFF',
|
|
209
|
+
borderWidth: 1,
|
|
210
|
+
borderColor: '#E5E7EB',
|
|
211
|
+
borderRadius: 14,
|
|
212
|
+
padding: 14,
|
|
213
|
+
marginBottom: 12,
|
|
214
|
+
flexDirection: 'row'
|
|
215
|
+
},
|
|
216
|
+
timeWrap: {
|
|
217
|
+
width: 98,
|
|
218
|
+
borderRightWidth: 1,
|
|
219
|
+
borderRightColor: '#E5E7EB',
|
|
220
|
+
paddingRight: 12,
|
|
221
|
+
justifyContent: 'center'
|
|
222
|
+
},
|
|
223
|
+
timeText: {
|
|
224
|
+
fontSize: 14,
|
|
225
|
+
fontWeight: '700',
|
|
226
|
+
color: '#1D4ED8'
|
|
227
|
+
},
|
|
228
|
+
periodText: {
|
|
229
|
+
fontSize: 12,
|
|
230
|
+
color: '#6B7280',
|
|
231
|
+
marginTop: 4
|
|
232
|
+
},
|
|
233
|
+
infoWrap: {
|
|
234
|
+
flex: 1,
|
|
235
|
+
paddingLeft: 14,
|
|
236
|
+
justifyContent: 'center'
|
|
237
|
+
},
|
|
238
|
+
subjectText: {
|
|
239
|
+
fontSize: 17,
|
|
240
|
+
fontWeight: '700',
|
|
241
|
+
color: '#111827',
|
|
242
|
+
marginBottom: 4
|
|
243
|
+
},
|
|
244
|
+
classText: {
|
|
245
|
+
fontSize: 14,
|
|
246
|
+
color: '#374151'
|
|
247
|
+
},
|
|
248
|
+
roomText: {
|
|
249
|
+
fontSize: 13,
|
|
250
|
+
color: '#6B7280',
|
|
251
|
+
marginTop: 2
|
|
252
|
+
},
|
|
253
|
+
emptyText: {
|
|
254
|
+
fontSize: 16,
|
|
255
|
+
textAlign: 'center',
|
|
256
|
+
color: '#6B7280'
|
|
257
|
+
}
|
|
258
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fetchTeacherTimeTable = fetchTeacherTimeTable;
|
|
7
|
+
exports.fetchTimeTable = fetchTimeTable;
|
|
8
|
+
var _endpoints = require("../../../core/api/endpoints");
|
|
9
|
+
async function fetchTimeTable(api, params) {
|
|
10
|
+
const res = await api.get(_endpoints.endpoints.timetable.classSection(params));
|
|
11
|
+
return res.data;
|
|
12
|
+
}
|
|
13
|
+
async function fetchTeacherTimeTable(api, params) {
|
|
14
|
+
const res = await api.get(_endpoints.endpoints.timetable.teacher(params));
|
|
15
|
+
return res.data;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EmptyState = EmptyState;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function EmptyState({
|
|
12
|
+
title = 'No Data Found',
|
|
13
|
+
message
|
|
14
|
+
}) {
|
|
15
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
16
|
+
style: styles.root,
|
|
17
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
18
|
+
style: styles.title,
|
|
19
|
+
children: title
|
|
20
|
+
}), message ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
21
|
+
style: styles.message,
|
|
22
|
+
children: message
|
|
23
|
+
}) : null]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const styles = _reactNative.StyleSheet.create({
|
|
27
|
+
root: {
|
|
28
|
+
flex: 1,
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
paddingHorizontal: 24
|
|
32
|
+
},
|
|
33
|
+
title: {
|
|
34
|
+
fontSize: 16,
|
|
35
|
+
color: '#6B7280',
|
|
36
|
+
textAlign: 'center'
|
|
37
|
+
},
|
|
38
|
+
message: {
|
|
39
|
+
marginTop: 8,
|
|
40
|
+
fontSize: 13,
|
|
41
|
+
color: '#9CA3AF',
|
|
42
|
+
textAlign: 'center',
|
|
43
|
+
lineHeight: 18
|
|
44
|
+
}
|
|
45
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ErrorState = ErrorState;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function ErrorState({
|
|
12
|
+
title = 'Something went wrong',
|
|
13
|
+
message
|
|
14
|
+
}) {
|
|
15
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
16
|
+
style: styles.root,
|
|
17
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
18
|
+
style: styles.title,
|
|
19
|
+
children: title
|
|
20
|
+
}), message ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
21
|
+
style: styles.message,
|
|
22
|
+
children: message
|
|
23
|
+
}) : null]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const styles = _reactNative.StyleSheet.create({
|
|
27
|
+
root: {
|
|
28
|
+
flex: 1,
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
paddingHorizontal: 24
|
|
32
|
+
},
|
|
33
|
+
title: {
|
|
34
|
+
fontSize: 16,
|
|
35
|
+
color: '#DC2626',
|
|
36
|
+
textAlign: 'center',
|
|
37
|
+
fontWeight: '600'
|
|
38
|
+
},
|
|
39
|
+
message: {
|
|
40
|
+
marginTop: 8,
|
|
41
|
+
fontSize: 14,
|
|
42
|
+
color: '#6B7280',
|
|
43
|
+
textAlign: 'center'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LoadingState = LoadingState;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function LoadingState() {
|
|
12
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
13
|
+
style: styles.root,
|
|
14
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
|
|
15
|
+
size: "large"
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const styles = _reactNative.StyleSheet.create({
|
|
20
|
+
root: {
|
|
21
|
+
flex: 1,
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'center'
|
|
24
|
+
}
|
|
25
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.theme = void 0;
|
|
7
|
+
const theme = exports.theme = {
|
|
8
|
+
colors: {
|
|
9
|
+
primary: '#2563EB',
|
|
10
|
+
danger: '#DC2626',
|
|
11
|
+
text: '#111827',
|
|
12
|
+
muted: '#6B7280',
|
|
13
|
+
background: '#FFFFFF'
|
|
14
|
+
},
|
|
15
|
+
spacing: {
|
|
16
|
+
xs: 4,
|
|
17
|
+
sm: 8,
|
|
18
|
+
md: 12,
|
|
19
|
+
lg: 16,
|
|
20
|
+
xl: 24
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
import { attachInterceptors } from "./interceptor.js";
|
|
5
|
+
export function normalizeApiError(e) {
|
|
6
|
+
if (axios.isAxiosError(e)) {
|
|
7
|
+
const err = e;
|
|
8
|
+
const status = err.response?.status;
|
|
9
|
+
const data = err.response?.data;
|
|
10
|
+
return {
|
|
11
|
+
message: err.message,
|
|
12
|
+
status,
|
|
13
|
+
data
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (e instanceof Error) {
|
|
17
|
+
return {
|
|
18
|
+
message: e.message
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
message: 'Unknown error'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function createApiClient(args) {
|
|
26
|
+
const baseUrl = args.network.baseUrl.endsWith('/') ? args.network.baseUrl.slice(0, -1) : args.network.baseUrl;
|
|
27
|
+
const instance = axios.create({
|
|
28
|
+
baseURL: baseUrl
|
|
29
|
+
});
|
|
30
|
+
attachInterceptors(instance, args);
|
|
31
|
+
return instance;
|
|
32
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const endpoints = {
|
|
4
|
+
attendance: {
|
|
5
|
+
studentsForAttendance: args => {
|
|
6
|
+
const date = args.date ?? '';
|
|
7
|
+
return `staff/teacherAPP/AttendenceSection/studentlistforAttendence?class_id=${args.classId}§ion_id=${args.sectionId}&session_id=${args.sessionId}&date=${encodeURIComponent(date)}`;
|
|
8
|
+
},
|
|
9
|
+
updateStatus: 'staff/teacherAPP/AttendenceSection/studentstatusupdate',
|
|
10
|
+
notify: 'staff/teacherAPP/AttendenceSection/studentAttendanceNotification',
|
|
11
|
+
classDropdown: 'staff/teacherAPP/attendenceSection/getclassDropdownforTeacher',
|
|
12
|
+
sectionDropdown: args => {
|
|
13
|
+
return `staff/teacherAPP/attendenceSection/getsectionDropdownforTeacher?class_id=${args.classId}`;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
assignment: {
|
|
17
|
+
listByClassSection: args => {
|
|
18
|
+
const classPart = args.classId !== undefined ? `&class_id=${args.classId}` : '';
|
|
19
|
+
const sectionPart = args.sectionId !== undefined ? `§ion_id=${args.sectionId}` : '';
|
|
20
|
+
const subjectPart = args.subjectId !== undefined ? `&subject_id=${args.subjectId}` : '';
|
|
21
|
+
return `staff/teacherAPP/StaffHomework/gethomeworklistByClassSection?page=${args.page}&per_page=${args.perPage}${classPart}${sectionPart}${subjectPart}`;
|
|
22
|
+
},
|
|
23
|
+
add: 'staff/teacherAPP/StaffHomework/addHomework',
|
|
24
|
+
classDropdown: 'staff/teacherAPP/attendenceSection/getclassDropdownforTeacher',
|
|
25
|
+
sectionDropdown: args => {
|
|
26
|
+
return `staff/teacherAPP/attendenceSection/getsectionDropdownforTeacher?class_id=${args.classId}`;
|
|
27
|
+
},
|
|
28
|
+
teacherSubjectsByClass: args => {
|
|
29
|
+
return `staff/teacherAPP/teacherbasicDetails/getteacherSubjectsaccordingtoClass?session_id=${args.sessionId}&class_id=${args.classId}`;
|
|
30
|
+
},
|
|
31
|
+
uploadFile: 'superAdmin/uploadFile',
|
|
32
|
+
submissionsList: args => {
|
|
33
|
+
return `staff/teacherAPP/StaffHomework/studentsubmissionList?homework_id=${args.homeworkId}`;
|
|
34
|
+
},
|
|
35
|
+
giveMarks: 'staff/teacherAPP/StaffHomework/givemarkstoHomework',
|
|
36
|
+
showHomework: args => {
|
|
37
|
+
return `staff/teacherAPP/StaffHomework/showHomeWork?id=${args.homeworkId}`;
|
|
38
|
+
},
|
|
39
|
+
updateHomework: 'staff/teacherAPP/StaffHomework/updateHomework'
|
|
40
|
+
},
|
|
41
|
+
leaveRequest: {
|
|
42
|
+
table: args => {
|
|
43
|
+
return `staff/teacherAPP/staffLeave/leaveTable?page=${args.page}&per_page=${args.perPage}`;
|
|
44
|
+
},
|
|
45
|
+
leaveTypes: 'staff/teacherAPP/staffLeave/leavetypeDropdown',
|
|
46
|
+
apply: 'staff/teacherAPP/staffLeave/applyLeave'
|
|
47
|
+
},
|
|
48
|
+
marks: {
|
|
49
|
+
coscholasticGrades: 'staff/teacherAPP/ExamDetails/gradeDropdownCoScholastic',
|
|
50
|
+
classDropdown: 'staff/teacherAPP/attendenceSection/getclassDropdownforTeacher',
|
|
51
|
+
classTeacherClassList: 'staff/teacherAPP/ExamDetails/getClassTeacherClassList',
|
|
52
|
+
sectionDropdown: args => {
|
|
53
|
+
return `staff/teacherAPP/attendenceSection/getsectionDropdownforTeacher?class_id=${args.classId}`;
|
|
54
|
+
},
|
|
55
|
+
examDropdown: args => {
|
|
56
|
+
return `staff/teacherAPP/ExamDetails/examdropdown?session_id=${args.sessionId}&class_id=${args.classId}`;
|
|
57
|
+
},
|
|
58
|
+
teacherSubjectsForExam: args => {
|
|
59
|
+
return `staff/teacherAPP/ExamDetails/getSubjectofTeacherAccordingtoExam?session_id=${args.sessionId}&exam_id=${args.examId}&class_id=${args.classId}§ion_id=${args.sectionId}`;
|
|
60
|
+
},
|
|
61
|
+
coScholasticCategories: args => {
|
|
62
|
+
return `staff/teacherAPP/ExamDetails/getscholasticCategoryByClassId?session_id=${args.sessionId}&exam_id=${args.examId}&class_id=${args.classId}`;
|
|
63
|
+
},
|
|
64
|
+
studentListForExamAssessment: args => {
|
|
65
|
+
return `staff/teacherAPP/ExamDetails/getstudentlistforExamAssesment?class_id=${args.classId}&exam_id=${args.examId}§ion_id=${args.sectionId}&subject_id=${args.subjectId}`;
|
|
66
|
+
},
|
|
67
|
+
submitExamMarks: 'staff/teacherAPP/ExamDetails/addexamMarksV2',
|
|
68
|
+
studentListForCoScholastic: args => {
|
|
69
|
+
return `staff/teacherAPP/ExamDetails/getstudentlistforCoscholastic?class_id=${args.classId}&exam_id=${args.examId}§ion_id=${args.sectionId}&CoScholastic_category_id=${args.categoryId}`;
|
|
70
|
+
},
|
|
71
|
+
submitCoScholasticMarks: 'staff/teacherAPP/ExamDetails/assignCoscholasticMarks',
|
|
72
|
+
studentListRemarks: args => {
|
|
73
|
+
return `staff/teacherAPP/ExamDetails/getstudentListRemarks?class_id=${args.classId}&exam_id=${args.examId}§ion_id=${args.sectionId}`;
|
|
74
|
+
},
|
|
75
|
+
submitExamRemarks: 'staff/teacherAPP/ExamDetails/studentExamRemarks'
|
|
76
|
+
},
|
|
77
|
+
myAttendance: {
|
|
78
|
+
report: args => {
|
|
79
|
+
return `staff/teacherAPP/AttendenceSection/getAttendenceReportofstaffApp?id=${args.staffId}&month=${args.month}&year=${args.year}&session_id=${args.sessionId}`;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
notes: {
|
|
83
|
+
listByClassSection: args => {
|
|
84
|
+
const classPart = args.classId !== undefined ? `&class_id=${args.classId}` : '';
|
|
85
|
+
const sectionPart = args.sectionId !== undefined ? `§ion_id=${args.sectionId}` : '';
|
|
86
|
+
const subjectPart = args.subjectId !== undefined ? `&subject_id=${args.subjectId}` : '';
|
|
87
|
+
return `staff/teacherAPP/Notes/getnotelistByClassSection?page=${args.page}&per_page=${args.perPage}${classPart}${sectionPart}${subjectPart}`;
|
|
88
|
+
},
|
|
89
|
+
classDropdown: 'staff/teacherAPP/attendenceSection/getclassDropdownforTeacher',
|
|
90
|
+
sectionDropdown: args => {
|
|
91
|
+
return `staff/teacherAPP/attendenceSection/getsectionDropdownforTeacher?class_id=${args.classId}`;
|
|
92
|
+
},
|
|
93
|
+
teacherSubjectsByClass: args => {
|
|
94
|
+
return `staff/teacherAPP/StaffHomework/getsubjectDropdownByClass?class_id=${args.classId}&session_id=${args.sessionId}`;
|
|
95
|
+
},
|
|
96
|
+
details: args => {
|
|
97
|
+
return `staff/teacherAPP/Notes/getNotedatabyID?id=${args.noteId}`;
|
|
98
|
+
},
|
|
99
|
+
add: 'staff/teacherAPP/Notes/addNotes',
|
|
100
|
+
update: 'staff/teacherAPP/Notes/updateNote',
|
|
101
|
+
upload: 'staff/teacherAPP/Notes/uploadnotes'
|
|
102
|
+
},
|
|
103
|
+
noticeboard: {
|
|
104
|
+
list: args => {
|
|
105
|
+
return `staff/teacherAPP/Noticeboard?page=${args.page}&per_page=${args.perPage}`;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
notification: {
|
|
109
|
+
list: args => {
|
|
110
|
+
return `staff/teacherAPP/message/getnotificationlist?page=${args.page}&per_page=${args.perPage}`;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
promoteStudent: {
|
|
114
|
+
classDropdown: 'staff/teacherAPP/attendenceSection/getclassDropdownforTeacher',
|
|
115
|
+
sectionDropdown: args => {
|
|
116
|
+
return `staff/teacherAPP/attendenceSection/getsectionDropdownforTeacher?class_id=${args.classId}`;
|
|
117
|
+
},
|
|
118
|
+
allSectionDropdown: args => {
|
|
119
|
+
return `staff/teacherAPP/attendenceSection/getsectionDropdown?class_id=${args.classId}`;
|
|
120
|
+
},
|
|
121
|
+
sessionDropdown: 'staff/teacherAPP/StudentDetails/sessiondropdown',
|
|
122
|
+
searchByClassSection: args => {
|
|
123
|
+
return `staff/teacherAPP/StudentDetails/studentsearchbyClassSection?class_id=${args.classId}§ion_id=${args.sectionId}`;
|
|
124
|
+
},
|
|
125
|
+
submit: 'staff/teacherAPP/StudentDetails/promotestudent'
|
|
126
|
+
},
|
|
127
|
+
timetable: {
|
|
128
|
+
teacher: args => {
|
|
129
|
+
return `timetable/teacher/${args.staffId}?session_id=${args.sessionId}`;
|
|
130
|
+
},
|
|
131
|
+
classSection: args => {
|
|
132
|
+
return `timetable/class/${args.classId}/section/${args.sectionId}?session_id=${args.sessionId}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { normalizeApiError } from "./apiClient.js";
|
|
4
|
+
async function sleep(ms) {
|
|
5
|
+
await new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
6
|
+
}
|
|
7
|
+
function shouldRetry(err) {
|
|
8
|
+
if (!err.response) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
const status = err.response.status;
|
|
12
|
+
return status >= 500 && status <= 599;
|
|
13
|
+
}
|
|
14
|
+
export function attachInterceptors(instance, args) {
|
|
15
|
+
instance.interceptors.request.use(async config => {
|
|
16
|
+
const nextConfig = config;
|
|
17
|
+
nextConfig.headers = {
|
|
18
|
+
...(args.network.headers ?? {}),
|
|
19
|
+
...(nextConfig.headers ?? {})
|
|
20
|
+
};
|
|
21
|
+
const token = args.auth.authToken ?? (args.auth.getAuthToken ? await args.auth.getAuthToken() : null);
|
|
22
|
+
if (token) {
|
|
23
|
+
nextConfig.headers.Authorization = token;
|
|
24
|
+
}
|
|
25
|
+
if (args.network.schoolCode) {
|
|
26
|
+
nextConfig.headers.school_code = args.network.schoolCode;
|
|
27
|
+
}
|
|
28
|
+
return nextConfig;
|
|
29
|
+
});
|
|
30
|
+
instance.interceptors.response.use(res => res, async error => {
|
|
31
|
+
const config = error.config ?? {};
|
|
32
|
+
const status = error.response?.status;
|
|
33
|
+
if (status === 401 && !config.__didRefreshAuth && args.auth.refreshAuthToken) {
|
|
34
|
+
config.__didRefreshAuth = true;
|
|
35
|
+
const refreshed = await args.auth.refreshAuthToken();
|
|
36
|
+
if (refreshed) {
|
|
37
|
+
config.headers = {
|
|
38
|
+
...(config.headers ?? {}),
|
|
39
|
+
Authorization: refreshed
|
|
40
|
+
};
|
|
41
|
+
return instance.request(config);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (status === 401 && args.auth.onUnauthorized) {
|
|
45
|
+
args.auth.onUnauthorized(normalizeApiError(error));
|
|
46
|
+
}
|
|
47
|
+
if (args.network.onError) {
|
|
48
|
+
args.network.onError(normalizeApiError(error));
|
|
49
|
+
}
|
|
50
|
+
const retries = args.network.retry?.retries ?? 0;
|
|
51
|
+
const delayMs = args.network.retry?.delayMs ?? 500;
|
|
52
|
+
const count = config.__retryCount ?? 0;
|
|
53
|
+
if (count < retries && shouldRetry(error)) {
|
|
54
|
+
config.__retryCount = count + 1;
|
|
55
|
+
await sleep(delayMs * (count + 1));
|
|
56
|
+
return instance.request(config);
|
|
57
|
+
}
|
|
58
|
+
return Promise.reject(error);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useCallback, useMemo, useState } from 'react';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export const AuthContext = /*#__PURE__*/createContext(null);
|
|
6
|
+
export function AuthProvider({
|
|
7
|
+
children
|
|
8
|
+
}) {
|
|
9
|
+
const [authToken, setAuthTokenState] = useState(null);
|
|
10
|
+
const setAuthToken = useCallback(token => {
|
|
11
|
+
setAuthTokenState(token);
|
|
12
|
+
}, []);
|
|
13
|
+
const value = useMemo(() => {
|
|
14
|
+
return {
|
|
15
|
+
authToken,
|
|
16
|
+
setAuthToken
|
|
17
|
+
};
|
|
18
|
+
}, [authToken, setAuthToken]);
|
|
19
|
+
return /*#__PURE__*/_jsx(AuthContext.Provider, {
|
|
20
|
+
value: value,
|
|
21
|
+
children: children
|
|
22
|
+
});
|
|
23
|
+
}
|