powr-sdk-web 3.3.2 → 3.3.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.
- package/dist/invoices/admin.js +34 -63
- package/dist/notifications/admin.js +32 -55
- package/package.json +2 -2
package/dist/invoices/admin.js
CHANGED
|
@@ -29,7 +29,6 @@ var PowrBaseInvoicesAdmin = function PowrBaseInvoicesAdmin(_ref) {
|
|
|
29
29
|
apiUrl = _ref.apiUrl,
|
|
30
30
|
onInvoiceAction = _ref.onInvoiceAction,
|
|
31
31
|
onRefresh = _ref.onRefresh;
|
|
32
|
-
console.log('PowrBaseInvoicesAdmin rendering with projectId:', projectId);
|
|
33
32
|
var _useState = (0, _react.useState)([]),
|
|
34
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
34
|
invoices = _useState2[0],
|
|
@@ -107,52 +106,41 @@ var PowrBaseInvoicesAdmin = function PowrBaseInvoicesAdmin(_ref) {
|
|
|
107
106
|
return _regenerator().w(function (_context) {
|
|
108
107
|
while (1) switch (_context.n) {
|
|
109
108
|
case 0:
|
|
110
|
-
console.log('fetchInvoices called with projectId:', projectId);
|
|
111
|
-
if (projectId) {
|
|
112
|
-
_context.n = 1;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
return _context.a(2);
|
|
116
|
-
case 1:
|
|
117
109
|
setLoading(true);
|
|
118
110
|
setError(null);
|
|
119
|
-
_context.p =
|
|
120
|
-
|
|
121
|
-
_context.n = 3;
|
|
111
|
+
_context.p = 1;
|
|
112
|
+
_context.n = 2;
|
|
122
113
|
return (0, _auth.apiCall)(apiUrl, "/invoices", projectId);
|
|
123
|
-
case
|
|
114
|
+
case 2:
|
|
124
115
|
_yield$apiCall = _context.v;
|
|
125
116
|
data = _yield$apiCall.data;
|
|
126
117
|
ok = _yield$apiCall.ok;
|
|
127
|
-
console.log('Response status:', ok ? 'success' : 'error');
|
|
128
118
|
if (ok) {
|
|
129
|
-
_context.n =
|
|
119
|
+
_context.n = 3;
|
|
130
120
|
break;
|
|
131
121
|
}
|
|
132
122
|
throw new Error('Failed to fetch invoices');
|
|
133
|
-
case
|
|
134
|
-
console.log('Response data:', data);
|
|
123
|
+
case 3:
|
|
135
124
|
if (data.success && data.invoices) {
|
|
136
125
|
setInvoices(data.invoices);
|
|
137
126
|
} else {
|
|
138
127
|
setInvoices([]);
|
|
139
128
|
}
|
|
140
|
-
_context.n =
|
|
129
|
+
_context.n = 5;
|
|
141
130
|
break;
|
|
142
|
-
case
|
|
143
|
-
_context.p =
|
|
131
|
+
case 4:
|
|
132
|
+
_context.p = 4;
|
|
144
133
|
_t = _context.v;
|
|
145
|
-
console.error('Error fetching invoices:', _t);
|
|
146
134
|
setError('Failed to load invoices');
|
|
147
135
|
setInvoices([]);
|
|
148
|
-
case
|
|
149
|
-
_context.p =
|
|
136
|
+
case 5:
|
|
137
|
+
_context.p = 5;
|
|
150
138
|
setLoading(false);
|
|
151
|
-
return _context.f(
|
|
152
|
-
case
|
|
139
|
+
return _context.f(5);
|
|
140
|
+
case 6:
|
|
153
141
|
return _context.a(2);
|
|
154
142
|
}
|
|
155
|
-
}, _callee, null, [[
|
|
143
|
+
}, _callee, null, [[1, 4, 5, 6]]);
|
|
156
144
|
}));
|
|
157
145
|
return function fetchInvoices() {
|
|
158
146
|
return _ref2.apply(this, arguments);
|
|
@@ -160,7 +148,7 @@ var PowrBaseInvoicesAdmin = function PowrBaseInvoicesAdmin(_ref) {
|
|
|
160
148
|
}();
|
|
161
149
|
(0, _react.useEffect)(function () {
|
|
162
150
|
fetchInvoices();
|
|
163
|
-
}, [
|
|
151
|
+
}, []);
|
|
164
152
|
var handleAddInvoice = /*#__PURE__*/function () {
|
|
165
153
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e) {
|
|
166
154
|
var _yield$apiCall2, data, ok, _t2;
|
|
@@ -168,32 +156,26 @@ var PowrBaseInvoicesAdmin = function PowrBaseInvoicesAdmin(_ref) {
|
|
|
168
156
|
while (1) switch (_context2.n) {
|
|
169
157
|
case 0:
|
|
170
158
|
e.preventDefault();
|
|
171
|
-
if (projectId) {
|
|
172
|
-
_context2.n = 1;
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
return _context2.a(2);
|
|
176
|
-
case 1:
|
|
177
159
|
setAddLoading(true);
|
|
178
160
|
setAddError(null);
|
|
179
|
-
_context2.p =
|
|
180
|
-
_context2.n =
|
|
161
|
+
_context2.p = 1;
|
|
162
|
+
_context2.n = 2;
|
|
181
163
|
return (0, _auth.apiCall)(apiUrl, "/invoices", projectId, {
|
|
182
164
|
method: 'POST',
|
|
183
165
|
body: form
|
|
184
166
|
});
|
|
185
|
-
case
|
|
167
|
+
case 2:
|
|
186
168
|
_yield$apiCall2 = _context2.v;
|
|
187
169
|
data = _yield$apiCall2.data;
|
|
188
170
|
ok = _yield$apiCall2.ok;
|
|
189
171
|
if (ok) {
|
|
190
|
-
_context2.n =
|
|
172
|
+
_context2.n = 3;
|
|
191
173
|
break;
|
|
192
174
|
}
|
|
193
175
|
throw new Error('Failed to add invoice');
|
|
194
|
-
case
|
|
176
|
+
case 3:
|
|
195
177
|
if (!data.success) {
|
|
196
|
-
_context2.n =
|
|
178
|
+
_context2.n = 5;
|
|
197
179
|
break;
|
|
198
180
|
}
|
|
199
181
|
setShowAddModal(false);
|
|
@@ -222,28 +204,28 @@ var PowrBaseInvoicesAdmin = function PowrBaseInvoicesAdmin(_ref) {
|
|
|
222
204
|
}
|
|
223
205
|
});
|
|
224
206
|
setAddError(null);
|
|
225
|
-
_context2.n =
|
|
207
|
+
_context2.n = 4;
|
|
226
208
|
return fetchInvoices();
|
|
227
|
-
case
|
|
209
|
+
case 4:
|
|
228
210
|
if (onInvoiceAction) {
|
|
229
211
|
onInvoiceAction('success', 'Invoice added successfully!');
|
|
230
212
|
} else {
|
|
231
213
|
_reactToastify.toast.success('Invoice added successfully!');
|
|
232
214
|
}
|
|
233
|
-
_context2.n =
|
|
215
|
+
_context2.n = 6;
|
|
234
216
|
break;
|
|
235
|
-
case
|
|
217
|
+
case 5:
|
|
236
218
|
setAddError('Failed to add invoice');
|
|
237
219
|
if (onInvoiceAction) {
|
|
238
220
|
onInvoiceAction('error', 'Failed to add invoice');
|
|
239
221
|
} else {
|
|
240
222
|
_reactToastify.toast.error('Failed to add invoice');
|
|
241
223
|
}
|
|
242
|
-
case
|
|
243
|
-
_context2.n =
|
|
224
|
+
case 6:
|
|
225
|
+
_context2.n = 8;
|
|
244
226
|
break;
|
|
245
|
-
case
|
|
246
|
-
_context2.p =
|
|
227
|
+
case 7:
|
|
228
|
+
_context2.p = 7;
|
|
247
229
|
_t2 = _context2.v;
|
|
248
230
|
setAddError('Failed to add invoice');
|
|
249
231
|
if (onInvoiceAction) {
|
|
@@ -251,14 +233,14 @@ var PowrBaseInvoicesAdmin = function PowrBaseInvoicesAdmin(_ref) {
|
|
|
251
233
|
} else {
|
|
252
234
|
_reactToastify.toast.error('Failed to add invoice');
|
|
253
235
|
}
|
|
254
|
-
case
|
|
255
|
-
_context2.p =
|
|
236
|
+
case 8:
|
|
237
|
+
_context2.p = 8;
|
|
256
238
|
setAddLoading(false);
|
|
257
|
-
return _context2.f(
|
|
258
|
-
case
|
|
239
|
+
return _context2.f(8);
|
|
240
|
+
case 9:
|
|
259
241
|
return _context2.a(2);
|
|
260
242
|
}
|
|
261
|
-
}, _callee2, null, [[
|
|
243
|
+
}, _callee2, null, [[1, 7, 8, 9]]);
|
|
262
244
|
}));
|
|
263
245
|
return function handleAddInvoice(_x) {
|
|
264
246
|
return _ref3.apply(this, arguments);
|
|
@@ -339,7 +321,7 @@ var PowrBaseInvoicesAdmin = function PowrBaseInvoicesAdmin(_ref) {
|
|
|
339
321
|
while (1) switch (_context3.n) {
|
|
340
322
|
case 0:
|
|
341
323
|
e.preventDefault();
|
|
342
|
-
if (
|
|
324
|
+
if (editInvoiceId) {
|
|
343
325
|
_context3.n = 1;
|
|
344
326
|
break;
|
|
345
327
|
}
|
|
@@ -419,17 +401,6 @@ var PowrBaseInvoicesAdmin = function PowrBaseInvoicesAdmin(_ref) {
|
|
|
419
401
|
className: "animate-spin rounded-full h-8 w-8 border-b-2 border-orange-600"
|
|
420
402
|
}));
|
|
421
403
|
}
|
|
422
|
-
if (!projectId) {
|
|
423
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
424
|
-
className: "flex items-center justify-center h-64"
|
|
425
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
426
|
-
className: "text-center"
|
|
427
|
-
}, /*#__PURE__*/_react["default"].createElement("p", {
|
|
428
|
-
className: "text-gray-500"
|
|
429
|
-
}, "No project selected"), /*#__PURE__*/_react["default"].createElement("p", {
|
|
430
|
-
className: "text-sm text-gray-400"
|
|
431
|
-
}, "Please select a project to view invoices")));
|
|
432
|
-
}
|
|
433
404
|
if (error) {
|
|
434
405
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
435
406
|
className: "flex items-center justify-center h-64"
|
|
@@ -86,52 +86,46 @@ var PowrBaseNotificationsAdmin = function PowrBaseNotificationsAdmin(_ref) {
|
|
|
86
86
|
return _regenerator().w(function (_context) {
|
|
87
87
|
while (1) switch (_context.n) {
|
|
88
88
|
case 0:
|
|
89
|
-
if (projectId) {
|
|
90
|
-
_context.n = 1;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
return _context.a(2);
|
|
94
|
-
case 1:
|
|
95
89
|
setLoading(true);
|
|
96
90
|
setError(null);
|
|
97
|
-
_context.p =
|
|
98
|
-
_context.n =
|
|
91
|
+
_context.p = 1;
|
|
92
|
+
_context.n = 2;
|
|
99
93
|
return (0, _auth.apiCall)(apiUrl, "/notifications", projectId);
|
|
100
|
-
case
|
|
94
|
+
case 2:
|
|
101
95
|
_yield$apiCall = _context.v;
|
|
102
96
|
data = _yield$apiCall.data;
|
|
103
97
|
ok = _yield$apiCall.ok;
|
|
104
98
|
if (ok) {
|
|
105
|
-
_context.n =
|
|
99
|
+
_context.n = 3;
|
|
106
100
|
break;
|
|
107
101
|
}
|
|
108
102
|
throw new Error('Failed to fetch notifications');
|
|
109
|
-
case
|
|
103
|
+
case 3:
|
|
110
104
|
if (!data.success) {
|
|
111
|
-
_context.n =
|
|
105
|
+
_context.n = 4;
|
|
112
106
|
break;
|
|
113
107
|
}
|
|
114
108
|
setNotifications(data.notification);
|
|
115
|
-
_context.n =
|
|
109
|
+
_context.n = 5;
|
|
116
110
|
break;
|
|
117
|
-
case
|
|
111
|
+
case 4:
|
|
118
112
|
throw new Error('API response indicates failure');
|
|
119
|
-
case
|
|
120
|
-
_context.n =
|
|
113
|
+
case 5:
|
|
114
|
+
_context.n = 7;
|
|
121
115
|
break;
|
|
122
|
-
case
|
|
123
|
-
_context.p =
|
|
116
|
+
case 6:
|
|
117
|
+
_context.p = 6;
|
|
124
118
|
_t = _context.v;
|
|
125
119
|
setError(_t instanceof Error ? _t.message : 'Failed to load notifications');
|
|
126
120
|
setNotifications([]);
|
|
127
|
-
case
|
|
128
|
-
_context.p =
|
|
121
|
+
case 7:
|
|
122
|
+
_context.p = 7;
|
|
129
123
|
setLoading(false);
|
|
130
|
-
return _context.f(
|
|
131
|
-
case
|
|
124
|
+
return _context.f(7);
|
|
125
|
+
case 8:
|
|
132
126
|
return _context.a(2);
|
|
133
127
|
}
|
|
134
|
-
}, _callee, null, [[
|
|
128
|
+
}, _callee, null, [[1, 6, 7, 8]]);
|
|
135
129
|
}));
|
|
136
130
|
return function fetchNotifications() {
|
|
137
131
|
return _ref2.apply(this, arguments);
|
|
@@ -139,7 +133,7 @@ var PowrBaseNotificationsAdmin = function PowrBaseNotificationsAdmin(_ref) {
|
|
|
139
133
|
}();
|
|
140
134
|
(0, _react.useEffect)(function () {
|
|
141
135
|
fetchNotifications();
|
|
142
|
-
}, [
|
|
136
|
+
}, []);
|
|
143
137
|
(0, _react.useEffect)(function () {
|
|
144
138
|
if (selectedImageurl) {
|
|
145
139
|
setNotificationData(function (prev) {
|
|
@@ -170,14 +164,8 @@ var PowrBaseNotificationsAdmin = function PowrBaseNotificationsAdmin(_ref) {
|
|
|
170
164
|
return _regenerator().w(function (_context2) {
|
|
171
165
|
while (1) switch (_context2.n) {
|
|
172
166
|
case 0:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
return _context2.a(2);
|
|
178
|
-
case 1:
|
|
179
|
-
_context2.p = 1;
|
|
180
|
-
_context2.n = 2;
|
|
167
|
+
_context2.p = 0;
|
|
168
|
+
_context2.n = 1;
|
|
181
169
|
return (0, _auth.apiCall)(apiUrl, "/notifications", projectId, {
|
|
182
170
|
method: 'POST',
|
|
183
171
|
body: {
|
|
@@ -187,12 +175,12 @@ var PowrBaseNotificationsAdmin = function PowrBaseNotificationsAdmin(_ref) {
|
|
|
187
175
|
filter: notificationData.filter
|
|
188
176
|
}
|
|
189
177
|
});
|
|
190
|
-
case
|
|
178
|
+
case 1:
|
|
191
179
|
_yield$apiCall2 = _context2.v;
|
|
192
180
|
result = _yield$apiCall2.data;
|
|
193
181
|
ok = _yield$apiCall2.ok;
|
|
194
182
|
if (!result.success) {
|
|
195
|
-
_context2.n =
|
|
183
|
+
_context2.n = 3;
|
|
196
184
|
break;
|
|
197
185
|
}
|
|
198
186
|
setShowModal(false);
|
|
@@ -205,33 +193,33 @@ var PowrBaseNotificationsAdmin = function PowrBaseNotificationsAdmin(_ref) {
|
|
|
205
193
|
isMerchant: false
|
|
206
194
|
}
|
|
207
195
|
});
|
|
208
|
-
_context2.n =
|
|
196
|
+
_context2.n = 2;
|
|
209
197
|
return fetchNotifications();
|
|
210
|
-
case
|
|
198
|
+
case 2:
|
|
211
199
|
if (onNotificationAction) {
|
|
212
200
|
onNotificationAction('success', 'Notification added successfully!');
|
|
213
201
|
} else {
|
|
214
202
|
_reactToastify.toast.success('Notification added successfully!');
|
|
215
203
|
}
|
|
216
|
-
_context2.n =
|
|
204
|
+
_context2.n = 4;
|
|
217
205
|
break;
|
|
218
|
-
case
|
|
206
|
+
case 3:
|
|
219
207
|
throw new Error('Failed to add notification');
|
|
220
|
-
case
|
|
221
|
-
_context2.n =
|
|
208
|
+
case 4:
|
|
209
|
+
_context2.n = 6;
|
|
222
210
|
break;
|
|
223
|
-
case
|
|
224
|
-
_context2.p =
|
|
211
|
+
case 5:
|
|
212
|
+
_context2.p = 5;
|
|
225
213
|
_t2 = _context2.v;
|
|
226
214
|
if (onNotificationAction) {
|
|
227
215
|
onNotificationAction('error', _t2.message || 'Failed to add notification');
|
|
228
216
|
} else {
|
|
229
217
|
_reactToastify.toast.error(_t2.message || 'Failed to add notification');
|
|
230
218
|
}
|
|
231
|
-
case
|
|
219
|
+
case 6:
|
|
232
220
|
return _context2.a(2);
|
|
233
221
|
}
|
|
234
|
-
}, _callee2, null, [[
|
|
222
|
+
}, _callee2, null, [[0, 5]]);
|
|
235
223
|
}));
|
|
236
224
|
return function handleSubmit() {
|
|
237
225
|
return _ref3.apply(this, arguments);
|
|
@@ -289,17 +277,6 @@ var PowrBaseNotificationsAdmin = function PowrBaseNotificationsAdmin(_ref) {
|
|
|
289
277
|
className: "animate-spin rounded-full h-8 w-8 border-b-2 border-orange-600"
|
|
290
278
|
}));
|
|
291
279
|
}
|
|
292
|
-
if (!projectId) {
|
|
293
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
294
|
-
className: "flex items-center justify-center h-64"
|
|
295
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
296
|
-
className: "text-center"
|
|
297
|
-
}, /*#__PURE__*/_react["default"].createElement("p", {
|
|
298
|
-
className: "text-gray-500"
|
|
299
|
-
}, "No project selected"), /*#__PURE__*/_react["default"].createElement("p", {
|
|
300
|
-
className: "text-sm text-gray-400"
|
|
301
|
-
}, "Please select a project to view notifications")));
|
|
302
|
-
}
|
|
303
280
|
if (error) {
|
|
304
281
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
305
282
|
className: "flex items-center justify-center h-64"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powr-sdk-web",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "babel src -d dist --copy-files",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "https://github.com/lawaziatech/
|
|
21
|
+
"url": "https://github.com/lawaziatech/powr-sdk-web.git"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"filepond": "*",
|