@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.
Files changed (146) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +413 -0
  3. package/lib/commonjs/core/api/apiClient.js +38 -0
  4. package/lib/commonjs/core/api/endpoints.js +139 -0
  5. package/lib/commonjs/core/api/interceptor.js +64 -0
  6. package/lib/commonjs/core/auth/authContext.js +30 -0
  7. package/lib/commonjs/core/auth/authService.js +12 -0
  8. package/lib/commonjs/core/hooks/useApiQuery.js +26 -0
  9. package/lib/commonjs/core/provider/ERPProvider.js +63 -0
  10. package/lib/commonjs/core/provider/types.js +5 -0
  11. package/lib/commonjs/core/provider/useERP.js +17 -0
  12. package/lib/commonjs/core/types/api.js +1 -0
  13. package/lib/commonjs/index.js +110 -0
  14. package/lib/commonjs/modules/assignment/hooks/useAssignmentList.js +16 -0
  15. package/lib/commonjs/modules/assignment/hooks/useHomeworkDetails.js +16 -0
  16. package/lib/commonjs/modules/assignment/hooks/useHomeworkSubmissions.js +16 -0
  17. package/lib/commonjs/modules/assignment/screens/AssignmentScreen.js +2615 -0
  18. package/lib/commonjs/modules/assignment/services/assignmentService.js +75 -0
  19. package/lib/commonjs/modules/attendance/hooks/useAttendance.js +16 -0
  20. package/lib/commonjs/modules/attendance/screens/AttendanceScreen.js +866 -0
  21. package/lib/commonjs/modules/attendance/services/attendanceService.js +31 -0
  22. package/lib/commonjs/modules/leaveRequest/hooks/useLeaveRequests.js +16 -0
  23. package/lib/commonjs/modules/leaveRequest/screens/LeaveRequestScreen.js +991 -0
  24. package/lib/commonjs/modules/leaveRequest/services/leaveRequestService.js +42 -0
  25. package/lib/commonjs/modules/marks/hooks/useMarks.js +14 -0
  26. package/lib/commonjs/modules/marks/screens/MarksScreen.js +1621 -0
  27. package/lib/commonjs/modules/marks/services/marksService.js +71 -0
  28. package/lib/commonjs/modules/myAttendance/hooks/useMyAttendance.js +16 -0
  29. package/lib/commonjs/modules/myAttendance/screens/MyAttendanceScreen.js +357 -0
  30. package/lib/commonjs/modules/myAttendance/services/myAttendanceService.js +11 -0
  31. package/lib/commonjs/modules/notes/hooks/useNotes.js +16 -0
  32. package/lib/commonjs/modules/notes/screens/NotesScreen.js +1287 -0
  33. package/lib/commonjs/modules/notes/services/notesService.js +65 -0
  34. package/lib/commonjs/modules/noticeboard/hooks/useNoticeboard.js +16 -0
  35. package/lib/commonjs/modules/noticeboard/screens/NoticeBoardScreen.js +381 -0
  36. package/lib/commonjs/modules/noticeboard/services/noticeboardService.js +16 -0
  37. package/lib/commonjs/modules/notification/hooks/useNotifications.js +16 -0
  38. package/lib/commonjs/modules/notification/screens/NotificationScreen.js +186 -0
  39. package/lib/commonjs/modules/notification/services/notificationService.js +16 -0
  40. package/lib/commonjs/modules/promoteStudent/hooks/usePromoteStudent.js +16 -0
  41. package/lib/commonjs/modules/promoteStudent/screens/PromoteStudentScreen.js +644 -0
  42. package/lib/commonjs/modules/promoteStudent/services/promoteStudentService.js +36 -0
  43. package/lib/commonjs/modules/timetable/hooks/useTimeTable.js +14 -0
  44. package/lib/commonjs/modules/timetable/screens/TimeTableScreen.js +258 -0
  45. package/lib/commonjs/modules/timetable/services/timetableService.js +16 -0
  46. package/lib/commonjs/package.json +1 -0
  47. package/lib/commonjs/shared/empty-states/EmptyState.js +45 -0
  48. package/lib/commonjs/shared/empty-states/ErrorState.js +45 -0
  49. package/lib/commonjs/shared/loaders/LoadingState.js +25 -0
  50. package/lib/commonjs/shared/theme/theme.js +22 -0
  51. package/lib/module/core/api/apiClient.js +32 -0
  52. package/lib/module/core/api/endpoints.js +135 -0
  53. package/lib/module/core/api/interceptor.js +60 -0
  54. package/lib/module/core/auth/authContext.js +23 -0
  55. package/lib/module/core/auth/authService.js +8 -0
  56. package/lib/module/core/hooks/useApiQuery.js +21 -0
  57. package/lib/module/core/provider/ERPProvider.js +56 -0
  58. package/lib/module/core/provider/types.js +3 -0
  59. package/lib/module/core/provider/useERP.js +12 -0
  60. package/lib/module/core/types/api.js +1 -0
  61. package/lib/module/index.js +17 -0
  62. package/lib/module/modules/assignment/hooks/useAssignmentList.js +12 -0
  63. package/lib/module/modules/assignment/hooks/useHomeworkDetails.js +12 -0
  64. package/lib/module/modules/assignment/hooks/useHomeworkSubmissions.js +12 -0
  65. package/lib/module/modules/assignment/screens/AssignmentScreen.js +2609 -0
  66. package/lib/module/modules/assignment/services/assignmentService.js +62 -0
  67. package/lib/module/modules/attendance/hooks/useAttendance.js +12 -0
  68. package/lib/module/modules/attendance/screens/AttendanceScreen.js +860 -0
  69. package/lib/module/modules/attendance/services/attendanceService.js +23 -0
  70. package/lib/module/modules/leaveRequest/hooks/useLeaveRequests.js +12 -0
  71. package/lib/module/modules/leaveRequest/screens/LeaveRequestScreen.js +985 -0
  72. package/lib/module/modules/leaveRequest/services/leaveRequestService.js +35 -0
  73. package/lib/module/modules/marks/hooks/useMarks.js +10 -0
  74. package/lib/module/modules/marks/screens/MarksScreen.js +1615 -0
  75. package/lib/module/modules/marks/services/marksService.js +55 -0
  76. package/lib/module/modules/myAttendance/hooks/useMyAttendance.js +12 -0
  77. package/lib/module/modules/myAttendance/screens/MyAttendanceScreen.js +351 -0
  78. package/lib/module/modules/myAttendance/services/myAttendanceService.js +7 -0
  79. package/lib/module/modules/notes/hooks/useNotes.js +12 -0
  80. package/lib/module/modules/notes/screens/NotesScreen.js +1281 -0
  81. package/lib/module/modules/notes/services/notesService.js +54 -0
  82. package/lib/module/modules/noticeboard/hooks/useNoticeboard.js +12 -0
  83. package/lib/module/modules/noticeboard/screens/NoticeBoardScreen.js +375 -0
  84. package/lib/module/modules/noticeboard/services/noticeboardService.js +12 -0
  85. package/lib/module/modules/notification/hooks/useNotifications.js +12 -0
  86. package/lib/module/modules/notification/screens/NotificationScreen.js +180 -0
  87. package/lib/module/modules/notification/services/notificationService.js +12 -0
  88. package/lib/module/modules/promoteStudent/hooks/usePromoteStudent.js +12 -0
  89. package/lib/module/modules/promoteStudent/screens/PromoteStudentScreen.js +638 -0
  90. package/lib/module/modules/promoteStudent/services/promoteStudentService.js +27 -0
  91. package/lib/module/modules/timetable/hooks/useTimeTable.js +10 -0
  92. package/lib/module/modules/timetable/screens/TimeTableScreen.js +252 -0
  93. package/lib/module/modules/timetable/services/timetableService.js +11 -0
  94. package/lib/module/package.json +1 -0
  95. package/lib/module/shared/empty-states/EmptyState.js +40 -0
  96. package/lib/module/shared/empty-states/ErrorState.js +40 -0
  97. package/lib/module/shared/loaders/LoadingState.js +20 -0
  98. package/lib/module/shared/theme/theme.js +18 -0
  99. package/lib/typescript/core/api/apiClient.d.ts +14 -0
  100. package/lib/typescript/core/api/endpoints.d.ts +164 -0
  101. package/lib/typescript/core/api/interceptor.d.ts +4 -0
  102. package/lib/typescript/core/auth/authContext.d.ts +11 -0
  103. package/lib/typescript/core/auth/authService.d.ts +9 -0
  104. package/lib/typescript/core/hooks/useApiQuery.d.ts +7 -0
  105. package/lib/typescript/core/provider/ERPProvider.d.ts +14 -0
  106. package/lib/typescript/core/provider/types.d.ts +34 -0
  107. package/lib/typescript/core/provider/useERP.d.ts +3 -0
  108. package/lib/typescript/core/types/api.d.ts +11 -0
  109. package/lib/typescript/index.d.ts +18 -0
  110. package/lib/typescript/modules/assignment/hooks/useAssignmentList.d.ts +3 -0
  111. package/lib/typescript/modules/assignment/hooks/useHomeworkDetails.d.ts +4 -0
  112. package/lib/typescript/modules/assignment/hooks/useHomeworkSubmissions.d.ts +4 -0
  113. package/lib/typescript/modules/assignment/screens/AssignmentScreen.d.ts +9 -0
  114. package/lib/typescript/modules/assignment/services/assignmentService.d.ts +89 -0
  115. package/lib/typescript/modules/attendance/hooks/useAttendance.d.ts +3 -0
  116. package/lib/typescript/modules/attendance/screens/AttendanceScreen.d.ts +5 -0
  117. package/lib/typescript/modules/attendance/services/attendanceService.d.ts +33 -0
  118. package/lib/typescript/modules/leaveRequest/hooks/useLeaveRequests.d.ts +3 -0
  119. package/lib/typescript/modules/leaveRequest/screens/LeaveRequestScreen.d.ts +5 -0
  120. package/lib/typescript/modules/leaveRequest/services/leaveRequestService.d.ts +39 -0
  121. package/lib/typescript/modules/marks/hooks/useMarks.d.ts +2 -0
  122. package/lib/typescript/modules/marks/screens/MarksScreen.d.ts +6 -0
  123. package/lib/typescript/modules/marks/services/marksService.d.ts +150 -0
  124. package/lib/typescript/modules/myAttendance/hooks/useMyAttendance.d.ts +3 -0
  125. package/lib/typescript/modules/myAttendance/screens/MyAttendanceScreen.d.ts +5 -0
  126. package/lib/typescript/modules/myAttendance/services/myAttendanceService.d.ts +10 -0
  127. package/lib/typescript/modules/notes/hooks/useNotes.d.ts +3 -0
  128. package/lib/typescript/modules/notes/screens/NotesScreen.d.ts +8 -0
  129. package/lib/typescript/modules/notes/services/notesService.d.ts +58 -0
  130. package/lib/typescript/modules/noticeboard/hooks/useNoticeboard.d.ts +3 -0
  131. package/lib/typescript/modules/noticeboard/screens/NoticeBoardScreen.d.ts +5 -0
  132. package/lib/typescript/modules/noticeboard/services/noticeboardService.d.ts +17 -0
  133. package/lib/typescript/modules/notification/hooks/useNotifications.d.ts +3 -0
  134. package/lib/typescript/modules/notification/screens/NotificationScreen.d.ts +5 -0
  135. package/lib/typescript/modules/notification/services/notificationService.d.ts +8 -0
  136. package/lib/typescript/modules/promoteStudent/hooks/usePromoteStudent.d.ts +3 -0
  137. package/lib/typescript/modules/promoteStudent/screens/PromoteStudentScreen.d.ts +5 -0
  138. package/lib/typescript/modules/promoteStudent/services/promoteStudentService.d.ts +40 -0
  139. package/lib/typescript/modules/timetable/hooks/useTimeTable.d.ts +3 -0
  140. package/lib/typescript/modules/timetable/screens/TimeTableScreen.d.ts +5 -0
  141. package/lib/typescript/modules/timetable/services/timetableService.d.ts +14 -0
  142. package/lib/typescript/shared/empty-states/EmptyState.d.ts +6 -0
  143. package/lib/typescript/shared/empty-states/ErrorState.d.ts +6 -0
  144. package/lib/typescript/shared/loaders/LoadingState.d.ts +3 -0
  145. package/lib/typescript/shared/theme/theme.d.ts +17 -0
  146. package/package.json +89 -0
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createNote = createNote;
7
+ exports.fetchNoteDetails = fetchNoteDetails;
8
+ exports.fetchNotesClasses = fetchNotesClasses;
9
+ exports.fetchNotesList = fetchNotesList;
10
+ exports.fetchNotesSections = fetchNotesSections;
11
+ exports.fetchNotesSubjects = fetchNotesSubjects;
12
+ exports.updateNote = updateNote;
13
+ exports.uploadNoteFile = uploadNoteFile;
14
+ var _endpoints = require("../../../core/api/endpoints");
15
+ async function fetchNotesList(api, params) {
16
+ const page = params.page ?? 1;
17
+ const perPage = params.perPage ?? 10;
18
+ const res = await api.get(_endpoints.endpoints.notes.listByClassSection({
19
+ page,
20
+ perPage,
21
+ classId: params.classId,
22
+ sectionId: params.sectionId,
23
+ subjectId: params.subjectId
24
+ }));
25
+ return res.data;
26
+ }
27
+ async function fetchNotesClasses(api) {
28
+ const res = await api.get(_endpoints.endpoints.notes.classDropdown);
29
+ return res.data;
30
+ }
31
+ async function fetchNotesSections(api, args) {
32
+ const res = await api.get(_endpoints.endpoints.notes.sectionDropdown(args));
33
+ return res.data;
34
+ }
35
+ async function fetchNotesSubjects(api, args) {
36
+ const res = await api.get(_endpoints.endpoints.notes.teacherSubjectsByClass(args));
37
+ return res.data;
38
+ }
39
+ async function fetchNoteDetails(api, args) {
40
+ const res = await api.get(_endpoints.endpoints.notes.details(args));
41
+ return res.data;
42
+ }
43
+ async function uploadNoteFile(api, file) {
44
+ const formData = new FormData();
45
+ formData.append('file', {
46
+ uri: file.uri,
47
+ name: file.name,
48
+ type: file.type
49
+ });
50
+ formData.append('filepath', 'uploads/student/note/');
51
+ const res = await api.post(_endpoints.endpoints.notes.upload, formData, {
52
+ headers: {
53
+ 'Content-Type': 'multipart/form-data'
54
+ }
55
+ });
56
+ return res.data;
57
+ }
58
+ async function createNote(api, payload) {
59
+ const res = await api.post(_endpoints.endpoints.notes.add, payload);
60
+ return res.data;
61
+ }
62
+ async function updateNote(api, payload) {
63
+ const res = await api.post(_endpoints.endpoints.notes.update, payload);
64
+ return res.data;
65
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useNoticeboardList = useNoticeboardList;
7
+ var _useApiQuery = require("../../../core/hooks/useApiQuery");
8
+ var _noticeboardService = require("../services/noticeboardService");
9
+ function useNoticeboardList(params) {
10
+ const page = params.page ?? 1;
11
+ const perPage = params.perPage ?? 10;
12
+ return (0, _useApiQuery.useApiQuery)({
13
+ queryKey: ['noticeboard', 'list', page, perPage],
14
+ queryFn: api => (0, _noticeboardService.fetchNoticeboardList)(api, params)
15
+ });
16
+ }
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NoticeBoardScreen = NoticeBoardScreen;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _useERP = require("../../../core/provider/useERP");
10
+ var _noticeboardService = require("../services/noticeboardService");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ 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); }
13
+ 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; }
14
+ function getNoticeMessage(item) {
15
+ return String(item?.message ?? item?.description ?? '');
16
+ }
17
+ function getNoticeDate(item) {
18
+ return String(item?.date ?? item?.created_at ?? '');
19
+ }
20
+ function getNoticeTitle(item) {
21
+ return String(item?.title ?? 'Notice');
22
+ }
23
+ function getNoticePreview(item) {
24
+ const message = getNoticeMessage(item);
25
+ if (!message) {
26
+ return '.....';
27
+ }
28
+ let preview = '';
29
+ for (let index = 0; index < 40 && index < message.length; index += 1) {
30
+ preview += message[index];
31
+ }
32
+ return `${preview}.....`;
33
+ }
34
+ function NoticeBoardScreen(props) {
35
+ const {
36
+ api
37
+ } = (0, _useERP.useERP)();
38
+ const initialPage = props.page ?? 1;
39
+ const perPage = props.perPage ?? 10;
40
+ const [notices, setNotices] = (0, _react.useState)([]);
41
+ const [selectedNotice, setSelectedNotice] = (0, _react.useState)(null);
42
+ const [currentPage, setCurrentPage] = (0, _react.useState)(initialPage);
43
+ const [homeworkAvailability, setHomeworkAvailability] = (0, _react.useState)(true);
44
+ const [totalPage, setTotalPage] = (0, _react.useState)(1);
45
+ const [loaded, setLoaded] = (0, _react.useState)(false);
46
+ const getNotices = (0, _react.useCallback)(async (pageToLoad, reset = false) => {
47
+ try {
48
+ const res = await (0, _noticeboardService.fetchNoticeboardList)(api, {
49
+ page: pageToLoad,
50
+ perPage
51
+ });
52
+ const list = Array.isArray(res?.data) ? res.data : [];
53
+ const pages = Number(res?.pagination?.total_pages ?? 1) || 1;
54
+ if (list.length > 0) {
55
+ setNotices(prev => reset ? list : [...prev, ...list]);
56
+ setTotalPage(pages);
57
+ setLoaded(true);
58
+ return;
59
+ }
60
+ setLoaded(true);
61
+ setTotalPage(pages);
62
+ if (reset) {
63
+ setNotices([]);
64
+ }
65
+ } catch (e) {
66
+ console.log('noticeboard_error', e?.message ?? e);
67
+ setLoaded(true);
68
+ if (reset) {
69
+ setNotices([]);
70
+ }
71
+ }
72
+ }, [api, perPage]);
73
+ (0, _react.useEffect)(() => {
74
+ setNotices([]);
75
+ setCurrentPage(initialPage);
76
+ setHomeworkAvailability(true);
77
+ setTotalPage(1);
78
+ setLoaded(false);
79
+ }, [initialPage, perPage]);
80
+ (0, _react.useEffect)(() => {
81
+ if (homeworkAvailability) {
82
+ getNotices(currentPage, currentPage === initialPage).catch(() => {});
83
+ }
84
+ }, [currentPage, getNotices, homeworkAvailability, initialPage]);
85
+ const renderItem = ({
86
+ item
87
+ }) => {
88
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
89
+ style: styles.card,
90
+ activeOpacity: 0.85,
91
+ onPress: () => setSelectedNotice(item),
92
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
93
+ style: styles.cardHeader,
94
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
95
+ style: styles.cardTitle,
96
+ children: getNoticeTitle(item)
97
+ })
98
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
99
+ style: styles.cardDesc,
100
+ children: getNoticePreview(item)
101
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
102
+ style: styles.dateRow,
103
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
104
+ style: styles.cardDate,
105
+ children: getNoticeDate(item)
106
+ })
107
+ })]
108
+ });
109
+ };
110
+ const renderFooter = () => {
111
+ if (!homeworkAvailability) {
112
+ return null;
113
+ }
114
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
115
+ style: styles.footer,
116
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
117
+ color: "#1D4ED8",
118
+ size: "large"
119
+ })
120
+ });
121
+ };
122
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.SafeAreaView, {
123
+ style: styles.root,
124
+ children: [!loaded ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
125
+ style: styles.centerState,
126
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
127
+ size: "large",
128
+ color: "#1D4ED8"
129
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
130
+ style: styles.loadingText,
131
+ children: "Loading"
132
+ })]
133
+ }) : notices.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
134
+ style: styles.centerState,
135
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
136
+ style: styles.emptyText,
137
+ children: "No Data Found"
138
+ })
139
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
140
+ data: notices,
141
+ keyExtractor: (item, index) => String(item?.id ?? `${index}-${getNoticeDate(item) || 'row'}`),
142
+ renderItem: renderItem,
143
+ ListFooterComponent: renderFooter,
144
+ onEndReached: () => {
145
+ if (totalPage !== currentPage) {
146
+ setCurrentPage(prevPage => prevPage + 1);
147
+ setHomeworkAvailability(true);
148
+ } else {
149
+ setHomeworkAvailability(false);
150
+ }
151
+ },
152
+ onEndReachedThreshold: 0.2,
153
+ style: styles.list
154
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
155
+ visible: selectedNotice !== null,
156
+ animationType: "slide",
157
+ onRequestClose: () => setSelectedNotice(null),
158
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.SafeAreaView, {
159
+ style: styles.detailRoot,
160
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
161
+ style: styles.detailHeader,
162
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
163
+ style: styles.detailHeaderTitle,
164
+ children: "Notice Details"
165
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
166
+ style: styles.closeBtn,
167
+ onPress: () => setSelectedNotice(null),
168
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
169
+ style: styles.closeBtnText,
170
+ children: "Close"
171
+ })
172
+ })]
173
+ }), selectedNotice ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
174
+ style: styles.detailScroll,
175
+ contentContainerStyle: styles.detailScreenContent,
176
+ showsVerticalScrollIndicator: false,
177
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
178
+ style: styles.detailContainer,
179
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
180
+ style: styles.detailMetaRow,
181
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
182
+ style: styles.noticeBadge,
183
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
184
+ style: styles.noticeBadgeText,
185
+ children: "NOTICE"
186
+ })
187
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
188
+ style: styles.detailTopDate,
189
+ children: getNoticeDate(selectedNotice)
190
+ })]
191
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
192
+ style: styles.detailTitle,
193
+ children: getNoticeTitle(selectedNotice)
194
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
195
+ style: styles.messageCard,
196
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
197
+ style: styles.messageLabel,
198
+ children: "Message"
199
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
200
+ style: styles.detailDesc,
201
+ children: getNoticeMessage(selectedNotice) || '-'
202
+ })]
203
+ })]
204
+ })
205
+ }) : null]
206
+ })
207
+ })]
208
+ });
209
+ }
210
+ const styles = _reactNative.StyleSheet.create({
211
+ root: {
212
+ flex: 1,
213
+ backgroundColor: '#F3F4F6'
214
+ },
215
+ centerState: {
216
+ flex: 1,
217
+ alignItems: 'center',
218
+ justifyContent: 'center',
219
+ gap: 10
220
+ },
221
+ loadingText: {
222
+ fontSize: 16,
223
+ fontWeight: '600',
224
+ color: '#1D4ED8'
225
+ },
226
+ list: {
227
+ marginBottom: 90
228
+ },
229
+ card: {
230
+ backgroundColor: '#FFFFFF',
231
+ width: '90%',
232
+ alignSelf: 'center',
233
+ marginVertical: 8,
234
+ borderRadius: 5,
235
+ padding: 20,
236
+ elevation: 1,
237
+ shadowColor: '#000000',
238
+ shadowOpacity: 0.06,
239
+ shadowRadius: 4,
240
+ shadowOffset: {
241
+ width: 0,
242
+ height: 2
243
+ }
244
+ },
245
+ cardHeader: {
246
+ flexDirection: 'row',
247
+ alignItems: 'center',
248
+ justifyContent: 'space-between',
249
+ marginBottom: 10
250
+ },
251
+ cardTitle: {
252
+ flex: 1,
253
+ fontSize: 18,
254
+ fontWeight: '700',
255
+ color: '#1D4ED8'
256
+ },
257
+ cardDesc: {
258
+ fontSize: 16,
259
+ lineHeight: 22,
260
+ color: '#111827'
261
+ },
262
+ dateRow: {
263
+ flexDirection: 'row',
264
+ justifyContent: 'flex-end',
265
+ marginTop: 8
266
+ },
267
+ cardDate: {
268
+ fontSize: 16,
269
+ color: '#1D4ED8'
270
+ },
271
+ emptyText: {
272
+ fontSize: 20,
273
+ color: '#1D4ED8',
274
+ fontWeight: '700',
275
+ textAlign: 'center'
276
+ },
277
+ footer: {
278
+ paddingVertical: 16
279
+ },
280
+ detailRoot: {
281
+ flex: 1,
282
+ backgroundColor: '#F8FAFC'
283
+ },
284
+ detailHeader: {
285
+ minHeight: 58,
286
+ paddingHorizontal: 16,
287
+ paddingVertical: 10,
288
+ borderBottomWidth: 1,
289
+ borderBottomColor: '#E5E7EB',
290
+ flexDirection: 'row',
291
+ alignItems: 'center',
292
+ justifyContent: 'space-between'
293
+ },
294
+ detailHeaderTitle: {
295
+ fontSize: 18,
296
+ fontWeight: '700',
297
+ color: '#111827'
298
+ },
299
+ detailContainer: {
300
+ width: '92%',
301
+ alignSelf: 'center',
302
+ marginTop: 16
303
+ },
304
+ closeBtn: {
305
+ borderWidth: 1,
306
+ borderColor: '#BFDBFE',
307
+ backgroundColor: '#EFF6FF',
308
+ borderRadius: 10,
309
+ paddingHorizontal: 14,
310
+ paddingVertical: 8
311
+ },
312
+ closeBtnText: {
313
+ fontSize: 14,
314
+ fontWeight: '700',
315
+ color: '#1D4ED8'
316
+ },
317
+ detailScreenContent: {
318
+ paddingBottom: 32
319
+ },
320
+ detailMetaRow: {
321
+ flexDirection: 'row',
322
+ alignItems: 'center',
323
+ justifyContent: 'space-between',
324
+ marginBottom: 16
325
+ },
326
+ noticeBadge: {
327
+ borderRadius: 999,
328
+ backgroundColor: '#DBEAFE',
329
+ paddingHorizontal: 12,
330
+ paddingVertical: 6
331
+ },
332
+ noticeBadgeText: {
333
+ fontSize: 12,
334
+ fontWeight: '700',
335
+ color: '#1D4ED8',
336
+ letterSpacing: 0.8
337
+ },
338
+ detailTopDate: {
339
+ color: '#1D4ED8',
340
+ fontSize: 14,
341
+ fontWeight: '600'
342
+ },
343
+ detailTitle: {
344
+ fontSize: 28,
345
+ fontWeight: '700',
346
+ color: '#111827',
347
+ lineHeight: 36,
348
+ marginBottom: 18
349
+ },
350
+ detailScroll: {
351
+ flex: 1
352
+ },
353
+ messageCard: {
354
+ backgroundColor: '#FFFFFF',
355
+ borderRadius: 18,
356
+ paddingHorizontal: 18,
357
+ paddingVertical: 18,
358
+ borderWidth: 1,
359
+ borderColor: '#E5E7EB',
360
+ shadowColor: '#0F172A',
361
+ shadowOpacity: 0.06,
362
+ shadowRadius: 10,
363
+ shadowOffset: {
364
+ width: 0,
365
+ height: 4
366
+ },
367
+ elevation: 2
368
+ },
369
+ messageLabel: {
370
+ fontSize: 13,
371
+ fontWeight: '700',
372
+ color: '#64748B',
373
+ marginBottom: 10,
374
+ textTransform: 'uppercase'
375
+ },
376
+ detailDesc: {
377
+ fontSize: 21,
378
+ lineHeight: 32,
379
+ color: '#0F172A'
380
+ }
381
+ });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchNoticeboardList = fetchNoticeboardList;
7
+ var _endpoints = require("../../../core/api/endpoints");
8
+ async function fetchNoticeboardList(api, params) {
9
+ const page = params.page ?? 1;
10
+ const perPage = params.perPage ?? 10;
11
+ const res = await api.get(_endpoints.endpoints.noticeboard.list({
12
+ page,
13
+ perPage
14
+ }));
15
+ return res.data;
16
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useNotifications = useNotifications;
7
+ var _useApiQuery = require("../../../core/hooks/useApiQuery");
8
+ var _notificationService = require("../services/notificationService");
9
+ function useNotifications(params) {
10
+ const page = params.page ?? 1;
11
+ const perPage = params.perPage ?? 10;
12
+ return (0, _useApiQuery.useApiQuery)({
13
+ queryKey: ['notification', 'list', page, perPage],
14
+ queryFn: api => (0, _notificationService.fetchNotificationList)(api, params)
15
+ });
16
+ }
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NotificationScreen = NotificationScreen;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _useERP = require("../../../core/provider/useERP");
10
+ var _ErrorState = require("../../../shared/empty-states/ErrorState");
11
+ var _notificationService = require("../services/notificationService");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ 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); }
14
+ 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; }
15
+ function NotificationScreen(props) {
16
+ const {
17
+ api
18
+ } = (0, _useERP.useERP)();
19
+ const perPage = props.perPage ?? 10;
20
+ const initialPage = props.page ?? 1;
21
+ const [items, setItems] = (0, _react.useState)([]);
22
+ const [page, setPage] = (0, _react.useState)(initialPage);
23
+ const [totalPages, setTotalPages] = (0, _react.useState)(1);
24
+ const [loading, setLoading] = (0, _react.useState)(true);
25
+ const [refreshing, setRefreshing] = (0, _react.useState)(false);
26
+ const [loadingMore, setLoadingMore] = (0, _react.useState)(false);
27
+ const [error, setError] = (0, _react.useState)(null);
28
+ const hasMore = (0, _react.useMemo)(() => page < totalPages, [page, totalPages]);
29
+ const loadPage = (0, _react.useCallback)(async (nextPage, reset = false) => {
30
+ try {
31
+ if (reset) {
32
+ setRefreshing(true);
33
+ setError(null);
34
+ } else if (nextPage === initialPage && !items.length) {
35
+ setLoading(true);
36
+ setError(null);
37
+ } else {
38
+ setLoadingMore(true);
39
+ }
40
+ const res = await (0, _notificationService.fetchNotificationList)(api, {
41
+ page: nextPage,
42
+ perPage
43
+ });
44
+ const list = Array.isArray(res?.data) ? res.data : [];
45
+ const pages = Number(res?.pagination?.total_pages ?? 1);
46
+ setTotalPages(pages > 0 ? pages : 1);
47
+ setPage(nextPage);
48
+ setItems(prev => reset ? list : [...prev, ...list]);
49
+ } catch (e) {
50
+ setError(String(e?.message ?? 'Could not load notifications'));
51
+ } finally {
52
+ setLoading(false);
53
+ setRefreshing(false);
54
+ setLoadingMore(false);
55
+ }
56
+ }, [api, initialPage, items.length, perPage]);
57
+ (0, _react.useEffect)(() => {
58
+ setItems([]);
59
+ setPage(initialPage);
60
+ setTotalPages(1);
61
+ loadPage(initialPage, true).catch(() => {});
62
+ }, [initialPage, loadPage, perPage]);
63
+ if (error && !items.length) {
64
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorState.ErrorState, {
65
+ message: error
66
+ });
67
+ }
68
+ const renderItem = ({
69
+ item
70
+ }) => {
71
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
72
+ style: styles.card,
73
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
74
+ style: styles.cardTitle,
75
+ children: String(item?.title ?? 'Notification')
76
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
77
+ style: styles.cardMessage,
78
+ children: String(item?.message ?? '-')
79
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
80
+ style: styles.cardDate,
81
+ children: String(item?.created_at ?? '')
82
+ })]
83
+ });
84
+ };
85
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.SafeAreaView, {
86
+ style: styles.root,
87
+ children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
88
+ style: styles.loaderWrap,
89
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
90
+ size: "large",
91
+ color: "#1D4ED8"
92
+ })
93
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
94
+ data: items,
95
+ keyExtractor: (item, index) => String(item?.id ?? `${index}-${item?.created_at ?? 'row'}`),
96
+ renderItem: renderItem,
97
+ contentContainerStyle: items.length ? styles.content : styles.emptyWrap,
98
+ refreshControl: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.RefreshControl, {
99
+ refreshing: refreshing,
100
+ onRefresh: () => {
101
+ loadPage(initialPage, true).catch(() => {});
102
+ },
103
+ tintColor: "#1D4ED8"
104
+ }),
105
+ onEndReached: () => {
106
+ if (!loadingMore && hasMore) {
107
+ loadPage(page + 1).catch(() => {});
108
+ }
109
+ },
110
+ onEndReachedThreshold: 0.4,
111
+ ListHeaderComponent: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
112
+ style: styles.title,
113
+ children: "Notifications"
114
+ }),
115
+ ListEmptyComponent: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
116
+ style: styles.emptyText,
117
+ children: "No Data Found"
118
+ }),
119
+ ListFooterComponent: loadingMore ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
120
+ style: styles.footer,
121
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
122
+ color: "#1D4ED8"
123
+ })
124
+ }) : null
125
+ })
126
+ });
127
+ }
128
+ const styles = _reactNative.StyleSheet.create({
129
+ root: {
130
+ flex: 1,
131
+ backgroundColor: '#F9FAFB'
132
+ },
133
+ content: {
134
+ padding: 16,
135
+ paddingBottom: 32
136
+ },
137
+ emptyWrap: {
138
+ flexGrow: 1,
139
+ padding: 16,
140
+ justifyContent: 'center'
141
+ },
142
+ loaderWrap: {
143
+ flex: 1,
144
+ alignItems: 'center',
145
+ justifyContent: 'center'
146
+ },
147
+ title: {
148
+ fontSize: 20,
149
+ fontWeight: '700',
150
+ color: '#111827',
151
+ marginBottom: 12
152
+ },
153
+ card: {
154
+ backgroundColor: '#FFFFFF',
155
+ borderRadius: 12,
156
+ padding: 14,
157
+ marginBottom: 12,
158
+ borderWidth: 1,
159
+ borderColor: '#E5E7EB'
160
+ },
161
+ cardTitle: {
162
+ fontSize: 16,
163
+ fontWeight: '700',
164
+ color: '#1D4ED8',
165
+ marginBottom: 6
166
+ },
167
+ cardMessage: {
168
+ fontSize: 14,
169
+ lineHeight: 20,
170
+ color: '#111827'
171
+ },
172
+ cardDate: {
173
+ fontSize: 12,
174
+ color: '#2563EB',
175
+ textAlign: 'right',
176
+ marginTop: 8
177
+ },
178
+ emptyText: {
179
+ fontSize: 16,
180
+ color: '#6B7280',
181
+ textAlign: 'center'
182
+ },
183
+ footer: {
184
+ paddingVertical: 16
185
+ }
186
+ });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchNotificationList = fetchNotificationList;
7
+ var _endpoints = require("../../../core/api/endpoints");
8
+ async function fetchNotificationList(api, params) {
9
+ const page = params.page ?? 1;
10
+ const perPage = params.perPage ?? 10;
11
+ const res = await api.get(_endpoints.endpoints.notification.list({
12
+ page,
13
+ perPage
14
+ }));
15
+ return res.data;
16
+ }