@bigbinary/neeto-commons-frontend 1.0.9 → 2.0.1

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/initializers.js CHANGED
@@ -1,11 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var axios = require('axios');
4
3
  var ramda = require('ramda');
4
+ var neetoui = require('@bigbinary/neetoui');
5
+ var axios = require('axios');
5
6
  var i18next = require('i18next');
6
- var dayjs = require('dayjs');
7
- var relativeTime = require('dayjs/plugin/relativeTime');
8
- var updateLocale = require('dayjs/plugin/updateLocale');
9
7
  var mixpanel = require('mixpanel-browser');
10
8
  var reactI18next = require('react-i18next');
11
9
 
@@ -13,23 +11,8 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
13
11
 
14
12
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
15
13
  var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
16
- var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
17
- var relativeTime__default = /*#__PURE__*/_interopDefaultLegacy(relativeTime);
18
- var updateLocale__default = /*#__PURE__*/_interopDefaultLegacy(updateLocale);
19
14
  var mixpanel__default = /*#__PURE__*/_interopDefaultLegacy(mixpanel);
20
15
 
21
- var HEADERS_KEYS = {
22
- xAuthEmail: "X-Auth-Email",
23
- xAuthToken: "X-Auth-Token",
24
- xCsrfToken: "X-CSRF-TOKEN"
25
- };
26
-
27
- var resetAuthTokens = function resetAuthTokens() {
28
- ramda.values(HEADERS_KEYS).forEach(function (header) {
29
- delete axios__default["default"].defaults.headers[header];
30
- });
31
- };
32
-
33
16
  function _arrayWithHoles(arr) {
34
17
  if (Array.isArray(arr)) return arr;
35
18
  }
@@ -91,14 +74,14 @@ function _slicedToArray(arr, i) {
91
74
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
92
75
  }
93
76
 
94
- function _typeof$1(obj) {
77
+ function _typeof(obj) {
95
78
  "@babel/helpers - typeof";
96
79
 
97
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
80
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
98
81
  return typeof obj;
99
82
  } : function (obj) {
100
83
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
101
- }, _typeof$1(obj);
84
+ }, _typeof(obj);
102
85
  }
103
86
 
104
87
  var snakeToCamelCase = function snakeToCamelCase(string) {
@@ -117,7 +100,7 @@ var transformObjectDeep = function transformObjectDeep(object, keyValueTransform
117
100
  return object.map(function (obj) {
118
101
  return transformObjectDeep(obj, keyValueTransformer);
119
102
  });
120
- } else if (object === null || _typeof$1(object) !== "object") {
103
+ } else if (object === null || _typeof(object) !== "object") {
121
104
  return object;
122
105
  }
123
106
 
@@ -134,13 +117,8 @@ var keysToCamelCase = function keysToCamelCase(object) {
134
117
  return [snakeToCamelCase(key), value];
135
118
  });
136
119
  };
137
- var keysToSnakeCase = function keysToSnakeCase(object) {
138
- return transformObjectDeep(object, function (key, value) {
139
- return [camelToSnakeCase(key), value];
140
- });
141
- };
142
120
  var deepFreezeObject = function deepFreezeObject(object) {
143
- if (object && _typeof$1(object) === "object" && !Object.isFrozen(object)) {
121
+ if (object && _typeof(object) === "object" && !Object.isFrozen(object)) {
144
122
  Object.keys(object).forEach(function (property) {
145
123
  return deepFreezeObject(object[property]);
146
124
  });
@@ -150,18 +128,25 @@ var deepFreezeObject = function deepFreezeObject(object) {
150
128
  return object;
151
129
  };
152
130
  var matches = ramda.curry(function (pattern, object) {
131
+ var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
132
+
153
133
  if (object === pattern) return true;
134
+ if (typeof pattern === "function" && pattern(object, __parent)) return true;
154
135
  if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
155
- if (_typeof$1(pattern) !== "object") return false;
136
+ if (_typeof(pattern) !== "object") return false;
156
137
  return Object.entries(pattern).every(function (_ref3) {
157
138
  var _ref4 = _slicedToArray(_ref3, 2),
158
139
  key = _ref4[0],
159
140
  value = _ref4[1];
160
141
 
161
- return matches(value, object[key]);
142
+ return matches(value, object[key], __parent);
162
143
  });
163
144
  });
164
145
 
146
+ var _document$getElements, _document$getElements2;
147
+ window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
148
+ deepFreezeObject(window.globalProps);
149
+
165
150
  function _defineProperty(obj, key, value) {
166
151
  if (key in obj) {
167
152
  Object.defineProperty(obj, key, {
@@ -177,499 +162,17 @@ function _defineProperty(obj, key, value) {
177
162
  return obj;
178
163
  }
179
164
 
180
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
181
-
182
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
183
- ramda.curry(function (id, array) {
184
- return array.filter(function (item) {
185
- return item.id !== id;
186
- });
187
- });
188
- ramda.curry(function (id, array) {
189
- return array.find(function (item) {
190
- return item.id === id;
191
- });
192
- });
193
- ramda.curry(function (id, newItem, array) {
194
- return array.map(function (item) {
195
- return item.id === id ? newItem : item;
196
- });
197
- });
198
- ramda.curry(function (id, modifier, array) {
199
- return array.map(function (item) {
200
- return item.id === id ? modifier(item) : item;
201
- });
202
- });
203
- ramda.curry(function (pattern, array) {
204
- return array.find(matches(pattern));
205
- });
206
- ramda.curry(function (pattern, array) {
207
- return array.filter(ramda.complement(matches(pattern)));
208
- });
209
- ramda.curry(function (pattern, newItem, array) {
210
- return array.map(function (item) {
211
- return matches(pattern, item) ? newItem : item;
212
- });
213
- });
214
- ramda.curry(function (pattern, modifier, array) {
215
- return array.map(function (item) {
216
- return matches(pattern, item) ? modifier(item) : item;
217
- });
218
- });
219
- ramda.curry(function (id, array) {
220
- return array.some(function (item) {
221
- return item.id === id;
222
- });
223
- });
224
- ramda.curry(function (pattern, array) {
225
- return array.some(matches(pattern));
226
- });
227
- ramda.curry(function (keyMap, objectArray) {
228
- return objectArray.map(function (object) {
229
- return _objectSpread(_objectSpread({}, object), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref) {
230
- var _ref2 = _slicedToArray(_ref, 2),
231
- key = _ref2[0],
232
- value = _ref2[1];
233
-
234
- return [value, object[key]];
235
- })));
236
- });
237
- });
238
- ramda.curry(function (keyMap, objectArray) {
239
- return objectArray.map(function (object) {
240
- return _objectSpread(_objectSpread({}, ramda.omit(ramda.keys(keyMap), object)), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref3) {
241
- var _ref4 = _slicedToArray(_ref3, 2),
242
- source = _ref4[0],
243
- destination = _ref4[1];
244
-
245
- return [destination, object[source]];
246
- })));
247
- });
248
- });
249
- ramda.curry(function (keyMap, objectArray) {
250
- var copyKeysSingleObject = function copyKeysSingleObject(object, keyMap) {
251
- var root = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
252
- return _objectSpread(_objectSpread({}, object), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref5) {
253
- var _ref6 = _slicedToArray(_ref5, 2),
254
- destination = _ref6[0],
255
- source = _ref6[1];
256
-
257
- if (typeof source === "function") {
258
- return [destination, source(object[destination], root)];
259
- } else if (Array.isArray(source)) {
260
- return [destination, ramda.path(source, root)];
261
- } else if (_typeof$1(source) === "object") {
262
- return [destination, copyKeysSingleObject(object[destination], source, root)];
263
- }
264
-
265
- return [destination, object[source]];
266
- })));
267
- };
165
+ var HEADERS_KEYS = {
166
+ xAuthEmail: "X-Auth-Email",
167
+ xAuthToken: "X-Auth-Token",
168
+ xCsrfToken: "X-CSRF-TOKEN"
169
+ };
268
170
 
269
- return objectArray.map(function (object) {
270
- return copyKeysSingleObject(object, keyMap);
171
+ var resetAuthTokens = function resetAuthTokens() {
172
+ ramda.values(HEADERS_KEYS).forEach(function (header) {
173
+ delete axios__default["default"].defaults.headers[header];
271
174
  });
272
- });
273
-
274
- var regeneratorRuntime$1 = {exports: {}};
275
-
276
- var _typeof = {exports: {}};
277
-
278
- (function (module) {
279
- function _typeof(obj) {
280
- "@babel/helpers - typeof";
281
-
282
- return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
283
- return typeof obj;
284
- } : function (obj) {
285
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
286
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
287
- }
288
-
289
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
290
- } (_typeof));
291
-
292
- (function (module) {
293
- var _typeof$1 = _typeof.exports["default"];
294
-
295
- function _regeneratorRuntime() {
296
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
297
-
298
- module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
299
- return exports;
300
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
301
- var exports = {},
302
- Op = Object.prototype,
303
- hasOwn = Op.hasOwnProperty,
304
- $Symbol = "function" == typeof Symbol ? Symbol : {},
305
- iteratorSymbol = $Symbol.iterator || "@@iterator",
306
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
307
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
308
-
309
- function define(obj, key, value) {
310
- return Object.defineProperty(obj, key, {
311
- value: value,
312
- enumerable: !0,
313
- configurable: !0,
314
- writable: !0
315
- }), obj[key];
316
- }
317
-
318
- try {
319
- define({}, "");
320
- } catch (err) {
321
- define = function define(obj, key, value) {
322
- return obj[key] = value;
323
- };
324
- }
325
-
326
- function wrap(innerFn, outerFn, self, tryLocsList) {
327
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
328
- generator = Object.create(protoGenerator.prototype),
329
- context = new Context(tryLocsList || []);
330
- return generator._invoke = function (innerFn, self, context) {
331
- var state = "suspendedStart";
332
- return function (method, arg) {
333
- if ("executing" === state) throw new Error("Generator is already running");
334
-
335
- if ("completed" === state) {
336
- if ("throw" === method) throw arg;
337
- return doneResult();
338
- }
339
-
340
- for (context.method = method, context.arg = arg;;) {
341
- var delegate = context.delegate;
342
-
343
- if (delegate) {
344
- var delegateResult = maybeInvokeDelegate(delegate, context);
345
-
346
- if (delegateResult) {
347
- if (delegateResult === ContinueSentinel) continue;
348
- return delegateResult;
349
- }
350
- }
351
-
352
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
353
- if ("suspendedStart" === state) throw state = "completed", context.arg;
354
- context.dispatchException(context.arg);
355
- } else "return" === context.method && context.abrupt("return", context.arg);
356
- state = "executing";
357
- var record = tryCatch(innerFn, self, context);
358
-
359
- if ("normal" === record.type) {
360
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
361
- return {
362
- value: record.arg,
363
- done: context.done
364
- };
365
- }
366
-
367
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
368
- }
369
- };
370
- }(innerFn, self, context), generator;
371
- }
372
-
373
- function tryCatch(fn, obj, arg) {
374
- try {
375
- return {
376
- type: "normal",
377
- arg: fn.call(obj, arg)
378
- };
379
- } catch (err) {
380
- return {
381
- type: "throw",
382
- arg: err
383
- };
384
- }
385
- }
386
-
387
- exports.wrap = wrap;
388
- var ContinueSentinel = {};
389
-
390
- function Generator() {}
391
-
392
- function GeneratorFunction() {}
393
-
394
- function GeneratorFunctionPrototype() {}
395
-
396
- var IteratorPrototype = {};
397
- define(IteratorPrototype, iteratorSymbol, function () {
398
- return this;
399
- });
400
- var getProto = Object.getPrototypeOf,
401
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
402
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
403
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
404
-
405
- function defineIteratorMethods(prototype) {
406
- ["next", "throw", "return"].forEach(function (method) {
407
- define(prototype, method, function (arg) {
408
- return this._invoke(method, arg);
409
- });
410
- });
411
- }
412
-
413
- function AsyncIterator(generator, PromiseImpl) {
414
- function invoke(method, arg, resolve, reject) {
415
- var record = tryCatch(generator[method], generator, arg);
416
-
417
- if ("throw" !== record.type) {
418
- var result = record.arg,
419
- value = result.value;
420
- return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
421
- invoke("next", value, resolve, reject);
422
- }, function (err) {
423
- invoke("throw", err, resolve, reject);
424
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
425
- result.value = unwrapped, resolve(result);
426
- }, function (error) {
427
- return invoke("throw", error, resolve, reject);
428
- });
429
- }
430
-
431
- reject(record.arg);
432
- }
433
-
434
- var previousPromise;
435
-
436
- this._invoke = function (method, arg) {
437
- function callInvokeWithMethodAndArg() {
438
- return new PromiseImpl(function (resolve, reject) {
439
- invoke(method, arg, resolve, reject);
440
- });
441
- }
442
-
443
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
444
- };
445
- }
446
-
447
- function maybeInvokeDelegate(delegate, context) {
448
- var method = delegate.iterator[context.method];
449
-
450
- if (undefined === method) {
451
- if (context.delegate = null, "throw" === context.method) {
452
- if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
453
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
454
- }
455
-
456
- return ContinueSentinel;
457
- }
458
-
459
- var record = tryCatch(method, delegate.iterator, context.arg);
460
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
461
- var info = record.arg;
462
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
463
- }
464
-
465
- function pushTryEntry(locs) {
466
- var entry = {
467
- tryLoc: locs[0]
468
- };
469
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
470
- }
471
-
472
- function resetTryEntry(entry) {
473
- var record = entry.completion || {};
474
- record.type = "normal", delete record.arg, entry.completion = record;
475
- }
476
-
477
- function Context(tryLocsList) {
478
- this.tryEntries = [{
479
- tryLoc: "root"
480
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
481
- }
482
-
483
- function values(iterable) {
484
- if (iterable) {
485
- var iteratorMethod = iterable[iteratorSymbol];
486
- if (iteratorMethod) return iteratorMethod.call(iterable);
487
- if ("function" == typeof iterable.next) return iterable;
488
-
489
- if (!isNaN(iterable.length)) {
490
- var i = -1,
491
- next = function next() {
492
- for (; ++i < iterable.length;) {
493
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
494
- }
495
-
496
- return next.value = undefined, next.done = !0, next;
497
- };
498
-
499
- return next.next = next;
500
- }
501
- }
502
-
503
- return {
504
- next: doneResult
505
- };
506
- }
507
-
508
- function doneResult() {
509
- return {
510
- value: undefined,
511
- done: !0
512
- };
513
- }
514
-
515
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
516
- var ctor = "function" == typeof genFun && genFun.constructor;
517
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
518
- }, exports.mark = function (genFun) {
519
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
520
- }, exports.awrap = function (arg) {
521
- return {
522
- __await: arg
523
- };
524
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
525
- return this;
526
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
527
- void 0 === PromiseImpl && (PromiseImpl = Promise);
528
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
529
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
530
- return result.done ? result.value : iter.next();
531
- });
532
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
533
- return this;
534
- }), define(Gp, "toString", function () {
535
- return "[object Generator]";
536
- }), exports.keys = function (object) {
537
- var keys = [];
538
-
539
- for (var key in object) {
540
- keys.push(key);
541
- }
542
-
543
- return keys.reverse(), function next() {
544
- for (; keys.length;) {
545
- var key = keys.pop();
546
- if (key in object) return next.value = key, next.done = !1, next;
547
- }
548
-
549
- return next.done = !0, next;
550
- };
551
- }, exports.values = values, Context.prototype = {
552
- constructor: Context,
553
- reset: function reset(skipTempReset) {
554
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
555
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
556
- }
557
- },
558
- stop: function stop() {
559
- this.done = !0;
560
- var rootRecord = this.tryEntries[0].completion;
561
- if ("throw" === rootRecord.type) throw rootRecord.arg;
562
- return this.rval;
563
- },
564
- dispatchException: function dispatchException(exception) {
565
- if (this.done) throw exception;
566
- var context = this;
567
-
568
- function handle(loc, caught) {
569
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
570
- }
571
-
572
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
573
- var entry = this.tryEntries[i],
574
- record = entry.completion;
575
- if ("root" === entry.tryLoc) return handle("end");
576
-
577
- if (entry.tryLoc <= this.prev) {
578
- var hasCatch = hasOwn.call(entry, "catchLoc"),
579
- hasFinally = hasOwn.call(entry, "finallyLoc");
580
-
581
- if (hasCatch && hasFinally) {
582
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
583
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
584
- } else if (hasCatch) {
585
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
586
- } else {
587
- if (!hasFinally) throw new Error("try statement without catch or finally");
588
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
589
- }
590
- }
591
- }
592
- },
593
- abrupt: function abrupt(type, arg) {
594
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
595
- var entry = this.tryEntries[i];
596
-
597
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
598
- var finallyEntry = entry;
599
- break;
600
- }
601
- }
602
-
603
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
604
- var record = finallyEntry ? finallyEntry.completion : {};
605
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
606
- },
607
- complete: function complete(record, afterLoc) {
608
- if ("throw" === record.type) throw record.arg;
609
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
610
- },
611
- finish: function finish(finallyLoc) {
612
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
613
- var entry = this.tryEntries[i];
614
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
615
- }
616
- },
617
- "catch": function _catch(tryLoc) {
618
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
619
- var entry = this.tryEntries[i];
620
-
621
- if (entry.tryLoc === tryLoc) {
622
- var record = entry.completion;
623
-
624
- if ("throw" === record.type) {
625
- var thrown = record.arg;
626
- resetTryEntry(entry);
627
- }
628
-
629
- return thrown;
630
- }
631
- }
632
-
633
- throw new Error("illegal catch attempt");
634
- },
635
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
636
- return this.delegate = {
637
- iterator: values(iterable),
638
- resultName: resultName,
639
- nextLoc: nextLoc
640
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
641
- }
642
- }, exports;
643
- }
644
-
645
- module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
646
- } (regeneratorRuntime$1));
647
-
648
- // TODO(Babel 8): Remove this file.
649
-
650
- var runtime = regeneratorRuntime$1.exports();
651
-
652
- // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
653
- try {
654
- regeneratorRuntime = runtime;
655
- } catch (accidentalStrictMode) {
656
- if (typeof globalThis === "object") {
657
- globalThis.regeneratorRuntime = runtime;
658
- } else {
659
- Function("r", "regeneratorRuntime = r")(runtime);
660
- }
661
- }
662
-
663
- ramda.curry(function (func, event) {
664
- return func(event.target.value);
665
- });
666
-
667
- dayjs__default["default"].extend(relativeTime__default["default"]);
668
- dayjs__default["default"].extend(updateLocale__default["default"]);
669
-
670
- var _document$getElements, _document$getElements2;
671
- window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
672
- deepFreezeObject(window.globalProps);
175
+ };
673
176
 
674
177
  var setAxiosDefaults = function setAxiosDefaults() {
675
178
  axios__default["default"].defaults.baseURL = "/";
@@ -698,26 +201,51 @@ var handleSuccessResponse = function handleSuccessResponse(response) {
698
201
  _response$config$tran = _response$config.transformResponseCase,
699
202
  transformResponseCase = _response$config$tran === void 0 ? true : _response$config$tran,
700
203
  _response$config$incl = _response$config.includeMetadataInResponse,
701
- includeMetadataInResponse = _response$config$incl === void 0 ? false : _response$config$incl;
204
+ includeMetadataInResponse = _response$config$incl === void 0 ? false : _response$config$incl,
205
+ _response$config$show = _response$config.showToastr,
206
+ showToastr = _response$config$show === void 0 ? true : _response$config$show;
207
+
208
+ if (response.data) {
209
+ if (transformResponseCase) response.data = keysToCamelCase(response.data);
702
210
 
703
- if (transformResponseCase && response.data) {
704
- response.data = keysToCamelCase(response.data);
211
+ if (showToastr && typeof response.data.notice === "string") {
212
+ neetoui.Toastr.success(response.data.notice);
213
+ }
705
214
  }
706
215
 
707
216
  return includeMetadataInResponse ? response : response.data;
708
217
  };
709
218
 
219
+ var handleUnauthorizedErrorResponse = function handleUnauthorizedErrorResponse() {
220
+ resetAuthTokens();
221
+ setTimeout(function () {
222
+ var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
223
+ window.location.href = redirectTo;
224
+ }, 300);
225
+ };
226
+
227
+ var showErrorToastr = function showErrorToastr(error) {
228
+ if (axios__default["default"].isCancel(error)) {
229
+ neetoui.Toastr.error(i18next__default["default"].t("neetoCommons.toastr.error.requestCanceled"));
230
+ } else if (error.message === "Network Error") {
231
+ neetoui.Toastr.error(i18next__default["default"].t("neetoCommons.toastr.error.networkError"));
232
+ } else {
233
+ neetoui.Toastr.error(error);
234
+ }
235
+ };
236
+
710
237
  var handleErrorResponse = function handleErrorResponse(error) {
711
238
  var _error$response, _error$response2;
712
239
 
240
+ var _error$config$showToa = error.config.showToastr,
241
+ showToastr = _error$config$showToa === void 0 ? true : _error$config$showToa;
242
+
713
243
  if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 404) {
714
244
  window.location.href = "/page-not-found";
715
245
  } else if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 401) {
716
- resetAuthTokens();
717
- setTimeout(function () {
718
- var redirectTo = window.location.pathname === "/login" ? "/login" : "/login?redirect_uri=".concat(encodeURIComponent(window.location.href));
719
- window.location.href = redirectTo;
720
- }, 300);
246
+ handleUnauthorizedErrorResponse();
247
+ } else if (showToastr) {
248
+ showErrorToastr(error);
721
249
  }
722
250
 
723
251
  return Promise.reject(error);
@@ -731,13 +259,28 @@ var cleanupCredentialsForCrossOrigin = function cleanupCredentialsForCrossOrigin
731
259
  })(request);
732
260
  };
733
261
 
262
+ var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
263
+ if (Array.isArray(object)) {
264
+ return object.map(serializeKeysToSnakeCase);
265
+ } else if (object === null || _typeof(object) !== "object") {
266
+ return object;
267
+ }
268
+
269
+ return Object.fromEntries(Object.entries(object).map(function (_ref) {
270
+ var _ref2 = _slicedToArray(_ref, 2),
271
+ key = _ref2[0],
272
+ value = _ref2[1];
273
+
274
+ var val = typeof (value === null || value === void 0 ? void 0 : value.toJSON) === "function" ? value.toJSON() : value;
275
+ return [camelToSnakeCase(key), serializeKeysToSnakeCase(val)];
276
+ }));
277
+ };
278
+
734
279
  var transformDataToSnakeCase = function transformDataToSnakeCase(request) {
735
280
  var _request$transformReq = request.transformRequestCase,
736
281
  transformRequestCase = _request$transformReq === void 0 ? true : _request$transformReq;
737
282
  if (!transformRequestCase || !request.data) return request;
738
- return ramda.evolve({
739
- data: keysToSnakeCase
740
- })(request);
283
+ return ramda.modify("data", serializeKeysToSnakeCase, request);
741
284
  };
742
285
 
743
286
  var registerIntercepts = function registerIntercepts() {
@@ -772,6 +315,11 @@ var neetoCommons = {
772
315
  pageDoesNotExist: "Page does not exist.",
773
316
  goToHome: "Go home"
774
317
  },
318
+ fallbackComponent: {
319
+ somethingWentWrong: "Sorry, something went wrong.",
320
+ tryReloading: "Please try reloading the page.",
321
+ reload: "Reload"
322
+ },
775
323
  sidebar: {
776
324
  profile: "Profile",
777
325
  orgSettings: "Organization Settings",
@@ -787,6 +335,10 @@ var neetoCommons = {
787
335
  toastr: {
788
336
  success: {
789
337
  copiedToClipboard: "Copied to clipboard!"
338
+ },
339
+ error: {
340
+ requestCanceled: "Request cancelled",
341
+ networkError: "No Internet Connection"
790
342
  }
791
343
  },
792
344
  notice: {