@bigbinary/neeto-webhooks-frontend 2.0.2 → 2.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/dist/NeetoWebhooks.js +1717 -0
- package/dist/NeetoWebhooks.js.map +1 -0
- package/dist/{index.cjs.js → cjs/NeetoWebhooks.js} +7 -9
- package/dist/cjs/NeetoWebhooks.js.map +1 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/index.js +38 -1716
- package/dist/index.js.map +1 -1
- package/package.json +21 -9
- package/dist/index.cjs.js.map +0 -1
|
@@ -0,0 +1,1717 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
import { prop, pluck, assoc, mergeRight } from 'ramda';
|
|
3
|
+
import { useRouteMatch, useHistory, useParams, Switch as Switch$1, Route } from 'react-router-dom';
|
|
4
|
+
import { isNotPresent, isPresent, removeBy, isNotEmpty, removeById, findBy } from '@bigbinary/neeto-cist';
|
|
5
|
+
import { DEFAULT_STALE_TIME, SINGULAR, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_INDEX, PLURAL } from '@bigbinary/neeto-commons-frontend/constants';
|
|
6
|
+
import { useQueryParams, useMutationWithInvalidation, withT } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
7
|
+
import Container from '@bigbinary/neeto-molecules/Container';
|
|
8
|
+
import Header$2 from '@bigbinary/neeto-molecules/Header';
|
|
9
|
+
import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
|
|
10
|
+
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
11
|
+
import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
|
|
12
|
+
import NoData from '@bigbinary/neetoui/NoData';
|
|
13
|
+
import Table from '@bigbinary/neetoui/Table';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { QueryClient, QueryCache, QueryClientProvider, useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
16
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
|
17
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
18
|
+
import axios from 'axios';
|
|
19
|
+
import DateFormat from '@bigbinary/neeto-molecules/DateFormat';
|
|
20
|
+
import Button from '@bigbinary/neetoui/Button';
|
|
21
|
+
import Pane from '@bigbinary/neetoui/Pane';
|
|
22
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
23
|
+
import Tab from '@bigbinary/neetoui/Tab';
|
|
24
|
+
import Tag from '@bigbinary/neetoui/Tag';
|
|
25
|
+
import { t as t$1 } from 'i18next';
|
|
26
|
+
import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
|
|
27
|
+
import Alert from '@bigbinary/neetoui/Alert';
|
|
28
|
+
import Plus from '@bigbinary/neeto-icons/Plus';
|
|
29
|
+
import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
30
|
+
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
31
|
+
import Input from '@bigbinary/neetoui/formik/Input';
|
|
32
|
+
import Form from '@bigbinary/neetoui/formik/Form';
|
|
33
|
+
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
34
|
+
import Select from '@bigbinary/neetoui/formik/Select';
|
|
35
|
+
import Switch from '@bigbinary/neetoui/formik/Switch';
|
|
36
|
+
import Textarea from '@bigbinary/neetoui/formik/Textarea';
|
|
37
|
+
import * as yup from 'yup';
|
|
38
|
+
|
|
39
|
+
var HELP_LINK_URLS = {
|
|
40
|
+
webhook: "https://neetocalhelp.neetokb.com/p/a-4bb6c2a2",
|
|
41
|
+
secrets: "https://neetocalhelp.neetokb.com/p/a-80de90bd",
|
|
42
|
+
deliveries: "https://help.neetocal.com/articles/managing-webhook-deliveries"
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var getDeliveriesPath = function getDeliveriesPath(webhooksPath) {
|
|
46
|
+
return "".concat(webhooksPath, "/:webhookId/deliveries");
|
|
47
|
+
};
|
|
48
|
+
var getDeliveryDetailsPath = function getDeliveryDetailsPath(deliveriesPath) {
|
|
49
|
+
return "".concat(deliveriesPath, "/:deliveryId/");
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
function _arrayLikeToArray(arr, len) {
|
|
53
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
54
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
55
|
+
return arr2;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function _arrayWithoutHoles(arr) {
|
|
59
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function _iterableToArray(iter) {
|
|
63
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
67
|
+
if (!o) return;
|
|
68
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
69
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
70
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
71
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
72
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function _nonIterableSpread() {
|
|
76
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _toConsumableArray(arr) {
|
|
80
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _typeof$1(o) {
|
|
84
|
+
"@babel/helpers - typeof";
|
|
85
|
+
|
|
86
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
87
|
+
return typeof o;
|
|
88
|
+
} : function (o) {
|
|
89
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
90
|
+
}, _typeof$1(o);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function _toPrimitive(input, hint) {
|
|
94
|
+
if (_typeof$1(input) !== "object" || input === null) return input;
|
|
95
|
+
var prim = input[Symbol.toPrimitive];
|
|
96
|
+
if (prim !== undefined) {
|
|
97
|
+
var res = prim.call(input, hint || "default");
|
|
98
|
+
if (_typeof$1(res) !== "object") return res;
|
|
99
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
100
|
+
}
|
|
101
|
+
return (hint === "string" ? String : Number)(input);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _toPropertyKey(arg) {
|
|
105
|
+
var key = _toPrimitive(arg, "string");
|
|
106
|
+
return _typeof$1(key) === "symbol" ? key : String(key);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function _defineProperty(obj, key, value) {
|
|
110
|
+
key = _toPropertyKey(key);
|
|
111
|
+
if (key in obj) {
|
|
112
|
+
Object.defineProperty(obj, key, {
|
|
113
|
+
value: value,
|
|
114
|
+
enumerable: true,
|
|
115
|
+
configurable: true,
|
|
116
|
+
writable: true
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
obj[key] = value;
|
|
120
|
+
}
|
|
121
|
+
return obj;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var queryClient = new QueryClient({
|
|
125
|
+
queryCache: new QueryCache(),
|
|
126
|
+
defaultOptions: {
|
|
127
|
+
queries: {
|
|
128
|
+
staleTime: DEFAULT_STALE_TIME
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
134
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
135
|
+
var withReactQuery = function withReactQuery(Component) {
|
|
136
|
+
var QueryWrapper = function QueryWrapper(props) {
|
|
137
|
+
return /*#__PURE__*/jsxs(QueryClientProvider, {
|
|
138
|
+
client: queryClient,
|
|
139
|
+
children: [/*#__PURE__*/jsx(Component, _objectSpread$2({}, props)), /*#__PURE__*/jsx(ReactQueryDevtools, {
|
|
140
|
+
initialIsOpen: false,
|
|
141
|
+
position: "bottom"
|
|
142
|
+
})]
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
return QueryWrapper;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
var baseUrl$2 = "/webhooks";
|
|
149
|
+
var fetch$1 = function fetch(webhookId, params) {
|
|
150
|
+
return axios.get("".concat(baseUrl$2, "/webhooks/").concat(webhookId, "/deliveries"), {
|
|
151
|
+
params: params
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
var show$1 = function show(id, webhookId) {
|
|
155
|
+
return axios.get("".concat(baseUrl$2, "/webhooks/").concat(webhookId, "/deliveries/").concat(id));
|
|
156
|
+
};
|
|
157
|
+
var redeliver = function redeliver(delivery_id, webhookId) {
|
|
158
|
+
return axios.post("".concat(baseUrl$2, "/webhooks/").concat(webhookId, "/deliveries/").concat(delivery_id, "/redeliver"));
|
|
159
|
+
};
|
|
160
|
+
var deliveriesApi = {
|
|
161
|
+
fetch: fetch$1,
|
|
162
|
+
show: show$1,
|
|
163
|
+
redeliver: redeliver
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
var QUERY_KEYS = {
|
|
167
|
+
DELIVERY_LIST: "delivery-list",
|
|
168
|
+
DELIVERY_DETAILS: "delivery-details",
|
|
169
|
+
WEBHOOK_LIST: "webhook-list",
|
|
170
|
+
WEBHOOK_DETAILS: "webhook-details",
|
|
171
|
+
EVENTS_LIST: "events-list"
|
|
172
|
+
};
|
|
173
|
+
var DELIVERY_STALE_TIME = 3200000; // 1 hour
|
|
174
|
+
var WEBHOOK_STALE_TIME = 3200000; // 1 hour
|
|
175
|
+
var POST_REDELIVERY_ON_SUCCESS_TIMEOUT = 5000; // 5 seconds
|
|
176
|
+
|
|
177
|
+
var useFetchDeliveries = function useFetchDeliveries(webhookId, params) {
|
|
178
|
+
return useQuery({
|
|
179
|
+
queryKey: [QUERY_KEYS.DELIVERY_LIST, webhookId, params],
|
|
180
|
+
queryFn: function queryFn() {
|
|
181
|
+
return deliveriesApi.fetch(webhookId, params);
|
|
182
|
+
},
|
|
183
|
+
staleTime: DELIVERY_STALE_TIME
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
var useShowDelivery = function useShowDelivery(id, webhookId) {
|
|
187
|
+
return useQuery({
|
|
188
|
+
queryKey: [QUERY_KEYS.DELIVERY_DETAILS, id, webhookId],
|
|
189
|
+
queryFn: function queryFn() {
|
|
190
|
+
return deliveriesApi.show(id, webhookId);
|
|
191
|
+
},
|
|
192
|
+
staleTime: DELIVERY_STALE_TIME,
|
|
193
|
+
enabled: !!id
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
var useRedeliverWebhook = function useRedeliverWebhook(deliveryId, webhookSid) {
|
|
197
|
+
var queryClient = useQueryClient();
|
|
198
|
+
return useMutation({
|
|
199
|
+
mutationFn: function mutationFn() {
|
|
200
|
+
return deliveriesApi.redeliver(deliveryId, webhookSid);
|
|
201
|
+
},
|
|
202
|
+
onSuccess: function onSuccess() {
|
|
203
|
+
setTimeout(function () {
|
|
204
|
+
return queryClient.invalidateQueries({
|
|
205
|
+
queryKey: [QUERY_KEYS.DELIVERY_LIST]
|
|
206
|
+
});
|
|
207
|
+
}, POST_REDELIVERY_ON_SUCCESS_TIMEOUT);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
213
|
+
try {
|
|
214
|
+
var info = gen[key](arg);
|
|
215
|
+
var value = info.value;
|
|
216
|
+
} catch (error) {
|
|
217
|
+
reject(error);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (info.done) {
|
|
221
|
+
resolve(value);
|
|
222
|
+
} else {
|
|
223
|
+
Promise.resolve(value).then(_next, _throw);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function _asyncToGenerator(fn) {
|
|
227
|
+
return function () {
|
|
228
|
+
var self = this,
|
|
229
|
+
args = arguments;
|
|
230
|
+
return new Promise(function (resolve, reject) {
|
|
231
|
+
var gen = fn.apply(self, args);
|
|
232
|
+
function _next(value) {
|
|
233
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
234
|
+
}
|
|
235
|
+
function _throw(err) {
|
|
236
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
237
|
+
}
|
|
238
|
+
_next(undefined);
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function getDefaultExportFromCjs (x) {
|
|
244
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
var regeneratorRuntime$1 = {exports: {}};
|
|
248
|
+
|
|
249
|
+
var _typeof = {exports: {}};
|
|
250
|
+
|
|
251
|
+
_typeof.exports;
|
|
252
|
+
|
|
253
|
+
(function (module) {
|
|
254
|
+
function _typeof(o) {
|
|
255
|
+
"@babel/helpers - typeof";
|
|
256
|
+
|
|
257
|
+
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
258
|
+
return typeof o;
|
|
259
|
+
} : function (o) {
|
|
260
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
261
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
|
|
262
|
+
}
|
|
263
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
264
|
+
} (_typeof));
|
|
265
|
+
|
|
266
|
+
var _typeofExports = _typeof.exports;
|
|
267
|
+
|
|
268
|
+
regeneratorRuntime$1.exports;
|
|
269
|
+
|
|
270
|
+
(function (module) {
|
|
271
|
+
var _typeof = _typeofExports["default"];
|
|
272
|
+
function _regeneratorRuntime() {
|
|
273
|
+
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
274
|
+
return e;
|
|
275
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
276
|
+
var t,
|
|
277
|
+
e = {},
|
|
278
|
+
r = Object.prototype,
|
|
279
|
+
n = r.hasOwnProperty,
|
|
280
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
281
|
+
t[e] = r.value;
|
|
282
|
+
},
|
|
283
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
284
|
+
a = i.iterator || "@@iterator",
|
|
285
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
286
|
+
u = i.toStringTag || "@@toStringTag";
|
|
287
|
+
function define(t, e, r) {
|
|
288
|
+
return Object.defineProperty(t, e, {
|
|
289
|
+
value: r,
|
|
290
|
+
enumerable: !0,
|
|
291
|
+
configurable: !0,
|
|
292
|
+
writable: !0
|
|
293
|
+
}), t[e];
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
define({}, "");
|
|
297
|
+
} catch (t) {
|
|
298
|
+
define = function define(t, e, r) {
|
|
299
|
+
return t[e] = r;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function wrap(t, e, r, n) {
|
|
303
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
304
|
+
a = Object.create(i.prototype),
|
|
305
|
+
c = new Context(n || []);
|
|
306
|
+
return o(a, "_invoke", {
|
|
307
|
+
value: makeInvokeMethod(t, r, c)
|
|
308
|
+
}), a;
|
|
309
|
+
}
|
|
310
|
+
function tryCatch(t, e, r) {
|
|
311
|
+
try {
|
|
312
|
+
return {
|
|
313
|
+
type: "normal",
|
|
314
|
+
arg: t.call(e, r)
|
|
315
|
+
};
|
|
316
|
+
} catch (t) {
|
|
317
|
+
return {
|
|
318
|
+
type: "throw",
|
|
319
|
+
arg: t
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
e.wrap = wrap;
|
|
324
|
+
var h = "suspendedStart",
|
|
325
|
+
l = "suspendedYield",
|
|
326
|
+
f = "executing",
|
|
327
|
+
s = "completed",
|
|
328
|
+
y = {};
|
|
329
|
+
function Generator() {}
|
|
330
|
+
function GeneratorFunction() {}
|
|
331
|
+
function GeneratorFunctionPrototype() {}
|
|
332
|
+
var p = {};
|
|
333
|
+
define(p, a, function () {
|
|
334
|
+
return this;
|
|
335
|
+
});
|
|
336
|
+
var d = Object.getPrototypeOf,
|
|
337
|
+
v = d && d(d(values([])));
|
|
338
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
339
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
340
|
+
function defineIteratorMethods(t) {
|
|
341
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
342
|
+
define(t, e, function (t) {
|
|
343
|
+
return this._invoke(e, t);
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
function AsyncIterator(t, e) {
|
|
348
|
+
function invoke(r, o, i, a) {
|
|
349
|
+
var c = tryCatch(t[r], t, o);
|
|
350
|
+
if ("throw" !== c.type) {
|
|
351
|
+
var u = c.arg,
|
|
352
|
+
h = u.value;
|
|
353
|
+
return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
354
|
+
invoke("next", t, i, a);
|
|
355
|
+
}, function (t) {
|
|
356
|
+
invoke("throw", t, i, a);
|
|
357
|
+
}) : e.resolve(h).then(function (t) {
|
|
358
|
+
u.value = t, i(u);
|
|
359
|
+
}, function (t) {
|
|
360
|
+
return invoke("throw", t, i, a);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
a(c.arg);
|
|
364
|
+
}
|
|
365
|
+
var r;
|
|
366
|
+
o(this, "_invoke", {
|
|
367
|
+
value: function value(t, n) {
|
|
368
|
+
function callInvokeWithMethodAndArg() {
|
|
369
|
+
return new e(function (e, r) {
|
|
370
|
+
invoke(t, n, e, r);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
function makeInvokeMethod(e, r, n) {
|
|
378
|
+
var o = h;
|
|
379
|
+
return function (i, a) {
|
|
380
|
+
if (o === f) throw new Error("Generator is already running");
|
|
381
|
+
if (o === s) {
|
|
382
|
+
if ("throw" === i) throw a;
|
|
383
|
+
return {
|
|
384
|
+
value: t,
|
|
385
|
+
done: !0
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
for (n.method = i, n.arg = a;;) {
|
|
389
|
+
var c = n.delegate;
|
|
390
|
+
if (c) {
|
|
391
|
+
var u = maybeInvokeDelegate(c, n);
|
|
392
|
+
if (u) {
|
|
393
|
+
if (u === y) continue;
|
|
394
|
+
return u;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
398
|
+
if (o === h) throw o = s, n.arg;
|
|
399
|
+
n.dispatchException(n.arg);
|
|
400
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
401
|
+
o = f;
|
|
402
|
+
var p = tryCatch(e, r, n);
|
|
403
|
+
if ("normal" === p.type) {
|
|
404
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
405
|
+
return {
|
|
406
|
+
value: p.arg,
|
|
407
|
+
done: n.done
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
function maybeInvokeDelegate(e, r) {
|
|
415
|
+
var n = r.method,
|
|
416
|
+
o = e.iterator[n];
|
|
417
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
418
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
419
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
420
|
+
var a = i.arg;
|
|
421
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
422
|
+
}
|
|
423
|
+
function pushTryEntry(t) {
|
|
424
|
+
var e = {
|
|
425
|
+
tryLoc: t[0]
|
|
426
|
+
};
|
|
427
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
428
|
+
}
|
|
429
|
+
function resetTryEntry(t) {
|
|
430
|
+
var e = t.completion || {};
|
|
431
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
432
|
+
}
|
|
433
|
+
function Context(t) {
|
|
434
|
+
this.tryEntries = [{
|
|
435
|
+
tryLoc: "root"
|
|
436
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
437
|
+
}
|
|
438
|
+
function values(e) {
|
|
439
|
+
if (e || "" === e) {
|
|
440
|
+
var r = e[a];
|
|
441
|
+
if (r) return r.call(e);
|
|
442
|
+
if ("function" == typeof e.next) return e;
|
|
443
|
+
if (!isNaN(e.length)) {
|
|
444
|
+
var o = -1,
|
|
445
|
+
i = function next() {
|
|
446
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
447
|
+
return next.value = t, next.done = !0, next;
|
|
448
|
+
};
|
|
449
|
+
return i.next = i;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
throw new TypeError(_typeof(e) + " is not iterable");
|
|
453
|
+
}
|
|
454
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
455
|
+
value: GeneratorFunctionPrototype,
|
|
456
|
+
configurable: !0
|
|
457
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
458
|
+
value: GeneratorFunction,
|
|
459
|
+
configurable: !0
|
|
460
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
461
|
+
var e = "function" == typeof t && t.constructor;
|
|
462
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
463
|
+
}, e.mark = function (t) {
|
|
464
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
465
|
+
}, e.awrap = function (t) {
|
|
466
|
+
return {
|
|
467
|
+
__await: t
|
|
468
|
+
};
|
|
469
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
470
|
+
return this;
|
|
471
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
472
|
+
void 0 === i && (i = Promise);
|
|
473
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
474
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
475
|
+
return t.done ? t.value : a.next();
|
|
476
|
+
});
|
|
477
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
478
|
+
return this;
|
|
479
|
+
}), define(g, "toString", function () {
|
|
480
|
+
return "[object Generator]";
|
|
481
|
+
}), e.keys = function (t) {
|
|
482
|
+
var e = Object(t),
|
|
483
|
+
r = [];
|
|
484
|
+
for (var n in e) r.push(n);
|
|
485
|
+
return r.reverse(), function next() {
|
|
486
|
+
for (; r.length;) {
|
|
487
|
+
var t = r.pop();
|
|
488
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
489
|
+
}
|
|
490
|
+
return next.done = !0, next;
|
|
491
|
+
};
|
|
492
|
+
}, e.values = values, Context.prototype = {
|
|
493
|
+
constructor: Context,
|
|
494
|
+
reset: function reset(e) {
|
|
495
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
496
|
+
},
|
|
497
|
+
stop: function stop() {
|
|
498
|
+
this.done = !0;
|
|
499
|
+
var t = this.tryEntries[0].completion;
|
|
500
|
+
if ("throw" === t.type) throw t.arg;
|
|
501
|
+
return this.rval;
|
|
502
|
+
},
|
|
503
|
+
dispatchException: function dispatchException(e) {
|
|
504
|
+
if (this.done) throw e;
|
|
505
|
+
var r = this;
|
|
506
|
+
function handle(n, o) {
|
|
507
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
508
|
+
}
|
|
509
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
510
|
+
var i = this.tryEntries[o],
|
|
511
|
+
a = i.completion;
|
|
512
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
513
|
+
if (i.tryLoc <= this.prev) {
|
|
514
|
+
var c = n.call(i, "catchLoc"),
|
|
515
|
+
u = n.call(i, "finallyLoc");
|
|
516
|
+
if (c && u) {
|
|
517
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
518
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
519
|
+
} else if (c) {
|
|
520
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
521
|
+
} else {
|
|
522
|
+
if (!u) throw new Error("try statement without catch or finally");
|
|
523
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
abrupt: function abrupt(t, e) {
|
|
529
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
530
|
+
var o = this.tryEntries[r];
|
|
531
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
532
|
+
var i = o;
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
537
|
+
var a = i ? i.completion : {};
|
|
538
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
539
|
+
},
|
|
540
|
+
complete: function complete(t, e) {
|
|
541
|
+
if ("throw" === t.type) throw t.arg;
|
|
542
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
543
|
+
},
|
|
544
|
+
finish: function finish(t) {
|
|
545
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
546
|
+
var r = this.tryEntries[e];
|
|
547
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
"catch": function _catch(t) {
|
|
551
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
552
|
+
var r = this.tryEntries[e];
|
|
553
|
+
if (r.tryLoc === t) {
|
|
554
|
+
var n = r.completion;
|
|
555
|
+
if ("throw" === n.type) {
|
|
556
|
+
var o = n.arg;
|
|
557
|
+
resetTryEntry(r);
|
|
558
|
+
}
|
|
559
|
+
return o;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
throw new Error("illegal catch attempt");
|
|
563
|
+
},
|
|
564
|
+
delegateYield: function delegateYield(e, r, n) {
|
|
565
|
+
return this.delegate = {
|
|
566
|
+
iterator: values(e),
|
|
567
|
+
resultName: r,
|
|
568
|
+
nextLoc: n
|
|
569
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
570
|
+
}
|
|
571
|
+
}, e;
|
|
572
|
+
}
|
|
573
|
+
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
574
|
+
} (regeneratorRuntime$1));
|
|
575
|
+
|
|
576
|
+
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
|
577
|
+
|
|
578
|
+
// TODO(Babel 8): Remove this file.
|
|
579
|
+
|
|
580
|
+
var runtime = regeneratorRuntimeExports();
|
|
581
|
+
var regenerator = runtime;
|
|
582
|
+
|
|
583
|
+
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
584
|
+
try {
|
|
585
|
+
regeneratorRuntime = runtime;
|
|
586
|
+
} catch (accidentalStrictMode) {
|
|
587
|
+
if (typeof globalThis === "object") {
|
|
588
|
+
globalThis.regeneratorRuntime = runtime;
|
|
589
|
+
} else {
|
|
590
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
595
|
+
|
|
596
|
+
function _arrayWithHoles(arr) {
|
|
597
|
+
if (Array.isArray(arr)) return arr;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function _iterableToArrayLimit(r, l) {
|
|
601
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
602
|
+
if (null != t) {
|
|
603
|
+
var e,
|
|
604
|
+
n,
|
|
605
|
+
i,
|
|
606
|
+
u,
|
|
607
|
+
a = [],
|
|
608
|
+
f = !0,
|
|
609
|
+
o = !1;
|
|
610
|
+
try {
|
|
611
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
612
|
+
if (Object(t) !== t) return;
|
|
613
|
+
f = !1;
|
|
614
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
615
|
+
} catch (r) {
|
|
616
|
+
o = !0, n = r;
|
|
617
|
+
} finally {
|
|
618
|
+
try {
|
|
619
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
620
|
+
} finally {
|
|
621
|
+
if (o) throw n;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return a;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function _nonIterableRest() {
|
|
629
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function _slicedToArray(arr, i) {
|
|
633
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
var DELIVERY_TAB = {
|
|
637
|
+
response: "response",
|
|
638
|
+
request: "request"
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
var Snippet = function Snippet(_ref) {
|
|
642
|
+
var children = _ref.children,
|
|
643
|
+
_ref$dataCy = _ref.dataCy,
|
|
644
|
+
dataCy = _ref$dataCy === void 0 ? "" : _ref$dataCy;
|
|
645
|
+
return /*#__PURE__*/jsx("div", {
|
|
646
|
+
className: "neeto-ui-rounded neeto-ui-border-gray-300 neeto-ui-bg-gray-100 my-2 whitespace-pre-wrap break-all border p-4",
|
|
647
|
+
"data-cy": dataCy,
|
|
648
|
+
children: children
|
|
649
|
+
});
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
var TransactionDetails = function TransactionDetails(_ref) {
|
|
653
|
+
var delivery = _ref.delivery;
|
|
654
|
+
var _useState = useState(DELIVERY_TAB.request),
|
|
655
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
656
|
+
activeHeader = _useState2[0],
|
|
657
|
+
setActiveHeader = _useState2[1];
|
|
658
|
+
var _useTranslation = useTranslation(),
|
|
659
|
+
t = _useTranslation.t;
|
|
660
|
+
var status = delivery.status,
|
|
661
|
+
identifier = delivery.identifier,
|
|
662
|
+
responseStatusCode = delivery.responseStatusCode,
|
|
663
|
+
sid = delivery.sid;
|
|
664
|
+
var renderPayload = function renderPayload() {
|
|
665
|
+
try {
|
|
666
|
+
return JSON.stringify(JSON.parse(delivery.requestBody), null, 2);
|
|
667
|
+
} catch (_unused) {
|
|
668
|
+
return "";
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
672
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
673
|
+
className: "neeto-ui-bg-white sticky top-0 mb-2 flex w-full flex-col",
|
|
674
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
675
|
+
className: "flex w-full flex-col space-y-2 pb-4",
|
|
676
|
+
children: [/*#__PURE__*/jsxs("span", {
|
|
677
|
+
className: "flex items-center space-x-1",
|
|
678
|
+
children: [t("neetoWebhooks.delivery.sid"), ":", /*#__PURE__*/jsx(Typography, {
|
|
679
|
+
className: "px-2 font-bold",
|
|
680
|
+
"data-cy": "delivery-sid",
|
|
681
|
+
style: "body2",
|
|
682
|
+
children: sid
|
|
683
|
+
})]
|
|
684
|
+
}), /*#__PURE__*/jsxs("span", {
|
|
685
|
+
className: "flex items-center space-x-1",
|
|
686
|
+
children: [t("neetoWebhooks.delivery.deliveryId"), ":", /*#__PURE__*/jsx(Typography, {
|
|
687
|
+
className: "px-2 font-bold",
|
|
688
|
+
"data-cy": "delivery-identifier",
|
|
689
|
+
style: "body2",
|
|
690
|
+
children: identifier
|
|
691
|
+
})]
|
|
692
|
+
}), /*#__PURE__*/jsxs("span", {
|
|
693
|
+
className: "flex items-center",
|
|
694
|
+
children: [t("neetoWebhooks.common.responseStatus"), ":", /*#__PURE__*/jsx(Typography, {
|
|
695
|
+
className: "px-2 font-bold",
|
|
696
|
+
"data-cy": "delivery-response-code",
|
|
697
|
+
style: "body2",
|
|
698
|
+
children: responseStatusCode
|
|
699
|
+
}), /*#__PURE__*/jsx(Tag, {
|
|
700
|
+
style: status === "success" ? "success" : "warning",
|
|
701
|
+
children: status
|
|
702
|
+
})]
|
|
703
|
+
})]
|
|
704
|
+
}), /*#__PURE__*/jsxs(Tab, {
|
|
705
|
+
children: [/*#__PURE__*/jsx(Tab.Item, {
|
|
706
|
+
active: activeHeader === DELIVERY_TAB.request,
|
|
707
|
+
onClick: function onClick() {
|
|
708
|
+
return setActiveHeader(DELIVERY_TAB.request);
|
|
709
|
+
},
|
|
710
|
+
children: t("neetoWebhooks.delivery.request")
|
|
711
|
+
}), /*#__PURE__*/jsx(Tab.Item, {
|
|
712
|
+
active: activeHeader === DELIVERY_TAB.response,
|
|
713
|
+
onClick: function onClick() {
|
|
714
|
+
return setActiveHeader(DELIVERY_TAB.response);
|
|
715
|
+
},
|
|
716
|
+
children: t("neetoWebhooks.delivery.response")
|
|
717
|
+
})]
|
|
718
|
+
})]
|
|
719
|
+
}), /*#__PURE__*/jsx("div", {
|
|
720
|
+
className: "mt-2 w-full",
|
|
721
|
+
children: activeHeader === DELIVERY_TAB.request ? /*#__PURE__*/jsxs("div", {
|
|
722
|
+
className: "space-y-4",
|
|
723
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
724
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
725
|
+
style: "h5",
|
|
726
|
+
children: t("neetoWebhooks.delivery.header")
|
|
727
|
+
}), /*#__PURE__*/jsx(Snippet, {
|
|
728
|
+
dataCy: "delivery-request-header",
|
|
729
|
+
children: delivery.requestHeader
|
|
730
|
+
})]
|
|
731
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
732
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
733
|
+
style: "h5",
|
|
734
|
+
children: t("neetoWebhooks.delivery.payload")
|
|
735
|
+
}), /*#__PURE__*/jsx(Snippet, {
|
|
736
|
+
dataCy: "delivery-request-payload",
|
|
737
|
+
children: renderPayload()
|
|
738
|
+
})]
|
|
739
|
+
})]
|
|
740
|
+
}) : /*#__PURE__*/jsxs("div", {
|
|
741
|
+
className: "space-y-4",
|
|
742
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
743
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
744
|
+
style: "h5",
|
|
745
|
+
children: t("neetoWebhooks.delivery.header")
|
|
746
|
+
}), /*#__PURE__*/jsx(Snippet, {
|
|
747
|
+
dataCy: "delivery-response-header",
|
|
748
|
+
children: delivery.responseHeader
|
|
749
|
+
})]
|
|
750
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
751
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
752
|
+
style: "h5",
|
|
753
|
+
children: t("neetoWebhooks.delivery.body")
|
|
754
|
+
}), /*#__PURE__*/jsx(Snippet, {
|
|
755
|
+
dataCy: "delivery-response-body",
|
|
756
|
+
children: delivery.responseBody
|
|
757
|
+
})]
|
|
758
|
+
})]
|
|
759
|
+
})
|
|
760
|
+
})]
|
|
761
|
+
});
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
var Details = function Details(_ref) {
|
|
765
|
+
var onClose = _ref.onClose,
|
|
766
|
+
deliveryId = _ref.deliveryId,
|
|
767
|
+
webhookSid = _ref.webhookSid;
|
|
768
|
+
var _useTranslation = useTranslation(),
|
|
769
|
+
t = _useTranslation.t;
|
|
770
|
+
var _useRedeliverWebhook = useRedeliverWebhook(deliveryId, webhookSid),
|
|
771
|
+
isRedelivering = _useRedeliverWebhook.isPending,
|
|
772
|
+
redeliverWebhook = _useRedeliverWebhook.mutateAsync;
|
|
773
|
+
var _useShowDelivery = useShowDelivery(deliveryId, webhookSid),
|
|
774
|
+
isLoading = _useShowDelivery.isLoading,
|
|
775
|
+
_useShowDelivery$data = _useShowDelivery.data,
|
|
776
|
+
_useShowDelivery$data2 = _useShowDelivery$data === void 0 ? {} : _useShowDelivery$data,
|
|
777
|
+
delivery = _useShowDelivery$data2.delivery;
|
|
778
|
+
var handleRedeliverClick = /*#__PURE__*/function () {
|
|
779
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
780
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
781
|
+
while (1) switch (_context.prev = _context.next) {
|
|
782
|
+
case 0:
|
|
783
|
+
_context.next = 2;
|
|
784
|
+
return redeliverWebhook();
|
|
785
|
+
case 2:
|
|
786
|
+
case "end":
|
|
787
|
+
return _context.stop();
|
|
788
|
+
}
|
|
789
|
+
}, _callee);
|
|
790
|
+
}));
|
|
791
|
+
return function handleRedeliverClick() {
|
|
792
|
+
return _ref2.apply(this, arguments);
|
|
793
|
+
};
|
|
794
|
+
}();
|
|
795
|
+
if (isNotPresent(delivery)) {
|
|
796
|
+
return null;
|
|
797
|
+
}
|
|
798
|
+
return /*#__PURE__*/jsx(Pane, {
|
|
799
|
+
onClose: onClose,
|
|
800
|
+
isOpen: isPresent(deliveryId),
|
|
801
|
+
size: "large",
|
|
802
|
+
children: /*#__PURE__*/jsx(Fragment, {
|
|
803
|
+
children: isLoading ? /*#__PURE__*/jsx(PageLoader, {}) : /*#__PURE__*/jsxs(Fragment, {
|
|
804
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
805
|
+
children: /*#__PURE__*/jsxs(Fragment, {
|
|
806
|
+
children: [/*#__PURE__*/jsx(DateFormat.Date, {
|
|
807
|
+
date: delivery.createdAt,
|
|
808
|
+
tooltipProps: {
|
|
809
|
+
disabled: true
|
|
810
|
+
},
|
|
811
|
+
typographyProps: {
|
|
812
|
+
style: "h2",
|
|
813
|
+
weight: "semibold"
|
|
814
|
+
}
|
|
815
|
+
}), /*#__PURE__*/jsx("span", {
|
|
816
|
+
children: " \u2022 "
|
|
817
|
+
}), /*#__PURE__*/jsx(DateFormat.Time, {
|
|
818
|
+
date: delivery.createdAt,
|
|
819
|
+
tooltipProps: {
|
|
820
|
+
disabled: true
|
|
821
|
+
},
|
|
822
|
+
typographyProps: {
|
|
823
|
+
style: "h2",
|
|
824
|
+
weight: "normal"
|
|
825
|
+
}
|
|
826
|
+
})]
|
|
827
|
+
})
|
|
828
|
+
}), /*#__PURE__*/jsx(Pane.Body, {
|
|
829
|
+
children: isPresent(delivery) && /*#__PURE__*/jsx(TransactionDetails, {
|
|
830
|
+
delivery: delivery
|
|
831
|
+
})
|
|
832
|
+
}), /*#__PURE__*/jsxs(Pane.Footer, {
|
|
833
|
+
className: "gap-x-2",
|
|
834
|
+
children: [event && /*#__PURE__*/jsx(Button, {
|
|
835
|
+
disabled: isRedelivering,
|
|
836
|
+
label: t("neetoWebhooks.delivery.redeliver"),
|
|
837
|
+
loading: isRedelivering,
|
|
838
|
+
style: "primary",
|
|
839
|
+
onClick: handleRedeliverClick
|
|
840
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
841
|
+
label: t("neetoWebhooks.buttons.cancel"),
|
|
842
|
+
style: "text",
|
|
843
|
+
onClick: onClose
|
|
844
|
+
})]
|
|
845
|
+
})]
|
|
846
|
+
})
|
|
847
|
+
})
|
|
848
|
+
});
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
var buildColumns$1 = function buildColumns(_ref) {
|
|
852
|
+
var deliveryDetailsPath = _ref.deliveryDetailsPath;
|
|
853
|
+
return [{
|
|
854
|
+
title: t$1("neetoWebhooks.delivery.deliveryId"),
|
|
855
|
+
key: "identifier",
|
|
856
|
+
dataIndex: "identifier",
|
|
857
|
+
width: 390,
|
|
858
|
+
render: function render(_, delivery) {
|
|
859
|
+
return /*#__PURE__*/jsxs("div", {
|
|
860
|
+
className: "flex items-center gap-x-3",
|
|
861
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
862
|
+
style: "link",
|
|
863
|
+
to: buildUrl(deliveryDetailsPath, {
|
|
864
|
+
deliveryId: delivery.sid
|
|
865
|
+
}),
|
|
866
|
+
weight: "semibold",
|
|
867
|
+
children: delivery.identifier
|
|
868
|
+
}), delivery.redelivery && /*#__PURE__*/jsx(Tag, {
|
|
869
|
+
style: "info",
|
|
870
|
+
children: t$1("neetoWebhooks.delivery.redelivery")
|
|
871
|
+
})]
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
}, {
|
|
875
|
+
title: t$1("neetoWebhooks.tableHeaders.createdAt"),
|
|
876
|
+
key: "createdAt",
|
|
877
|
+
dataIndex: "createdAt",
|
|
878
|
+
width: 280,
|
|
879
|
+
render: function render(createdAt) {
|
|
880
|
+
return /*#__PURE__*/jsx("div", {
|
|
881
|
+
className: "flex items-center justify-between space-x-1",
|
|
882
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
883
|
+
children: /*#__PURE__*/jsx(DateFormat.DateTime, {
|
|
884
|
+
date: createdAt
|
|
885
|
+
})
|
|
886
|
+
})
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
}, {
|
|
890
|
+
title: t$1("neetoWebhooks.common.responseStatus"),
|
|
891
|
+
key: "responseStatusCode",
|
|
892
|
+
width: 160,
|
|
893
|
+
render: function render(_ref2) {
|
|
894
|
+
var responseStatusCode = _ref2.responseStatusCode,
|
|
895
|
+
status = _ref2.status;
|
|
896
|
+
return /*#__PURE__*/jsxs("span", {
|
|
897
|
+
className: "flex items-center",
|
|
898
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
899
|
+
className: "px-2",
|
|
900
|
+
style: "body2",
|
|
901
|
+
children: responseStatusCode
|
|
902
|
+
}), /*#__PURE__*/jsx(Tag, {
|
|
903
|
+
style: status === "success" ? "success" : "warning",
|
|
904
|
+
children: status
|
|
905
|
+
})]
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
}, {
|
|
909
|
+
title: t$1("neetoWebhooks.common.event", SINGULAR),
|
|
910
|
+
key: "event",
|
|
911
|
+
dataIndex: "event",
|
|
912
|
+
width: 270,
|
|
913
|
+
render: prop("label")
|
|
914
|
+
}];
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
var Deliveries = function Deliveries(_ref) {
|
|
918
|
+
var webhooksUrl = _ref.webhooksUrl,
|
|
919
|
+
hostBreadcrumbs = _ref.breadcrumbs,
|
|
920
|
+
helpLink = _ref.helpLink;
|
|
921
|
+
var _useRouteMatch = useRouteMatch(),
|
|
922
|
+
deliveriesUrl = _useRouteMatch.url;
|
|
923
|
+
var history = useHistory();
|
|
924
|
+
var _useTranslation = useTranslation(),
|
|
925
|
+
t = _useTranslation.t;
|
|
926
|
+
var _useParams = useParams(),
|
|
927
|
+
webhookId = _useParams.webhookId,
|
|
928
|
+
deliveryId = _useParams.deliveryId;
|
|
929
|
+
var _useQueryParams = useQueryParams(),
|
|
930
|
+
_useQueryParams$page = _useQueryParams.page,
|
|
931
|
+
page = _useQueryParams$page === void 0 ? DEFAULT_PAGE_INDEX : _useQueryParams$page;
|
|
932
|
+
var deliveryDetailsPath = getDeliveryDetailsPath(deliveriesUrl);
|
|
933
|
+
var _useFetchDeliveries = useFetchDeliveries(webhookId, {
|
|
934
|
+
page: page,
|
|
935
|
+
pageSize: DEFAULT_PAGE_SIZE
|
|
936
|
+
}),
|
|
937
|
+
isLoading = _useFetchDeliveries.isLoading,
|
|
938
|
+
isFetching = _useFetchDeliveries.isFetching,
|
|
939
|
+
_useFetchDeliveries$d = _useFetchDeliveries.data,
|
|
940
|
+
_useFetchDeliveries$d2 = _useFetchDeliveries$d === void 0 ? {} : _useFetchDeliveries$d,
|
|
941
|
+
endpoint = _useFetchDeliveries$d2.endpoint,
|
|
942
|
+
totalCount = _useFetchDeliveries$d2.totalCount,
|
|
943
|
+
_useFetchDeliveries$d3 = _useFetchDeliveries$d2.deliveries,
|
|
944
|
+
deliveries = _useFetchDeliveries$d3 === void 0 ? [] : _useFetchDeliveries$d3;
|
|
945
|
+
var breadcrumbsWithoutWebhooksTitle = removeBy({
|
|
946
|
+
text: t("neetoWebhooks.webhook.title")
|
|
947
|
+
}, hostBreadcrumbs);
|
|
948
|
+
var breadcrumbs = [].concat(_toConsumableArray(breadcrumbsWithoutWebhooksTitle), [{
|
|
949
|
+
link: webhooksUrl,
|
|
950
|
+
text: t("neetoWebhooks.webhook.title")
|
|
951
|
+
}, {
|
|
952
|
+
link: window.location.pathname,
|
|
953
|
+
text: endpoint
|
|
954
|
+
}]);
|
|
955
|
+
if (isLoading) return /*#__PURE__*/jsx(PageLoader, {});
|
|
956
|
+
return /*#__PURE__*/jsxs(Container, {
|
|
957
|
+
className: "w-full",
|
|
958
|
+
children: [/*#__PURE__*/jsx(Header$2, {
|
|
959
|
+
breadcrumbs: breadcrumbs,
|
|
960
|
+
title: /*#__PURE__*/jsxs("div", {
|
|
961
|
+
className: "flex items-center gap-x-2",
|
|
962
|
+
children: [t("neetoWebhooks.delivery.title"), /*#__PURE__*/jsx(HelpPopover, {
|
|
963
|
+
description: t("neetoWebhooks.delivery.helpDescription"),
|
|
964
|
+
helpLinkProps: {
|
|
965
|
+
href: helpLink
|
|
966
|
+
},
|
|
967
|
+
title: t("neetoWebhooks.delivery.title")
|
|
968
|
+
})]
|
|
969
|
+
})
|
|
970
|
+
}), isNotEmpty(deliveries) ? /*#__PURE__*/jsx(TableWrapper, {
|
|
971
|
+
hasPagination: totalCount > DEFAULT_PAGE_SIZE,
|
|
972
|
+
children: /*#__PURE__*/jsx(Table, {
|
|
973
|
+
totalCount: totalCount,
|
|
974
|
+
fixedHeight: true,
|
|
975
|
+
columnData: buildColumns$1({
|
|
976
|
+
deliveryDetailsPath: deliveryDetailsPath
|
|
977
|
+
}),
|
|
978
|
+
currentPageNumber: page,
|
|
979
|
+
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
980
|
+
loading: isFetching,
|
|
981
|
+
rowData: deliveries
|
|
982
|
+
})
|
|
983
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
984
|
+
className: "flex h-full w-full items-center justify-center",
|
|
985
|
+
children: /*#__PURE__*/jsx(NoData, {
|
|
986
|
+
description: t("neetoWebhooks.delivery.empty.description"),
|
|
987
|
+
title: t("neetoWebhooks.delivery.empty.title")
|
|
988
|
+
})
|
|
989
|
+
}), /*#__PURE__*/jsx(Details, {
|
|
990
|
+
deliveryId: deliveryId,
|
|
991
|
+
webhookSid: webhookId,
|
|
992
|
+
onClose: function onClose() {
|
|
993
|
+
return history.goBack();
|
|
994
|
+
}
|
|
995
|
+
})]
|
|
996
|
+
});
|
|
997
|
+
};
|
|
998
|
+
var Deliveries$1 = withReactQuery(Deliveries);
|
|
999
|
+
|
|
1000
|
+
var baseUrl$1 = "/webhooks/webhooks";
|
|
1001
|
+
var fetch = function fetch(params) {
|
|
1002
|
+
return axios.get(baseUrl$1, {
|
|
1003
|
+
params: params
|
|
1004
|
+
});
|
|
1005
|
+
};
|
|
1006
|
+
var create = function create(payload) {
|
|
1007
|
+
return axios.post(baseUrl$1, {
|
|
1008
|
+
webhook: payload
|
|
1009
|
+
});
|
|
1010
|
+
};
|
|
1011
|
+
var show = function show(id) {
|
|
1012
|
+
return axios.get("".concat(baseUrl$1, "/").concat(id));
|
|
1013
|
+
};
|
|
1014
|
+
var update = function update(id, payload) {
|
|
1015
|
+
return axios.put("".concat(baseUrl$1, "/").concat(id), {
|
|
1016
|
+
webhook: payload
|
|
1017
|
+
});
|
|
1018
|
+
};
|
|
1019
|
+
var destroy = function destroy(id) {
|
|
1020
|
+
return axios["delete"]("".concat(baseUrl$1, "/").concat(id));
|
|
1021
|
+
};
|
|
1022
|
+
var webhooksApi = {
|
|
1023
|
+
fetch: fetch,
|
|
1024
|
+
create: create,
|
|
1025
|
+
show: show,
|
|
1026
|
+
update: update,
|
|
1027
|
+
destroy: destroy
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
var useFetchWebhooks = function useFetchWebhooks(params) {
|
|
1031
|
+
return useQuery({
|
|
1032
|
+
queryKey: [QUERY_KEYS.WEBHOOK_LIST, params],
|
|
1033
|
+
queryFn: function queryFn() {
|
|
1034
|
+
return webhooksApi.fetch(params);
|
|
1035
|
+
},
|
|
1036
|
+
staleTime: WEBHOOK_STALE_TIME
|
|
1037
|
+
});
|
|
1038
|
+
};
|
|
1039
|
+
var useCreateWebhook = function useCreateWebhook(options) {
|
|
1040
|
+
return useMutationWithInvalidation(webhooksApi.create, {
|
|
1041
|
+
keysToInvalidate: [[QUERY_KEYS.WEBHOOK_LIST]],
|
|
1042
|
+
onSuccess: function onSuccess() {
|
|
1043
|
+
var _options$onSuccess;
|
|
1044
|
+
options === null || options === void 0 || (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 || _options$onSuccess.call(options);
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
};
|
|
1048
|
+
var useShowWebhook = function useShowWebhook(id) {
|
|
1049
|
+
return useQuery({
|
|
1050
|
+
queryKey: [QUERY_KEYS.WEBHOOK_DETAILS, id],
|
|
1051
|
+
queryFn: function queryFn() {
|
|
1052
|
+
return webhooksApi.show(id);
|
|
1053
|
+
},
|
|
1054
|
+
enabled: !!id,
|
|
1055
|
+
staleTime: WEBHOOK_STALE_TIME
|
|
1056
|
+
});
|
|
1057
|
+
};
|
|
1058
|
+
var useUpdateWebhook = function useUpdateWebhook(id, options) {
|
|
1059
|
+
return useMutationWithInvalidation(function (_ref) {
|
|
1060
|
+
var id = _ref.id,
|
|
1061
|
+
payload = _ref.payload;
|
|
1062
|
+
return webhooksApi.update(id, payload);
|
|
1063
|
+
}, {
|
|
1064
|
+
keysToInvalidate: [[QUERY_KEYS.WEBHOOK_LIST], [QUERY_KEYS.WEBHOOK_DETAILS, id], [QUERY_KEYS.DELIVERY_LIST, id]],
|
|
1065
|
+
onSuccess: function onSuccess() {
|
|
1066
|
+
var _options$onSuccess2;
|
|
1067
|
+
options === null || options === void 0 || (_options$onSuccess2 = options.onSuccess) === null || _options$onSuccess2 === void 0 || _options$onSuccess2.call(options);
|
|
1068
|
+
}
|
|
1069
|
+
});
|
|
1070
|
+
};
|
|
1071
|
+
var useDestroyWebhook = function useDestroyWebhook(options) {
|
|
1072
|
+
return useMutationWithInvalidation(webhooksApi.destroy, {
|
|
1073
|
+
keysToInvalidate: [[QUERY_KEYS.WEBHOOK_LIST]],
|
|
1074
|
+
onSuccess: function onSuccess() {
|
|
1075
|
+
var _options$onSuccess3;
|
|
1076
|
+
options === null || options === void 0 || (_options$onSuccess3 = options.onSuccess) === null || _options$onSuccess3 === void 0 || _options$onSuccess3.call(options);
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
var baseUrl = "/webhooks/events/all";
|
|
1082
|
+
var all = function all() {
|
|
1083
|
+
return axios.get(baseUrl);
|
|
1084
|
+
};
|
|
1085
|
+
var eventsApi = {
|
|
1086
|
+
all: all
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
var useFetchEvents = function useFetchEvents() {
|
|
1090
|
+
return useQuery({
|
|
1091
|
+
queryKey: [QUERY_KEYS.EVENTS_LIST],
|
|
1092
|
+
queryFn: eventsApi.all,
|
|
1093
|
+
staleTime: WEBHOOK_STALE_TIME
|
|
1094
|
+
});
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
1098
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
1099
|
+
// generators (like Math.random()).
|
|
1100
|
+
let getRandomValues;
|
|
1101
|
+
const rnds8 = new Uint8Array(16);
|
|
1102
|
+
function rng() {
|
|
1103
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
1104
|
+
if (!getRandomValues) {
|
|
1105
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
1106
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
1107
|
+
|
|
1108
|
+
if (!getRandomValues) {
|
|
1109
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
return getRandomValues(rnds8);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
1118
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
1119
|
+
*/
|
|
1120
|
+
|
|
1121
|
+
const byteToHex = [];
|
|
1122
|
+
|
|
1123
|
+
for (let i = 0; i < 256; ++i) {
|
|
1124
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
function unsafeStringify(arr, offset = 0) {
|
|
1128
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
1129
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
1130
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
1134
|
+
var native = {
|
|
1135
|
+
randomUUID
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1138
|
+
function v4(options, buf, offset) {
|
|
1139
|
+
if (native.randomUUID && !buf && !options) {
|
|
1140
|
+
return native.randomUUID();
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
options = options || {};
|
|
1144
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
1145
|
+
|
|
1146
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
1147
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
1148
|
+
|
|
1149
|
+
if (buf) {
|
|
1150
|
+
offset = offset || 0;
|
|
1151
|
+
|
|
1152
|
+
for (let i = 0; i < 16; ++i) {
|
|
1153
|
+
buf[offset + i] = rnds[i];
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
return buf;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
return unsafeStringify(rnds);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
var MENU_ITEMS = {
|
|
1163
|
+
EDIT: "edit",
|
|
1164
|
+
DELETE: "delete"
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1168
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1169
|
+
var getMenuItems = function getMenuItems(_ref) {
|
|
1170
|
+
var onEdit = _ref.onEdit,
|
|
1171
|
+
onDelete = _ref.onDelete;
|
|
1172
|
+
return [{
|
|
1173
|
+
key: MENU_ITEMS.EDIT,
|
|
1174
|
+
label: t$1("neetoWebhooks.buttons.edit"),
|
|
1175
|
+
onClick: onEdit
|
|
1176
|
+
}, {
|
|
1177
|
+
key: MENU_ITEMS.DELETE,
|
|
1178
|
+
label: t$1("neetoWebhooks.buttons.delete"),
|
|
1179
|
+
onClick: onDelete
|
|
1180
|
+
}];
|
|
1181
|
+
};
|
|
1182
|
+
var getValidationSchema = function getValidationSchema(webhooks) {
|
|
1183
|
+
return yup.object().shape({
|
|
1184
|
+
endpoint: yup.string().trim().matches(/^(https?):\/\//i, t$1("neetoWebhooks.errors.webhook.invalidUrlProtocol")).url(t$1("neetoWebhooks.errors.webhook.invalidUrl")).required(t$1("neetoWebhooks.errors.webhook.required")).test("Is endpoint unique", t$1("neetoWebhooks.errors.webhook.urlNotUnique"), function (endpoint, ctx) {
|
|
1185
|
+
return !pluck("endpoint", removeById(ctx.parent.id, webhooks)).includes(endpoint === null || endpoint === void 0 ? void 0 : endpoint.trim());
|
|
1186
|
+
}),
|
|
1187
|
+
events: yup.array().min(1, t$1("neetoWebhooks.errors.webhook.events.required")),
|
|
1188
|
+
secret: yup.string().trim().nullable()
|
|
1189
|
+
});
|
|
1190
|
+
};
|
|
1191
|
+
var buildPayload = function buildPayload(_ref2) {
|
|
1192
|
+
var _initialValues$events;
|
|
1193
|
+
var isEditing = _ref2.isEditing,
|
|
1194
|
+
values = _ref2.values,
|
|
1195
|
+
initialValues = _ref2.initialValues;
|
|
1196
|
+
var events = values.events.map(function (_ref3) {
|
|
1197
|
+
var identifier = _ref3.identifier;
|
|
1198
|
+
return {
|
|
1199
|
+
identifier: identifier
|
|
1200
|
+
};
|
|
1201
|
+
});
|
|
1202
|
+
if (!isEditing) return _objectSpread$1(_objectSpread$1({}, values), {}, {
|
|
1203
|
+
eventsAttributes: events
|
|
1204
|
+
});
|
|
1205
|
+
var deletable = ((_initialValues$events = initialValues.events) !== null && _initialValues$events !== void 0 ? _initialValues$events : []).filter(function (_ref4) {
|
|
1206
|
+
var identifier = _ref4.identifier;
|
|
1207
|
+
return !findBy({
|
|
1208
|
+
identifier: identifier
|
|
1209
|
+
}, values.events);
|
|
1210
|
+
}).map(assoc("_destroy", true));
|
|
1211
|
+
var creatable = values.events.filter(function (_ref5) {
|
|
1212
|
+
var identifier = _ref5.identifier;
|
|
1213
|
+
return !findBy({
|
|
1214
|
+
identifier: identifier
|
|
1215
|
+
}, initialValues.events);
|
|
1216
|
+
});
|
|
1217
|
+
return _objectSpread$1(_objectSpread$1({}, values), {}, {
|
|
1218
|
+
eventsAttributes: [].concat(_toConsumableArray(creatable), _toConsumableArray(deletable))
|
|
1219
|
+
});
|
|
1220
|
+
};
|
|
1221
|
+
var buildColumns = function buildColumns(_ref6) {
|
|
1222
|
+
var handleDelete = _ref6.handleDelete,
|
|
1223
|
+
handleEdit = _ref6.handleEdit,
|
|
1224
|
+
deliveriesPath = _ref6.deliveriesPath;
|
|
1225
|
+
return [{
|
|
1226
|
+
title: t$1("neetoWebhooks.common.endpoint"),
|
|
1227
|
+
key: "endpoint",
|
|
1228
|
+
dataIndex: "endpoint",
|
|
1229
|
+
width: 830,
|
|
1230
|
+
render: function render(endpoint, webhook) {
|
|
1231
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1232
|
+
className: "flex items-center justify-between space-x-3",
|
|
1233
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
1234
|
+
style: "link",
|
|
1235
|
+
to: buildUrl(deliveriesPath, {
|
|
1236
|
+
webhookId: webhook.sid
|
|
1237
|
+
}),
|
|
1238
|
+
children: endpoint
|
|
1239
|
+
}), /*#__PURE__*/jsx(MoreDropdown, {
|
|
1240
|
+
dropdownProps: {
|
|
1241
|
+
strategy: "fixed"
|
|
1242
|
+
},
|
|
1243
|
+
menuItems: getMenuItems({
|
|
1244
|
+
onEdit: function onEdit() {
|
|
1245
|
+
return handleEdit(webhook.id);
|
|
1246
|
+
},
|
|
1247
|
+
onDelete: function onDelete() {
|
|
1248
|
+
return handleDelete(webhook.id);
|
|
1249
|
+
}
|
|
1250
|
+
})
|
|
1251
|
+
})]
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
}, {
|
|
1255
|
+
title: t$1("neetoWebhooks.webhook.active"),
|
|
1256
|
+
key: "isActive",
|
|
1257
|
+
dataIndex: "isActive",
|
|
1258
|
+
render: function render(isActive) {
|
|
1259
|
+
return isActive ? t$1("neetoWebhooks.webhook.activeStatuses.yes") : t$1("neetoWebhooks.webhook.activeStatuses.no");
|
|
1260
|
+
},
|
|
1261
|
+
width: 100
|
|
1262
|
+
}, {
|
|
1263
|
+
title: t$1("neetoWebhooks.common.event", PLURAL),
|
|
1264
|
+
dataIndex: "events",
|
|
1265
|
+
key: "events",
|
|
1266
|
+
render: function render(events) {
|
|
1267
|
+
return pluck("label", events).sort().join(", ");
|
|
1268
|
+
},
|
|
1269
|
+
width: 400
|
|
1270
|
+
}];
|
|
1271
|
+
};
|
|
1272
|
+
var generateRandomSecret = function generateRandomSecret() {
|
|
1273
|
+
return v4().replace(/-/g, "");
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1277
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1278
|
+
var AddWebhookPane = function AddWebhookPane(_ref) {
|
|
1279
|
+
var editingWebhookId = _ref.editingWebhookId,
|
|
1280
|
+
entityId = _ref.entityId,
|
|
1281
|
+
entityType = _ref.entityType,
|
|
1282
|
+
isOpen = _ref.isOpen,
|
|
1283
|
+
onClose = _ref.onClose,
|
|
1284
|
+
onCreate = _ref.onCreate,
|
|
1285
|
+
webhooks = _ref.webhooks,
|
|
1286
|
+
webhookHelpLink = _ref.webhookHelpLink,
|
|
1287
|
+
secretsHelpLink = _ref.secretsHelpLink;
|
|
1288
|
+
var _useTranslation = useTranslation(),
|
|
1289
|
+
t = _useTranslation.t;
|
|
1290
|
+
var _useState = useState(false),
|
|
1291
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1292
|
+
isSecretInputFieldVisible = _useState2[0],
|
|
1293
|
+
setIsSecretInputFieldVisible = _useState2[1];
|
|
1294
|
+
var _useCreateWebhook = useCreateWebhook({
|
|
1295
|
+
onSuccess: function onSuccess() {
|
|
1296
|
+
onClose();
|
|
1297
|
+
onCreate === null || onCreate === void 0 || onCreate();
|
|
1298
|
+
}
|
|
1299
|
+
}),
|
|
1300
|
+
createWebhook = _useCreateWebhook.mutate;
|
|
1301
|
+
var _useShowWebhook = useShowWebhook(editingWebhookId),
|
|
1302
|
+
_useShowWebhook$data = _useShowWebhook.data,
|
|
1303
|
+
_useShowWebhook$data2 = _useShowWebhook$data === void 0 ? {} : _useShowWebhook$data,
|
|
1304
|
+
_useShowWebhook$data3 = _useShowWebhook$data2.webhook,
|
|
1305
|
+
webhook = _useShowWebhook$data3 === void 0 ? {} : _useShowWebhook$data3;
|
|
1306
|
+
var _useUpdateWebhook = useUpdateWebhook(editingWebhookId, {
|
|
1307
|
+
onSuccess: onClose
|
|
1308
|
+
}),
|
|
1309
|
+
updateWebhook = _useUpdateWebhook.mutate;
|
|
1310
|
+
var endpointRef = useRef();
|
|
1311
|
+
var _useFetchEvents = useFetchEvents(),
|
|
1312
|
+
events = _useFetchEvents.data,
|
|
1313
|
+
isLoading = _useFetchEvents.isLoading;
|
|
1314
|
+
var initialValues = editingWebhookId ? webhook : {
|
|
1315
|
+
endpoint: "",
|
|
1316
|
+
events: events,
|
|
1317
|
+
secret: "",
|
|
1318
|
+
isActive: true
|
|
1319
|
+
};
|
|
1320
|
+
var handleSubmit = function handleSubmit(values) {
|
|
1321
|
+
var payload = buildPayload({
|
|
1322
|
+
isEditing: editingWebhookId,
|
|
1323
|
+
values: values,
|
|
1324
|
+
initialValues: initialValues
|
|
1325
|
+
});
|
|
1326
|
+
editingWebhookId ? updateWebhook({
|
|
1327
|
+
id: editingWebhookId,
|
|
1328
|
+
payload: payload,
|
|
1329
|
+
entityId: entityId
|
|
1330
|
+
}) : createWebhook(_objectSpread(_objectSpread({}, payload), {}, {
|
|
1331
|
+
entityId: entityId,
|
|
1332
|
+
entityType: entityType
|
|
1333
|
+
}));
|
|
1334
|
+
};
|
|
1335
|
+
var handleClick = function handleClick(setFieldValue) {
|
|
1336
|
+
var randomWebhookSecret = generateRandomSecret();
|
|
1337
|
+
setFieldValue("secret", randomWebhookSecret);
|
|
1338
|
+
setIsSecretInputFieldVisible(true);
|
|
1339
|
+
};
|
|
1340
|
+
var handleRegenerate = function handleRegenerate(setFieldValue) {
|
|
1341
|
+
var randomWebhookSecret = generateRandomSecret();
|
|
1342
|
+
setFieldValue("secret", randomWebhookSecret);
|
|
1343
|
+
};
|
|
1344
|
+
var handleDelete = function handleDelete(setFieldValue) {
|
|
1345
|
+
setFieldValue("secret", null);
|
|
1346
|
+
setIsSecretInputFieldVisible(false);
|
|
1347
|
+
};
|
|
1348
|
+
useEffect(function () {
|
|
1349
|
+
if (webhook !== null && webhook !== void 0 && webhook.secret) {
|
|
1350
|
+
setIsSecretInputFieldVisible(true);
|
|
1351
|
+
}
|
|
1352
|
+
}, [webhook]);
|
|
1353
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
1354
|
+
isOpen: isOpen,
|
|
1355
|
+
onClose: onClose,
|
|
1356
|
+
initialFocusRef: endpointRef,
|
|
1357
|
+
children: [/*#__PURE__*/jsxs(Pane.Header, {
|
|
1358
|
+
className: "flex items-center gap-x-2",
|
|
1359
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1360
|
+
"data-cy": "add-new-webhook-pane-header",
|
|
1361
|
+
style: "h2",
|
|
1362
|
+
weight: "semibold",
|
|
1363
|
+
children: editingWebhookId ? t("neetoWebhooks.webhook.edit") : t("neetoWebhooks.webhook.add")
|
|
1364
|
+
}), /*#__PURE__*/jsx(HelpPopover, {
|
|
1365
|
+
description: t("neetoWebhooks.webhook.helpDescription"),
|
|
1366
|
+
helpLinkProps: {
|
|
1367
|
+
href: webhookHelpLink
|
|
1368
|
+
},
|
|
1369
|
+
title: t("neetoWebhooks.webhook.title")
|
|
1370
|
+
})]
|
|
1371
|
+
}), /*#__PURE__*/jsx(Form, {
|
|
1372
|
+
formikProps: {
|
|
1373
|
+
enableReinitialize: true,
|
|
1374
|
+
validationSchema: getValidationSchema(webhooks),
|
|
1375
|
+
initialValues: initialValues,
|
|
1376
|
+
onSubmit: function onSubmit(values) {
|
|
1377
|
+
return handleSubmit(getValidationSchema().cast(values));
|
|
1378
|
+
}
|
|
1379
|
+
},
|
|
1380
|
+
children: function children(_ref2) {
|
|
1381
|
+
var setFieldValue = _ref2.setFieldValue;
|
|
1382
|
+
return isLoading ? /*#__PURE__*/jsx("div", {
|
|
1383
|
+
className: "flex items-center justify-center",
|
|
1384
|
+
children: /*#__PURE__*/jsx(Spinner, {})
|
|
1385
|
+
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
1386
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
1387
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
1388
|
+
className: "w-full space-y-4",
|
|
1389
|
+
children: [/*#__PURE__*/jsx(Textarea, {
|
|
1390
|
+
required: true,
|
|
1391
|
+
"data-cy": "endpoint-input-field",
|
|
1392
|
+
label: t("neetoWebhooks.webhook.endpoint"),
|
|
1393
|
+
name: "endpoint",
|
|
1394
|
+
placeholder: t("neetoWebhooks.webhook.endpointPlaceholder"),
|
|
1395
|
+
ref: endpointRef,
|
|
1396
|
+
rows: 1
|
|
1397
|
+
}), !isLoading && /*#__PURE__*/jsx(Select, {
|
|
1398
|
+
isMulti: true,
|
|
1399
|
+
required: true,
|
|
1400
|
+
getOptionLabel: prop("label"),
|
|
1401
|
+
getOptionValue: prop("identifier"),
|
|
1402
|
+
label: t("neetoWebhooks.common.event", PLURAL),
|
|
1403
|
+
name: "events",
|
|
1404
|
+
options: events,
|
|
1405
|
+
placeholder: t("neetoWebhooks.webhook.eventPlaceholder")
|
|
1406
|
+
}), isSecretInputFieldVisible && /*#__PURE__*/jsxs("div", {
|
|
1407
|
+
className: "flex items-center justify-between space-x-3",
|
|
1408
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
1409
|
+
"data-cy": "secret-key-input-field",
|
|
1410
|
+
name: "secret",
|
|
1411
|
+
label: /*#__PURE__*/jsxs("span", {
|
|
1412
|
+
className: "flex items-center gap-x-2",
|
|
1413
|
+
children: [t("neetoWebhooks.webhook.secret"), /*#__PURE__*/jsx(HelpPopover, {
|
|
1414
|
+
helpLinkProps: {
|
|
1415
|
+
href: secretsHelpLink
|
|
1416
|
+
},
|
|
1417
|
+
description: t("neetoWebhooks.webhook.secretkeyHelpDescription"),
|
|
1418
|
+
title: t("neetoWebhooks.webhook.secretkeyHelpTitle")
|
|
1419
|
+
})]
|
|
1420
|
+
}),
|
|
1421
|
+
placeholder: t("neetoWebhooks.webhook.secretPlaceholder")
|
|
1422
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1423
|
+
className: "mt-6",
|
|
1424
|
+
children: /*#__PURE__*/jsx(MoreDropdown, {
|
|
1425
|
+
menuItems: [{
|
|
1426
|
+
key: "regenerate-secret",
|
|
1427
|
+
label: t("neetoWebhooks.buttons.regenerate"),
|
|
1428
|
+
"data-cy": "regenerate-secret",
|
|
1429
|
+
onClick: function onClick() {
|
|
1430
|
+
return handleRegenerate(setFieldValue);
|
|
1431
|
+
}
|
|
1432
|
+
}, {
|
|
1433
|
+
key: "delete-secret",
|
|
1434
|
+
label: t("neetoWebhooks.buttons.delete"),
|
|
1435
|
+
"data-cy": "delete-secret",
|
|
1436
|
+
onClick: function onClick() {
|
|
1437
|
+
return handleDelete(setFieldValue);
|
|
1438
|
+
}
|
|
1439
|
+
}]
|
|
1440
|
+
})
|
|
1441
|
+
})]
|
|
1442
|
+
}), /*#__PURE__*/jsx(Switch, {
|
|
1443
|
+
label: t("neetoWebhooks.webhook.active"),
|
|
1444
|
+
name: "isActive"
|
|
1445
|
+
}), !isSecretInputFieldVisible && /*#__PURE__*/jsx(Button, {
|
|
1446
|
+
"data-cy": "add-secret-key",
|
|
1447
|
+
icon: Plus,
|
|
1448
|
+
label: t("neetoWebhooks.buttons.addSecretKey"),
|
|
1449
|
+
style: "text",
|
|
1450
|
+
onClick: function onClick() {
|
|
1451
|
+
return handleClick(setFieldValue);
|
|
1452
|
+
}
|
|
1453
|
+
})]
|
|
1454
|
+
})
|
|
1455
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
1456
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
1457
|
+
cancelButtonProps: {
|
|
1458
|
+
onClick: onClose
|
|
1459
|
+
}
|
|
1460
|
+
})
|
|
1461
|
+
})]
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
})]
|
|
1465
|
+
});
|
|
1466
|
+
};
|
|
1467
|
+
|
|
1468
|
+
var Header = withT(function (_ref) {
|
|
1469
|
+
var t = _ref.t,
|
|
1470
|
+
breadcrumbs = _ref.breadcrumbs,
|
|
1471
|
+
title = _ref.title,
|
|
1472
|
+
setIsAddWebhookPaneOpen = _ref.setIsAddWebhookPaneOpen,
|
|
1473
|
+
headerSize = _ref.headerSize,
|
|
1474
|
+
webhookHelpLink = _ref.webhookHelpLink;
|
|
1475
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1476
|
+
children: [/*#__PURE__*/jsx(Header$2, {
|
|
1477
|
+
breadcrumbs: breadcrumbs,
|
|
1478
|
+
size: headerSize,
|
|
1479
|
+
actionBlock: /*#__PURE__*/jsx(Button, {
|
|
1480
|
+
"data-cy": "add-new-webhook-button",
|
|
1481
|
+
label: t("neetoWebhooks.webhook.add"),
|
|
1482
|
+
onClick: function onClick() {
|
|
1483
|
+
return setIsAddWebhookPaneOpen(true);
|
|
1484
|
+
}
|
|
1485
|
+
}),
|
|
1486
|
+
title: title || /*#__PURE__*/jsxs("div", {
|
|
1487
|
+
className: "flex items-center gap-x-2",
|
|
1488
|
+
children: [t("neetoWebhooks.webhook.title"), /*#__PURE__*/jsx(HelpPopover, {
|
|
1489
|
+
description: t("neetoWebhooks.webhook.helpDescription"),
|
|
1490
|
+
helpLinkProps: {
|
|
1491
|
+
href: webhookHelpLink
|
|
1492
|
+
},
|
|
1493
|
+
title: t("neetoWebhooks.webhook.title")
|
|
1494
|
+
})]
|
|
1495
|
+
})
|
|
1496
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
1497
|
+
className: "mb-3",
|
|
1498
|
+
"data-cy": "webhook-description-header",
|
|
1499
|
+
style: "h5",
|
|
1500
|
+
weight: "normal",
|
|
1501
|
+
children: t("neetoWebhooks.webhook.description")
|
|
1502
|
+
})]
|
|
1503
|
+
});
|
|
1504
|
+
});
|
|
1505
|
+
var Header$1 = /*#__PURE__*/React.memo(Header);
|
|
1506
|
+
|
|
1507
|
+
var Webhooks = function Webhooks(_ref) {
|
|
1508
|
+
var deliveriesPath = _ref.deliveriesPath,
|
|
1509
|
+
entityType = _ref.entityType,
|
|
1510
|
+
breadcrumbs = _ref.breadcrumbs,
|
|
1511
|
+
title = _ref.title,
|
|
1512
|
+
entityId = _ref.entityId,
|
|
1513
|
+
onCreate = _ref.onCreate,
|
|
1514
|
+
onDelete = _ref.onDelete,
|
|
1515
|
+
headerSize = _ref.headerSize,
|
|
1516
|
+
_ref$containerClassNa = _ref.containerClassName,
|
|
1517
|
+
containerClassName = _ref$containerClassNa === void 0 ? "" : _ref$containerClassNa,
|
|
1518
|
+
webhookHelpLink = _ref.webhookHelpLink,
|
|
1519
|
+
secretsHelpLink = _ref.secretsHelpLink;
|
|
1520
|
+
var _useState = useState(null),
|
|
1521
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1522
|
+
editingWebhookId = _useState2[0],
|
|
1523
|
+
setEditingWebhookId = _useState2[1];
|
|
1524
|
+
var _useState3 = useState(null),
|
|
1525
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1526
|
+
deletingWebhookId = _useState4[0],
|
|
1527
|
+
setDeletingWebhookId = _useState4[1];
|
|
1528
|
+
var _useState5 = useState(false),
|
|
1529
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1530
|
+
isAddWebhookPaneOpen = _useState6[0],
|
|
1531
|
+
setIsAddWebhookPaneOpen = _useState6[1];
|
|
1532
|
+
var _useState7 = useState(false),
|
|
1533
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1534
|
+
isDeleteAlertOpen = _useState8[0],
|
|
1535
|
+
setIsDeleteAlertOpen = _useState8[1];
|
|
1536
|
+
var _useTranslation = useTranslation(),
|
|
1537
|
+
t = _useTranslation.t;
|
|
1538
|
+
var _useQueryParams = useQueryParams(),
|
|
1539
|
+
_useQueryParams$page = _useQueryParams.page,
|
|
1540
|
+
page = _useQueryParams$page === void 0 ? DEFAULT_PAGE_INDEX : _useQueryParams$page;
|
|
1541
|
+
var _useFetchWebhooks = useFetchWebhooks({
|
|
1542
|
+
entityId: entityId,
|
|
1543
|
+
page: page,
|
|
1544
|
+
pageSize: DEFAULT_PAGE_SIZE
|
|
1545
|
+
}),
|
|
1546
|
+
isLoading = _useFetchWebhooks.isLoading,
|
|
1547
|
+
isFetching = _useFetchWebhooks.isFetching,
|
|
1548
|
+
_useFetchWebhooks$dat = _useFetchWebhooks.data,
|
|
1549
|
+
_useFetchWebhooks$dat2 = _useFetchWebhooks$dat === void 0 ? {} : _useFetchWebhooks$dat,
|
|
1550
|
+
_useFetchWebhooks$dat3 = _useFetchWebhooks$dat2.webhooks,
|
|
1551
|
+
webhooks = _useFetchWebhooks$dat3 === void 0 ? [] : _useFetchWebhooks$dat3,
|
|
1552
|
+
_useFetchWebhooks$dat4 = _useFetchWebhooks$dat2.totalCount,
|
|
1553
|
+
totalCount = _useFetchWebhooks$dat4 === void 0 ? 0 : _useFetchWebhooks$dat4;
|
|
1554
|
+
var _useDestroyWebhook = useDestroyWebhook({
|
|
1555
|
+
onSuccess: function onSuccess() {
|
|
1556
|
+
setIsDeleteAlertOpen(false);
|
|
1557
|
+
onDelete === null || onDelete === void 0 || onDelete();
|
|
1558
|
+
}
|
|
1559
|
+
}),
|
|
1560
|
+
isDeleting = _useDestroyWebhook.isPending,
|
|
1561
|
+
destroyWebhook = _useDestroyWebhook.mutate;
|
|
1562
|
+
var handlePaneClose = function handlePaneClose() {
|
|
1563
|
+
setEditingWebhookId(null);
|
|
1564
|
+
setIsAddWebhookPaneOpen(false);
|
|
1565
|
+
};
|
|
1566
|
+
var handleEdit = useCallback(function (id) {
|
|
1567
|
+
setEditingWebhookId(id);
|
|
1568
|
+
setIsAddWebhookPaneOpen(true);
|
|
1569
|
+
}, []);
|
|
1570
|
+
var handleDelete = useCallback(function (id) {
|
|
1571
|
+
setDeletingWebhookId(id);
|
|
1572
|
+
setIsDeleteAlertOpen(true);
|
|
1573
|
+
}, []);
|
|
1574
|
+
if (isLoading) {
|
|
1575
|
+
return /*#__PURE__*/jsx(PageLoader, {});
|
|
1576
|
+
}
|
|
1577
|
+
return /*#__PURE__*/jsxs(Container, {
|
|
1578
|
+
className: containerClassName,
|
|
1579
|
+
children: [/*#__PURE__*/jsx(Header$1, {
|
|
1580
|
+
breadcrumbs: breadcrumbs,
|
|
1581
|
+
headerSize: headerSize,
|
|
1582
|
+
setIsAddWebhookPaneOpen: setIsAddWebhookPaneOpen,
|
|
1583
|
+
title: title,
|
|
1584
|
+
webhookHelpLink: webhookHelpLink
|
|
1585
|
+
}), isNotEmpty(webhooks) ? /*#__PURE__*/jsx(TableWrapper, {
|
|
1586
|
+
hasPagination: totalCount > DEFAULT_PAGE_SIZE,
|
|
1587
|
+
children: /*#__PURE__*/jsx(Table, {
|
|
1588
|
+
totalCount: totalCount,
|
|
1589
|
+
fixedHeight: true,
|
|
1590
|
+
currentPageNumber: page,
|
|
1591
|
+
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
1592
|
+
loading: isFetching,
|
|
1593
|
+
rowData: webhooks,
|
|
1594
|
+
columnData: buildColumns({
|
|
1595
|
+
handleDelete: handleDelete,
|
|
1596
|
+
handleEdit: handleEdit,
|
|
1597
|
+
deliveriesPath: deliveriesPath
|
|
1598
|
+
})
|
|
1599
|
+
})
|
|
1600
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
1601
|
+
className: "flex h-full w-full items-center justify-center",
|
|
1602
|
+
children: /*#__PURE__*/jsx(NoData, {
|
|
1603
|
+
title: t("neetoWebhooks.webhook.empty"),
|
|
1604
|
+
helpText: /*#__PURE__*/jsx(Button, {
|
|
1605
|
+
href: webhookHelpLink,
|
|
1606
|
+
label: t("neetoWebhooks.webhook.emptyHelpText"),
|
|
1607
|
+
rel: "noreferrer",
|
|
1608
|
+
style: "link",
|
|
1609
|
+
target: "_blank"
|
|
1610
|
+
}),
|
|
1611
|
+
primaryButtonProps: {
|
|
1612
|
+
label: t("neetoWebhooks.webhook.add"),
|
|
1613
|
+
onClick: function onClick() {
|
|
1614
|
+
return setIsAddWebhookPaneOpen(true);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
})
|
|
1618
|
+
}), /*#__PURE__*/jsx(AddWebhookPane, {
|
|
1619
|
+
editingWebhookId: editingWebhookId,
|
|
1620
|
+
entityId: entityId,
|
|
1621
|
+
entityType: entityType,
|
|
1622
|
+
onCreate: onCreate,
|
|
1623
|
+
secretsHelpLink: secretsHelpLink,
|
|
1624
|
+
webhookHelpLink: webhookHelpLink,
|
|
1625
|
+
webhooks: webhooks,
|
|
1626
|
+
isOpen: isAddWebhookPaneOpen,
|
|
1627
|
+
onClose: handlePaneClose
|
|
1628
|
+
}), /*#__PURE__*/jsx(Alert, {
|
|
1629
|
+
isOpen: isDeleteAlertOpen,
|
|
1630
|
+
isSubmitting: isDeleting,
|
|
1631
|
+
submitButtonLabel: t("neetoWebhooks.buttons.delete"),
|
|
1632
|
+
message: t("neetoWebhooks.alert.delete.message", {
|
|
1633
|
+
entity: t("neetoWebhooks.entity.webhook")
|
|
1634
|
+
}),
|
|
1635
|
+
title: t("neetoWebhooks.alert.delete.title", {
|
|
1636
|
+
entity: t("neetoWebhooks.entity.webhook")
|
|
1637
|
+
}),
|
|
1638
|
+
onClose: function onClose() {
|
|
1639
|
+
return setIsDeleteAlertOpen(false);
|
|
1640
|
+
},
|
|
1641
|
+
onSubmit: function onSubmit() {
|
|
1642
|
+
return destroyWebhook(deletingWebhookId, {
|
|
1643
|
+
entityId: entityId
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
})]
|
|
1647
|
+
});
|
|
1648
|
+
};
|
|
1649
|
+
var Webhooks$1 = withReactQuery(Webhooks);
|
|
1650
|
+
|
|
1651
|
+
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
1652
|
+
|
|
1653
|
+
var css = ".neeto-molecules-header .neeto-molecules-header__breadcrumbs-wrap{flex-wrap:wrap}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9tYWluLnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0Usa0VBQ0UsY0FBSiIsInNvdXJjZXNDb250ZW50IjpbIi5uZWV0by1tb2xlY3VsZXMtaGVhZGVyIHtcbiAgLm5lZXRvLW1vbGVjdWxlcy1oZWFkZXJfX2JyZWFkY3J1bWJzLXdyYXAge1xuICAgIGZsZXgtd3JhcDogd3JhcDtcbiAgfVxufVxuIl19 */";
|
|
1654
|
+
n(css,{});
|
|
1655
|
+
|
|
1656
|
+
var NeetoWebhooks = function NeetoWebhooks(_ref) {
|
|
1657
|
+
var entityType = _ref.entityType,
|
|
1658
|
+
entityId = _ref.entityId,
|
|
1659
|
+
_ref$breadcrumbs = _ref.breadcrumbs,
|
|
1660
|
+
breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
|
|
1661
|
+
title = _ref.title,
|
|
1662
|
+
onCreate = _ref.onCreate,
|
|
1663
|
+
onDelete = _ref.onDelete,
|
|
1664
|
+
headerSize = _ref.headerSize,
|
|
1665
|
+
_ref$helpLinkUrls = _ref.helpLinkUrls,
|
|
1666
|
+
helpLinkUrls = _ref$helpLinkUrls === void 0 ? {} : _ref$helpLinkUrls,
|
|
1667
|
+
containerClassName = _ref.containerClassName;
|
|
1668
|
+
var _useRouteMatch = useRouteMatch(),
|
|
1669
|
+
webhooksPath = _useRouteMatch.path,
|
|
1670
|
+
webhooksUrl = _useRouteMatch.url;
|
|
1671
|
+
var deliveriesPath = getDeliveriesPath(webhooksUrl);
|
|
1672
|
+
var deliveryDetailsPath = getDeliveryDetailsPath(deliveriesPath);
|
|
1673
|
+
var helpLinks = mergeRight(HELP_LINK_URLS, helpLinkUrls);
|
|
1674
|
+
return /*#__PURE__*/jsxs(Switch$1, {
|
|
1675
|
+
children: [/*#__PURE__*/jsx(Route, {
|
|
1676
|
+
exact: true,
|
|
1677
|
+
path: webhooksPath,
|
|
1678
|
+
component: function component() {
|
|
1679
|
+
return /*#__PURE__*/jsx(Webhooks$1, {
|
|
1680
|
+
breadcrumbs: breadcrumbs,
|
|
1681
|
+
containerClassName: containerClassName,
|
|
1682
|
+
deliveriesPath: deliveriesPath,
|
|
1683
|
+
entityId: entityId,
|
|
1684
|
+
entityType: entityType,
|
|
1685
|
+
headerSize: headerSize,
|
|
1686
|
+
onCreate: onCreate,
|
|
1687
|
+
onDelete: onDelete,
|
|
1688
|
+
title: title,
|
|
1689
|
+
secretsHelpLink: helpLinks.secrets,
|
|
1690
|
+
webhookHelpLink: helpLinks.webhook
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
}), /*#__PURE__*/jsx(Route, {
|
|
1694
|
+
exact: true,
|
|
1695
|
+
path: deliveryDetailsPath,
|
|
1696
|
+
render: function render() {
|
|
1697
|
+
return /*#__PURE__*/jsx(Deliveries$1, {
|
|
1698
|
+
breadcrumbs: breadcrumbs,
|
|
1699
|
+
webhooksUrl: webhooksUrl,
|
|
1700
|
+
helpLink: helpLinks.deliveries
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
}), /*#__PURE__*/jsx(Route, {
|
|
1704
|
+
path: deliveriesPath,
|
|
1705
|
+
component: function component() {
|
|
1706
|
+
return /*#__PURE__*/jsx(Deliveries$1, {
|
|
1707
|
+
breadcrumbs: breadcrumbs,
|
|
1708
|
+
webhooksUrl: webhooksUrl,
|
|
1709
|
+
helpLink: helpLinks.deliveries
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
})]
|
|
1713
|
+
});
|
|
1714
|
+
};
|
|
1715
|
+
|
|
1716
|
+
export { NeetoWebhooks as default };
|
|
1717
|
+
//# sourceMappingURL=NeetoWebhooks.js.map
|