be-components 7.6.3 → 7.6.4

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 (138) hide show
  1. package/lib/commonjs/NotificationManager/NotificationManagerTabs.js +188 -0
  2. package/lib/commonjs/NotificationManager/NotificationManagerTabs.js.map +1 -0
  3. package/lib/commonjs/NotificationManager/api/index.js +235 -6
  4. package/lib/commonjs/NotificationManager/api/index.js.map +1 -1
  5. package/lib/commonjs/NotificationManager/components/GroupManagement.js +1038 -0
  6. package/lib/commonjs/NotificationManager/components/GroupManagement.js.map +1 -0
  7. package/lib/commonjs/NotificationManager/components/JobManagement.js +783 -0
  8. package/lib/commonjs/NotificationManager/components/JobManagement.js.map +1 -0
  9. package/lib/commonjs/NotificationManager/components/ScheduleNotification.js +407 -0
  10. package/lib/commonjs/NotificationManager/components/ScheduleNotification.js.map +1 -0
  11. package/lib/commonjs/NotificationManager/components/index.js +56 -0
  12. package/lib/commonjs/NotificationManager/components/index.js.map +1 -0
  13. package/lib/commonjs/NotificationManager/components/shared/DateTimePicker.js +113 -0
  14. package/lib/commonjs/NotificationManager/components/shared/DateTimePicker.js.map +1 -0
  15. package/lib/commonjs/NotificationManager/components/shared/GroupSelector.js +191 -0
  16. package/lib/commonjs/NotificationManager/components/shared/GroupSelector.js.map +1 -0
  17. package/lib/commonjs/NotificationManager/components/shared/NotificationBuilderForm.js +509 -0
  18. package/lib/commonjs/NotificationManager/components/shared/NotificationBuilderForm.js.map +1 -0
  19. package/lib/commonjs/NotificationManager/components/shared/StatusBadge.js +69 -0
  20. package/lib/commonjs/NotificationManager/components/shared/StatusBadge.js.map +1 -0
  21. package/lib/commonjs/NotificationManager/index.js +38 -23
  22. package/lib/commonjs/NotificationManager/index.js.map +1 -1
  23. package/lib/commonjs/index.js +7 -0
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/types.d.js +2 -0
  26. package/lib/commonjs/types.d.js.map +1 -1
  27. package/lib/module/NotificationManager/NotificationManagerTabs.js +180 -0
  28. package/lib/module/NotificationManager/NotificationManagerTabs.js.map +1 -0
  29. package/lib/module/NotificationManager/api/index.js +235 -6
  30. package/lib/module/NotificationManager/api/index.js.map +1 -1
  31. package/lib/module/NotificationManager/components/GroupManagement.js +1030 -0
  32. package/lib/module/NotificationManager/components/GroupManagement.js.map +1 -0
  33. package/lib/module/NotificationManager/components/JobManagement.js +775 -0
  34. package/lib/module/NotificationManager/components/JobManagement.js.map +1 -0
  35. package/lib/module/NotificationManager/components/ScheduleNotification.js +399 -0
  36. package/lib/module/NotificationManager/components/ScheduleNotification.js.map +1 -0
  37. package/lib/module/NotificationManager/components/index.js +8 -0
  38. package/lib/module/NotificationManager/components/index.js.map +1 -0
  39. package/lib/module/NotificationManager/components/shared/DateTimePicker.js +106 -0
  40. package/lib/module/NotificationManager/components/shared/DateTimePicker.js.map +1 -0
  41. package/lib/module/NotificationManager/components/shared/GroupSelector.js +184 -0
  42. package/lib/module/NotificationManager/components/shared/GroupSelector.js.map +1 -0
  43. package/lib/module/NotificationManager/components/shared/NotificationBuilderForm.js +501 -0
  44. package/lib/module/NotificationManager/components/shared/NotificationBuilderForm.js.map +1 -0
  45. package/lib/module/NotificationManager/components/shared/StatusBadge.js +62 -0
  46. package/lib/module/NotificationManager/components/shared/StatusBadge.js.map +1 -0
  47. package/lib/module/NotificationManager/index.js +32 -23
  48. package/lib/module/NotificationManager/index.js.map +1 -1
  49. package/lib/module/index.js +2 -1
  50. package/lib/module/index.js.map +1 -1
  51. package/lib/module/types.d.js +2 -0
  52. package/lib/module/types.d.js.map +1 -1
  53. package/lib/typescript/lib/commonjs/NotificationManager/NotificationManagerTabs.d.ts +17 -0
  54. package/lib/typescript/lib/commonjs/NotificationManager/NotificationManagerTabs.d.ts.map +1 -0
  55. package/lib/typescript/lib/commonjs/NotificationManager/api/index.d.ts +17 -2
  56. package/lib/typescript/lib/commonjs/NotificationManager/api/index.d.ts.map +1 -1
  57. package/lib/typescript/lib/commonjs/NotificationManager/components/GroupManagement.d.ts +6 -0
  58. package/lib/typescript/lib/commonjs/NotificationManager/components/GroupManagement.d.ts.map +1 -0
  59. package/lib/typescript/lib/commonjs/NotificationManager/components/JobManagement.d.ts +7 -0
  60. package/lib/typescript/lib/commonjs/NotificationManager/components/JobManagement.d.ts.map +1 -0
  61. package/lib/typescript/lib/commonjs/NotificationManager/components/ScheduleNotification.d.ts +8 -0
  62. package/lib/typescript/lib/commonjs/NotificationManager/components/ScheduleNotification.d.ts.map +1 -0
  63. package/lib/typescript/lib/commonjs/NotificationManager/components/index.d.ts +9 -0
  64. package/lib/typescript/lib/commonjs/NotificationManager/components/index.d.ts.map +1 -0
  65. package/lib/typescript/lib/commonjs/NotificationManager/components/shared/DateTimePicker.d.ts +9 -0
  66. package/lib/typescript/lib/commonjs/NotificationManager/components/shared/DateTimePicker.d.ts.map +1 -0
  67. package/lib/typescript/lib/commonjs/NotificationManager/components/shared/GroupSelector.d.ts +13 -0
  68. package/lib/typescript/lib/commonjs/NotificationManager/components/shared/GroupSelector.d.ts.map +1 -0
  69. package/lib/typescript/lib/commonjs/NotificationManager/components/shared/NotificationBuilderForm.d.ts +10 -0
  70. package/lib/typescript/lib/commonjs/NotificationManager/components/shared/NotificationBuilderForm.d.ts.map +1 -0
  71. package/lib/typescript/lib/commonjs/NotificationManager/components/shared/StatusBadge.d.ts +6 -0
  72. package/lib/typescript/lib/commonjs/NotificationManager/components/shared/StatusBadge.d.ts.map +1 -0
  73. package/lib/typescript/lib/commonjs/NotificationManager/index.d.ts +18 -2
  74. package/lib/typescript/lib/commonjs/NotificationManager/index.d.ts.map +1 -1
  75. package/lib/typescript/lib/commonjs/index.d.ts +18 -2
  76. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
  77. package/lib/typescript/lib/module/NotificationManager/NotificationManagerTabs.d.ts +17 -0
  78. package/lib/typescript/lib/module/NotificationManager/NotificationManagerTabs.d.ts.map +1 -0
  79. package/lib/typescript/lib/module/NotificationManager/api/index.d.ts +17 -2
  80. package/lib/typescript/lib/module/NotificationManager/api/index.d.ts.map +1 -1
  81. package/lib/typescript/lib/module/NotificationManager/components/GroupManagement.d.ts +6 -0
  82. package/lib/typescript/lib/module/NotificationManager/components/GroupManagement.d.ts.map +1 -0
  83. package/lib/typescript/lib/module/NotificationManager/components/JobManagement.d.ts +7 -0
  84. package/lib/typescript/lib/module/NotificationManager/components/JobManagement.d.ts.map +1 -0
  85. package/lib/typescript/lib/module/NotificationManager/components/ScheduleNotification.d.ts +8 -0
  86. package/lib/typescript/lib/module/NotificationManager/components/ScheduleNotification.d.ts.map +1 -0
  87. package/lib/typescript/lib/module/NotificationManager/components/index.d.ts +8 -0
  88. package/lib/typescript/lib/module/NotificationManager/components/index.d.ts.map +1 -0
  89. package/lib/typescript/lib/module/NotificationManager/components/shared/DateTimePicker.d.ts +9 -0
  90. package/lib/typescript/lib/module/NotificationManager/components/shared/DateTimePicker.d.ts.map +1 -0
  91. package/lib/typescript/lib/module/NotificationManager/components/shared/GroupSelector.d.ts +13 -0
  92. package/lib/typescript/lib/module/NotificationManager/components/shared/GroupSelector.d.ts.map +1 -0
  93. package/lib/typescript/lib/module/NotificationManager/components/shared/NotificationBuilderForm.d.ts +10 -0
  94. package/lib/typescript/lib/module/NotificationManager/components/shared/NotificationBuilderForm.d.ts.map +1 -0
  95. package/lib/typescript/lib/module/NotificationManager/components/shared/StatusBadge.d.ts +6 -0
  96. package/lib/typescript/lib/module/NotificationManager/components/shared/StatusBadge.d.ts.map +1 -0
  97. package/lib/typescript/lib/module/NotificationManager/index.d.ts +1 -0
  98. package/lib/typescript/lib/module/NotificationManager/index.d.ts.map +1 -1
  99. package/lib/typescript/lib/module/index.d.ts +2 -1
  100. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  101. package/lib/typescript/src/NotificationManager/NotificationManagerTabs.d.ts +20 -0
  102. package/lib/typescript/src/NotificationManager/NotificationManagerTabs.d.ts.map +1 -0
  103. package/lib/typescript/src/NotificationManager/api/index.d.ts +74 -3
  104. package/lib/typescript/src/NotificationManager/api/index.d.ts.map +1 -1
  105. package/lib/typescript/src/NotificationManager/components/GroupManagement.d.ts +8 -0
  106. package/lib/typescript/src/NotificationManager/components/GroupManagement.d.ts.map +1 -0
  107. package/lib/typescript/src/NotificationManager/components/JobManagement.d.ts +9 -0
  108. package/lib/typescript/src/NotificationManager/components/JobManagement.d.ts.map +1 -0
  109. package/lib/typescript/src/NotificationManager/components/ScheduleNotification.d.ts +10 -0
  110. package/lib/typescript/src/NotificationManager/components/ScheduleNotification.d.ts.map +1 -0
  111. package/lib/typescript/src/NotificationManager/components/index.d.ts +8 -0
  112. package/lib/typescript/src/NotificationManager/components/index.d.ts.map +1 -0
  113. package/lib/typescript/src/NotificationManager/components/shared/DateTimePicker.d.ts +12 -0
  114. package/lib/typescript/src/NotificationManager/components/shared/DateTimePicker.d.ts.map +1 -0
  115. package/lib/typescript/src/NotificationManager/components/shared/GroupSelector.d.ts +16 -0
  116. package/lib/typescript/src/NotificationManager/components/shared/GroupSelector.d.ts.map +1 -0
  117. package/lib/typescript/src/NotificationManager/components/shared/NotificationBuilderForm.d.ts +12 -0
  118. package/lib/typescript/src/NotificationManager/components/shared/NotificationBuilderForm.d.ts.map +1 -0
  119. package/lib/typescript/src/NotificationManager/components/shared/StatusBadge.d.ts +8 -0
  120. package/lib/typescript/src/NotificationManager/components/shared/StatusBadge.d.ts.map +1 -0
  121. package/lib/typescript/src/NotificationManager/index.d.ts +1 -0
  122. package/lib/typescript/src/NotificationManager/index.d.ts.map +1 -1
  123. package/lib/typescript/src/index.d.ts +2 -1
  124. package/lib/typescript/src/index.d.ts.map +1 -1
  125. package/package.json +1 -1
  126. package/src/NotificationManager/NotificationManagerTabs.tsx +178 -0
  127. package/src/NotificationManager/api/index.ts +239 -6
  128. package/src/NotificationManager/components/GroupManagement.tsx +854 -0
  129. package/src/NotificationManager/components/JobManagement.tsx +569 -0
  130. package/src/NotificationManager/components/ScheduleNotification.tsx +388 -0
  131. package/src/NotificationManager/components/index.ts +7 -0
  132. package/src/NotificationManager/components/shared/DateTimePicker.tsx +94 -0
  133. package/src/NotificationManager/components/shared/GroupSelector.tsx +130 -0
  134. package/src/NotificationManager/components/shared/NotificationBuilderForm.tsx +364 -0
  135. package/src/NotificationManager/components/shared/StatusBadge.tsx +72 -0
  136. package/src/NotificationManager/index.tsx +43 -24
  137. package/src/index.tsx +2 -0
  138. package/src/types.d.ts +38 -3
@@ -0,0 +1,783 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _Themed = require("../../Components/Themed");
10
+ var _useColors = require("../../constants/useColors");
11
+ var _api = require("../api");
12
+ var _ConfirmAlert = require("../../Components/ConfirmAlert");
13
+ var _Components = require("../../Components");
14
+ var _StatusBadge = _interopRequireDefault(require("./shared/StatusBadge"));
15
+ var _Dropdown = _interopRequireDefault(require("../../Components/Dropdown"));
16
+ var _Pagination = _interopRequireDefault(require("../../Components/Pagination"));
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
19
+ const STATUS_FILTERS = [{
20
+ label: 'All Jobs',
21
+ value: 'all'
22
+ }, {
23
+ label: 'Drafts',
24
+ value: 'pending'
25
+ }, {
26
+ label: 'Scheduled',
27
+ value: 'ready'
28
+ }, {
29
+ label: 'Sending',
30
+ value: 'processing'
31
+ }, {
32
+ label: 'Sent',
33
+ value: 'sent'
34
+ }, {
35
+ label: 'Failed',
36
+ value: 'failed'
37
+ }, {
38
+ label: 'Cancelled',
39
+ value: 'cancelled'
40
+ }];
41
+ const JobManagement = ({
42
+ onEditJob,
43
+ onFocusPosition
44
+ }) => {
45
+ const Colors = (0, _useColors.useColors)();
46
+ const [loading, setLoading] = (0, _react.useState)(false);
47
+ const [jobs, setJobs] = (0, _react.useState)([]);
48
+ const [groups, setGroups] = (0, _react.useState)([]);
49
+ const [statusFilter, setStatusFilter] = (0, _react.useState)('all');
50
+ const [selectedJob, setSelectedJob] = (0, _react.useState)(null);
51
+ const [showDetailsModal, setShowDetailsModal] = (0, _react.useState)(false);
52
+ const [autoRefreshEnabled, setAutoRefreshEnabled] = (0, _react.useState)(true);
53
+
54
+ // Pagination state
55
+ const [currentPage, setCurrentPage] = (0, _react.useState)(0);
56
+ const pageSize = 20;
57
+ const [hasMore, setHasMore] = (0, _react.useState)(false);
58
+
59
+ // Search state
60
+ const [searchQuery, setSearchQuery] = (0, _react.useState)('');
61
+ (0, _react.useEffect)(() => {
62
+ loadJobs();
63
+ loadGroups();
64
+ }, []);
65
+ (0, _react.useEffect)(() => {
66
+ // Reload jobs when status filter or current page changes
67
+ loadJobs();
68
+ }, [statusFilter, currentPage]);
69
+ (0, _react.useEffect)(() => {
70
+ // Auto-refresh every 30 seconds
71
+ if (!autoRefreshEnabled) return;
72
+ const interval = setInterval(() => {
73
+ loadJobs();
74
+ }, 30000);
75
+ return () => clearInterval(interval);
76
+ }, [autoRefreshEnabled, statusFilter, currentPage]);
77
+ const loadJobs = async () => {
78
+ setLoading(true);
79
+ const offset = currentPage * pageSize;
80
+ let fetchedJobs = [];
81
+ if (statusFilter === 'all') {
82
+ fetchedJobs = await _api.NotificationApi.getAllNotificationJobs(pageSize, offset);
83
+ } else {
84
+ fetchedJobs = await _api.NotificationApi.getNotificationJobsByStatus(statusFilter, pageSize, offset);
85
+ }
86
+
87
+ // Sort by scheduled_time descending (most recent first)
88
+ fetchedJobs.sort((a, b) => new Date(b.scheduled_time).getTime() - new Date(a.scheduled_time).getTime());
89
+
90
+ // Check if there are more results (if we got the full page size, there might be more)
91
+ setHasMore(fetchedJobs.length === pageSize);
92
+ setJobs(fetchedJobs);
93
+ setLoading(false);
94
+ };
95
+ const loadGroups = async () => {
96
+ const allGroups = await _api.NotificationApi.getAllNotificationGroups();
97
+ setGroups(allGroups);
98
+ };
99
+ const getGroupName = groupId => {
100
+ const group = groups.find(g => g.notification_group_id === groupId);
101
+ return group?.name || 'Unknown Group';
102
+ };
103
+ const handleStatusFilterChange = newStatus => {
104
+ setStatusFilter(newStatus);
105
+ setCurrentPage(0); // Reset to first page when filter changes
106
+ };
107
+ const handlePreviousPage = () => {
108
+ if (currentPage > 0) {
109
+ setCurrentPage(currentPage - 1);
110
+ }
111
+ };
112
+ const handleNextPage = () => {
113
+ if (hasMore) {
114
+ setCurrentPage(currentPage + 1);
115
+ }
116
+ };
117
+ const handleSelectPage = page => {
118
+ setCurrentPage(page);
119
+ };
120
+
121
+ // Client-side search filtering
122
+ const filteredJobs = _react.default.useMemo(() => {
123
+ if (!searchQuery.trim()) {
124
+ return jobs;
125
+ }
126
+ const query = searchQuery.toLowerCase();
127
+ return jobs.filter(job => {
128
+ const title = (job.notification.title || '').toLowerCase();
129
+ const body = (job.notification.body || '').toLowerCase();
130
+ return title.includes(query) || body.includes(query);
131
+ });
132
+ }, [jobs, searchQuery]);
133
+
134
+ // Build list data for FlatList
135
+ const listData = _react.default.useMemo(() => {
136
+ const data = [];
137
+
138
+ // Always add header, search, and filter sections
139
+ data.push({
140
+ type: 'header'
141
+ });
142
+ data.push({
143
+ type: 'search'
144
+ });
145
+ data.push({
146
+ type: 'filter'
147
+ });
148
+
149
+ // If loading, show loading indicator
150
+ if (loading) {
151
+ data.push({
152
+ type: 'loading'
153
+ });
154
+ return data;
155
+ }
156
+
157
+ // If no jobs, show empty state
158
+ if (filteredJobs.length === 0) {
159
+ data.push({
160
+ type: 'empty'
161
+ });
162
+ return data;
163
+ }
164
+
165
+ // Show results count
166
+ data.push({
167
+ type: 'results-count'
168
+ });
169
+
170
+ // Add all job items
171
+ filteredJobs.forEach(job => {
172
+ data.push({
173
+ type: 'job',
174
+ data: job
175
+ });
176
+ });
177
+
178
+ // Add pagination
179
+ data.push({
180
+ type: 'pagination'
181
+ });
182
+ return data;
183
+ }, [loading, filteredJobs, currentPage, searchQuery]);
184
+ const handleCancel = job => {
185
+ if (job.status !== 'pending' && job.status !== 'ready') {
186
+ alert('Only pending or scheduled jobs can be cancelled.');
187
+ return;
188
+ }
189
+ (0, _ConfirmAlert.showConfirmAlert)('Cancel Job', `Are you sure you want to cancel this scheduled notification?`, async () => {
190
+ try {
191
+ setLoading(true);
192
+ await _api.NotificationApi.cancelNotificationJob(job.notification_job_id);
193
+ await loadJobs();
194
+ } catch (error) {
195
+ console.error('Error cancelling job:', error);
196
+ alert('Failed to cancel job. Please try again.');
197
+ } finally {
198
+ setLoading(false);
199
+ }
200
+ });
201
+ };
202
+ const handleRetry = job => {
203
+ if (job.status !== 'failed') {
204
+ alert('Only failed jobs can be retried.');
205
+ return;
206
+ }
207
+ (0, _ConfirmAlert.showConfirmAlert)('Retry Failed Job', `This will create a new job with the same notification. The original failed job will remain in history.`, async () => {
208
+ try {
209
+ setLoading(true);
210
+ // Create a new job with same notification
211
+ await _api.NotificationApi.createNotificationJob({
212
+ notification_group_id: job.notification_group_id,
213
+ notification: job.notification,
214
+ scheduled_time: new Date(),
215
+ status: 'pending'
216
+ });
217
+ await loadJobs();
218
+ alert('New job created! Edit and finalize it when ready.');
219
+ } catch (error) {
220
+ console.error('Error retrying job:', error);
221
+ alert('Failed to create retry job. Please try again.');
222
+ } finally {
223
+ setLoading(false);
224
+ }
225
+ });
226
+ };
227
+ const handleViewDetails = job => {
228
+ setSelectedJob(job);
229
+ setShowDetailsModal(true);
230
+ };
231
+ const formatDateTime = dateTime => {
232
+ const date = new Date(dateTime);
233
+ return date.toLocaleString();
234
+ };
235
+
236
+ // Render functions for each section type
237
+ const renderHeader = () => /*#__PURE__*/_react.default.createElement(_Themed.View, {
238
+ type: "header",
239
+ style: {
240
+ flexDirection: 'row',
241
+ alignItems: 'center',
242
+ padding: 10
243
+ }
244
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
245
+ transparent: true,
246
+ style: {
247
+ flex: 1
248
+ }
249
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
250
+ theme: "h1"
251
+ }, "Manage Jobs"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
252
+ theme: "description",
253
+ style: {
254
+ marginTop: 3
255
+ }
256
+ }, "View and manage scheduled notifications")), /*#__PURE__*/_react.default.createElement(_Themed.View, {
257
+ transparent: true,
258
+ style: {
259
+ flexDirection: 'row',
260
+ alignItems: 'center'
261
+ }
262
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
263
+ onPress: () => setAutoRefreshEnabled(!autoRefreshEnabled),
264
+ style: {
265
+ padding: 8,
266
+ marginRight: 5
267
+ }
268
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
269
+ transparent: true,
270
+ style: {
271
+ flexDirection: 'row',
272
+ alignItems: 'center'
273
+ }
274
+ }, /*#__PURE__*/_react.default.createElement(_Components.Icons.RefreshIcon, {
275
+ size: 16,
276
+ color: autoRefreshEnabled ? Colors.text.success : Colors.text.h2
277
+ }), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
278
+ theme: "description",
279
+ color: autoRefreshEnabled ? Colors.text.success : Colors.text.h2,
280
+ style: {
281
+ marginLeft: 4,
282
+ fontSize: 11
283
+ }
284
+ }, "Auto"))), /*#__PURE__*/_react.default.createElement(_Themed.Button, {
285
+ type: "action",
286
+ onPress: loadJobs,
287
+ style: {
288
+ padding: 10,
289
+ marginLeft: 5,
290
+ flexDirection: 'row',
291
+ alignItems: 'center',
292
+ justifyContent: 'center'
293
+ }
294
+ }, /*#__PURE__*/_react.default.createElement(_Components.Icons.RefreshIcon, {
295
+ size: 14,
296
+ color: Colors.text.white
297
+ }), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
298
+ theme: "h2",
299
+ color: Colors.text.white,
300
+ style: {
301
+ marginLeft: 6
302
+ }
303
+ }, "Refresh"))));
304
+ const renderSearch = () => /*#__PURE__*/_react.default.createElement(_Themed.View, {
305
+ type: "row",
306
+ style: {
307
+ padding: 10,
308
+ margin: 10,
309
+ marginBottom: 5
310
+ }
311
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
312
+ transparent: true,
313
+ style: {
314
+ flex: 1,
315
+ flexDirection: 'row',
316
+ alignItems: 'center'
317
+ }
318
+ }, /*#__PURE__*/_react.default.createElement(_Components.Icons.SearchIcon, {
319
+ size: 16,
320
+ color: Colors.text.h2
321
+ }), /*#__PURE__*/_react.default.createElement(_Themed.TextInput, {
322
+ placeholder: "Search by title or message...",
323
+ value: searchQuery,
324
+ onChangeText: setSearchQuery,
325
+ onFocusPosition: onFocusPosition,
326
+ style: {
327
+ flex: 1,
328
+ padding: 10,
329
+ fontSize: 14,
330
+ marginLeft: 5
331
+ }
332
+ }), searchQuery.length > 0 && /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
333
+ onPress: () => setSearchQuery(''),
334
+ style: {
335
+ padding: 8
336
+ }
337
+ }, /*#__PURE__*/_react.default.createElement(_Components.Icons.CloseIcon, {
338
+ size: 14,
339
+ color: Colors.text.h2
340
+ }))));
341
+ const renderFilter = () => /*#__PURE__*/_react.default.createElement(_Themed.View, {
342
+ type: "row",
343
+ style: {
344
+ padding: 10,
345
+ margin: 10,
346
+ marginTop: 5
347
+ }
348
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
349
+ theme: "h2",
350
+ style: {
351
+ flex: 1
352
+ }
353
+ }, "Filter by Status"), /*#__PURE__*/_react.default.createElement(_Dropdown.default, {
354
+ selected_value: STATUS_FILTERS.find(f => f.value === statusFilter)?.label ?? 'All Jobs',
355
+ dropdown_options: [{
356
+ value: 'status',
357
+ eligible_options: STATUS_FILTERS.map(f => f.label)
358
+ }],
359
+ onOptionSelect: selected => {
360
+ const filter = STATUS_FILTERS.find(f => f.label === selected);
361
+ if (filter) {
362
+ handleStatusFilterChange(filter.value);
363
+ }
364
+ }
365
+ }));
366
+ const renderResultsCount = () => /*#__PURE__*/_react.default.createElement(_Themed.View, {
367
+ transparent: true,
368
+ style: {
369
+ paddingHorizontal: 20,
370
+ paddingVertical: 5
371
+ }
372
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
373
+ theme: "description",
374
+ style: {
375
+ fontSize: 12
376
+ }
377
+ }, "Showing ", filteredJobs.length, " result", filteredJobs.length !== 1 ? 's' : '', " on page ", currentPage + 1, searchQuery && ` (filtered by search)`));
378
+ const renderJobCard = job => {
379
+ const canCancel = job.status === 'pending' || job.status === 'ready';
380
+ const canEdit = job.status === 'pending';
381
+ const canRetry = job.status === 'failed';
382
+ return /*#__PURE__*/_react.default.createElement(_Themed.View, {
383
+ float: true,
384
+ style: {
385
+ padding: 15,
386
+ margin: 10,
387
+ borderRadius: 8
388
+ }
389
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
390
+ transparent: true,
391
+ style: {
392
+ flexDirection: 'row',
393
+ justifyContent: 'space-between',
394
+ marginBottom: 10
395
+ }
396
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
397
+ transparent: true,
398
+ style: {
399
+ flex: 1
400
+ }
401
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
402
+ transparent: true,
403
+ style: {
404
+ flexDirection: 'row',
405
+ alignItems: 'center',
406
+ marginBottom: 6
407
+ }
408
+ }, /*#__PURE__*/_react.default.createElement(_StatusBadge.default, {
409
+ status: job.status
410
+ }), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
411
+ theme: "h2",
412
+ style: {
413
+ marginLeft: 8,
414
+ flex: 1
415
+ }
416
+ }, getGroupName(job.notification_group_id))), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
417
+ theme: "h1",
418
+ style: {
419
+ marginBottom: 4
420
+ }
421
+ }, job.notification.title || 'No Title'), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
422
+ theme: "description",
423
+ numberOfLines: 2
424
+ }, job.notification.body || 'No message'), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
425
+ theme: "description",
426
+ style: {
427
+ marginTop: 6,
428
+ fontSize: 11
429
+ }
430
+ }, "Scheduled: ", formatDateTime(job.scheduled_time)), job.sent_datetime && /*#__PURE__*/_react.default.createElement(_Themed.Text, {
431
+ theme: "description",
432
+ style: {
433
+ fontSize: 11,
434
+ color: Colors.text.success
435
+ }
436
+ }, "Sent: ", formatDateTime(job.sent_datetime)), job.error_message && /*#__PURE__*/_react.default.createElement(_Themed.Text, {
437
+ theme: "description",
438
+ style: {
439
+ fontSize: 11,
440
+ color: Colors.text.error,
441
+ marginTop: 4
442
+ }
443
+ }, "Error: ", job.error_message))), /*#__PURE__*/_react.default.createElement(_Themed.View, {
444
+ transparent: true,
445
+ style: {
446
+ flexDirection: 'row',
447
+ flexWrap: 'wrap'
448
+ }
449
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Button, {
450
+ type: "action",
451
+ onPress: () => handleViewDetails(job),
452
+ style: {
453
+ flex: 1,
454
+ minWidth: 100,
455
+ padding: 10,
456
+ marginRight: 4,
457
+ flexDirection: 'row',
458
+ alignItems: 'center',
459
+ justifyContent: 'center'
460
+ }
461
+ }, /*#__PURE__*/_react.default.createElement(_Components.Icons.EyeOnIcon, {
462
+ size: 14,
463
+ color: Colors.text.white
464
+ }), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
465
+ theme: "h2",
466
+ color: Colors.text.white,
467
+ style: {
468
+ marginLeft: 6
469
+ }
470
+ }, "Details")), canEdit && onEditJob && /*#__PURE__*/_react.default.createElement(_Themed.Button, {
471
+ type: "success",
472
+ onPress: () => onEditJob(job),
473
+ style: {
474
+ flex: 1,
475
+ minWidth: 100,
476
+ padding: 10,
477
+ marginHorizontal: 4,
478
+ flexDirection: 'row',
479
+ alignItems: 'center',
480
+ justifyContent: 'center'
481
+ }
482
+ }, /*#__PURE__*/_react.default.createElement(_Components.Icons.EditIcon, {
483
+ size: 14,
484
+ color: Colors.text.white
485
+ }), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
486
+ theme: "h2",
487
+ color: Colors.text.white,
488
+ style: {
489
+ marginLeft: 6
490
+ }
491
+ }, "Edit")), canRetry && /*#__PURE__*/_react.default.createElement(_Themed.Button, {
492
+ type: "warning",
493
+ onPress: () => handleRetry(job),
494
+ style: {
495
+ flex: 1,
496
+ minWidth: 100,
497
+ padding: 10,
498
+ marginHorizontal: 4,
499
+ flexDirection: 'row',
500
+ alignItems: 'center',
501
+ justifyContent: 'center'
502
+ }
503
+ }, /*#__PURE__*/_react.default.createElement(_Components.Icons.RefreshIcon, {
504
+ size: 14,
505
+ color: Colors.text.white
506
+ }), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
507
+ theme: "h2",
508
+ color: Colors.text.white,
509
+ style: {
510
+ marginLeft: 6
511
+ }
512
+ }, "Retry")), canCancel && /*#__PURE__*/_react.default.createElement(_Themed.Button, {
513
+ type: "error",
514
+ onPress: () => handleCancel(job),
515
+ style: {
516
+ flex: 1,
517
+ minWidth: 100,
518
+ padding: 10,
519
+ marginLeft: 4,
520
+ flexDirection: 'row',
521
+ alignItems: 'center',
522
+ justifyContent: 'center'
523
+ }
524
+ }, /*#__PURE__*/_react.default.createElement(_Components.Icons.CloseIcon, {
525
+ size: 14,
526
+ color: Colors.text.white
527
+ }), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
528
+ theme: "h2",
529
+ color: Colors.text.white,
530
+ style: {
531
+ marginLeft: 6
532
+ }
533
+ }, "Cancel"))));
534
+ };
535
+ const renderEmpty = () => /*#__PURE__*/_react.default.createElement(_Themed.View, {
536
+ style: {
537
+ padding: 40,
538
+ alignItems: 'center'
539
+ }
540
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
541
+ theme: "description"
542
+ }, searchQuery ? 'No jobs match your search query.' : statusFilter === 'all' ? 'No jobs found. Schedule your first notification!' : `No ${STATUS_FILTERS.find(f => f.value === statusFilter)?.label.toLowerCase()} found.`));
543
+ const renderLoading = () => /*#__PURE__*/_react.default.createElement(_Themed.View, {
544
+ style: {
545
+ padding: 40,
546
+ justifyContent: 'center',
547
+ alignItems: 'center'
548
+ }
549
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, {
550
+ size: "large",
551
+ color: Colors.text.action
552
+ }));
553
+ const renderPagination = () => /*#__PURE__*/_react.default.createElement(_Themed.View, {
554
+ transparent: true,
555
+ style: {
556
+ padding: 15,
557
+ paddingBottom: 20
558
+ }
559
+ }, /*#__PURE__*/_react.default.createElement(_Pagination.default, {
560
+ offset: currentPage,
561
+ pages: hasMore ? currentPage + 2 : currentPage + 1,
562
+ onPrevious: handlePreviousPage,
563
+ onNext: handleNextPage,
564
+ onSelectPage: handleSelectPage
565
+ }));
566
+
567
+ // Main render item function with switch statement
568
+ const renderItem = ({
569
+ item
570
+ }) => {
571
+ switch (item.type) {
572
+ case 'header':
573
+ return renderHeader();
574
+ case 'search':
575
+ return renderSearch();
576
+ case 'filter':
577
+ return renderFilter();
578
+ case 'results-count':
579
+ return renderResultsCount();
580
+ case 'job':
581
+ return renderJobCard(item.data);
582
+ case 'empty':
583
+ return renderEmpty();
584
+ case 'loading':
585
+ return renderLoading();
586
+ case 'pagination':
587
+ return renderPagination();
588
+ default:
589
+ return null;
590
+ }
591
+ };
592
+ const getItemKey = (item, index) => {
593
+ if (item.type === 'job') {
594
+ return item.data.notification_job_id;
595
+ }
596
+ return `${item.type}-${index}`;
597
+ };
598
+ return /*#__PURE__*/_react.default.createElement(_Themed.View, {
599
+ style: {
600
+ flex: 1
601
+ }
602
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.FlatList, {
603
+ data: listData,
604
+ keyExtractor: getItemKey,
605
+ renderItem: renderItem,
606
+ showsVerticalScrollIndicator: true
607
+ }), showDetailsModal && selectedJob && /*#__PURE__*/_react.default.createElement(_Themed.View, {
608
+ type: "blur",
609
+ style: {
610
+ position: 'absolute',
611
+ top: 0,
612
+ left: 0,
613
+ right: 0,
614
+ bottom: 0,
615
+ padding: 20
616
+ }
617
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
618
+ float: true,
619
+ style: {
620
+ maxWidth: 600,
621
+ alignSelf: 'center',
622
+ width: '100%',
623
+ maxHeight: '80%'
624
+ }
625
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
626
+ type: "header",
627
+ style: {
628
+ flexDirection: 'row',
629
+ alignItems: 'center',
630
+ padding: 10,
631
+ borderTopRightRadius: 8,
632
+ borderTopLeftRadius: 8
633
+ }
634
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
635
+ transparent: true,
636
+ style: {
637
+ flex: 1
638
+ }
639
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
640
+ theme: "h1"
641
+ }, "Job Details"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
642
+ theme: "description",
643
+ style: {
644
+ marginTop: 3
645
+ }
646
+ }, "Full notification information")), /*#__PURE__*/_react.default.createElement(_StatusBadge.default, {
647
+ status: selectedJob.status
648
+ })), /*#__PURE__*/_react.default.createElement(_Themed.View, {
649
+ style: {
650
+ flex: 1,
651
+ padding: 15
652
+ }
653
+ }, /*#__PURE__*/_react.default.createElement(_Themed.View, {
654
+ transparent: true,
655
+ style: {
656
+ marginBottom: 15
657
+ }
658
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
659
+ theme: "h2",
660
+ style: {
661
+ marginBottom: 4
662
+ }
663
+ }, "Group"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
664
+ theme: "description"
665
+ }, getGroupName(selectedJob.notification_group_id))), /*#__PURE__*/_react.default.createElement(_Themed.View, {
666
+ transparent: true,
667
+ style: {
668
+ marginBottom: 15
669
+ }
670
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
671
+ theme: "h2",
672
+ style: {
673
+ marginBottom: 4
674
+ }
675
+ }, "Title"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
676
+ theme: "h1"
677
+ }, selectedJob.notification.title || 'No Title')), /*#__PURE__*/_react.default.createElement(_Themed.View, {
678
+ transparent: true,
679
+ style: {
680
+ marginBottom: 15
681
+ }
682
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
683
+ theme: "h2",
684
+ style: {
685
+ marginBottom: 4
686
+ }
687
+ }, "Message"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
688
+ theme: "description"
689
+ }, selectedJob.notification.body || 'No message')), /*#__PURE__*/_react.default.createElement(_Themed.View, {
690
+ transparent: true,
691
+ style: {
692
+ marginBottom: 15
693
+ }
694
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
695
+ theme: "h2",
696
+ style: {
697
+ marginBottom: 4
698
+ }
699
+ }, "Notification Type"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
700
+ theme: "description"
701
+ }, selectedJob.notification.type)), selectedJob.notification.options?.data?.path_name && /*#__PURE__*/_react.default.createElement(_Themed.View, {
702
+ transparent: true,
703
+ style: {
704
+ marginBottom: 15
705
+ }
706
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
707
+ theme: "h2",
708
+ style: {
709
+ marginBottom: 4
710
+ }
711
+ }, "Deep Link"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
712
+ theme: "description"
713
+ }, selectedJob.notification.options.data.path_name)), /*#__PURE__*/_react.default.createElement(_Themed.View, {
714
+ transparent: true,
715
+ style: {
716
+ marginBottom: 15
717
+ }
718
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
719
+ theme: "h2",
720
+ style: {
721
+ marginBottom: 4
722
+ }
723
+ }, "Scheduled Time"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
724
+ theme: "description"
725
+ }, formatDateTime(selectedJob.scheduled_time))), selectedJob.sent_datetime && /*#__PURE__*/_react.default.createElement(_Themed.View, {
726
+ transparent: true,
727
+ style: {
728
+ marginBottom: 15
729
+ }
730
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
731
+ theme: "h2",
732
+ style: {
733
+ marginBottom: 4
734
+ }
735
+ }, "Sent Time"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
736
+ theme: "description",
737
+ color: Colors.text.success
738
+ }, formatDateTime(selectedJob.sent_datetime))), selectedJob.error_message && /*#__PURE__*/_react.default.createElement(_Themed.View, {
739
+ transparent: true,
740
+ style: {
741
+ marginBottom: 15
742
+ }
743
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
744
+ theme: "h2",
745
+ style: {
746
+ marginBottom: 4,
747
+ color: Colors.text.error
748
+ }
749
+ }, "Error Message"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
750
+ theme: "description",
751
+ color: Colors.text.error
752
+ }, selectedJob.error_message)), /*#__PURE__*/_react.default.createElement(_Themed.View, {
753
+ transparent: true,
754
+ style: {
755
+ marginBottom: 15
756
+ }
757
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Text, {
758
+ theme: "h2",
759
+ style: {
760
+ marginBottom: 4
761
+ }
762
+ }, "Created"), /*#__PURE__*/_react.default.createElement(_Themed.Text, {
763
+ theme: "description"
764
+ }, formatDateTime(selectedJob.create_datetime)))), /*#__PURE__*/_react.default.createElement(_Themed.View, {
765
+ type: "footer",
766
+ style: {
767
+ flexDirection: 'row',
768
+ alignItems: 'center',
769
+ padding: 10,
770
+ borderBottomRightRadius: 8,
771
+ borderBottomLeftRadius: 8
772
+ }
773
+ }, /*#__PURE__*/_react.default.createElement(_Themed.Button, {
774
+ style: {
775
+ flex: 1
776
+ },
777
+ type: "close",
778
+ title: "CLOSE",
779
+ onPress: () => setShowDetailsModal(false)
780
+ })))));
781
+ };
782
+ var _default = exports.default = JobManagement;
783
+ //# sourceMappingURL=JobManagement.js.map