@bigbinary/neeto-commons-frontend 2.0.18 → 2.0.20

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,7 +1,8 @@
1
1
  import { Toastr } from '@bigbinary/neetoui';
2
2
  import axios from 'axios';
3
3
  import i18next from 'i18next';
4
- import { curryN, isNil, values, evolve, omit, modify, mergeDeepLeft, either, isEmpty } from 'ramda';
4
+ import { curryN, isNil, values, prop, evolve, omit, modify, mergeDeepLeft, either, isEmpty } from 'ramda';
5
+ import require$$0, { useDebugValue } from 'react';
5
6
  import { initReactI18next } from 'react-i18next';
6
7
  import Logger from 'js-logger';
7
8
  import mixpanel from 'mixpanel-browser';
@@ -217,6 +218,561 @@ var resetAuthTokens = function resetAuthTokens() {
217
218
  });
218
219
  };
219
220
 
221
+ const createStoreImpl = (createState) => {
222
+ let state;
223
+ const listeners = /* @__PURE__ */ new Set();
224
+ const setState = (partial, replace) => {
225
+ const nextState = typeof partial === "function" ? partial(state) : partial;
226
+ if (!Object.is(nextState, state)) {
227
+ const previousState = state;
228
+ state = (replace != null ? replace : typeof nextState !== "object") ? nextState : Object.assign({}, state, nextState);
229
+ listeners.forEach((listener) => listener(state, previousState));
230
+ }
231
+ };
232
+ const getState = () => state;
233
+ const subscribe = (listener) => {
234
+ listeners.add(listener);
235
+ return () => listeners.delete(listener);
236
+ };
237
+ const destroy = () => listeners.clear();
238
+ const api = { setState, getState, subscribe, destroy };
239
+ state = createState(
240
+ setState,
241
+ getState,
242
+ api
243
+ );
244
+ return api;
245
+ };
246
+ const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
247
+
248
+ function getDefaultExportFromCjs (x) {
249
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
250
+ }
251
+
252
+ var withSelector = {exports: {}};
253
+
254
+ var withSelector_production_min = {};
255
+
256
+ var shim = {exports: {}};
257
+
258
+ var useSyncExternalStoreShim_production_min = {};
259
+
260
+ /**
261
+ * @license React
262
+ * use-sync-external-store-shim.production.min.js
263
+ *
264
+ * Copyright (c) Facebook, Inc. and its affiliates.
265
+ *
266
+ * This source code is licensed under the MIT license found in the
267
+ * LICENSE file in the root directory of this source tree.
268
+ */
269
+
270
+ var hasRequiredUseSyncExternalStoreShim_production_min;
271
+
272
+ function requireUseSyncExternalStoreShim_production_min () {
273
+ if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
274
+ hasRequiredUseSyncExternalStoreShim_production_min = 1;
275
+ var e=require$$0;function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
276
+ function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;useSyncExternalStoreShim_production_min.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
277
+ return useSyncExternalStoreShim_production_min;
278
+ }
279
+
280
+ var useSyncExternalStoreShim_development = {};
281
+
282
+ /**
283
+ * @license React
284
+ * use-sync-external-store-shim.development.js
285
+ *
286
+ * Copyright (c) Facebook, Inc. and its affiliates.
287
+ *
288
+ * This source code is licensed under the MIT license found in the
289
+ * LICENSE file in the root directory of this source tree.
290
+ */
291
+
292
+ var hasRequiredUseSyncExternalStoreShim_development;
293
+
294
+ function requireUseSyncExternalStoreShim_development () {
295
+ if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
296
+ hasRequiredUseSyncExternalStoreShim_development = 1;
297
+
298
+ if (process.env.NODE_ENV !== "production") {
299
+ (function() {
300
+
301
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
302
+ if (
303
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
304
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
305
+ 'function'
306
+ ) {
307
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
308
+ }
309
+ var React = require$$0;
310
+
311
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
312
+
313
+ function error(format) {
314
+ {
315
+ {
316
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
317
+ args[_key2 - 1] = arguments[_key2];
318
+ }
319
+
320
+ printWarning('error', format, args);
321
+ }
322
+ }
323
+ }
324
+
325
+ function printWarning(level, format, args) {
326
+ // When changing this logic, you might want to also
327
+ // update consoleWithStackDev.www.js as well.
328
+ {
329
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
330
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
331
+
332
+ if (stack !== '') {
333
+ format += '%s';
334
+ args = args.concat([stack]);
335
+ } // eslint-disable-next-line react-internal/safe-string-coercion
336
+
337
+
338
+ var argsWithFormat = args.map(function (item) {
339
+ return String(item);
340
+ }); // Careful: RN currently depends on this prefix
341
+
342
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
343
+ // breaks IE9: https://github.com/facebook/react/issues/13610
344
+ // eslint-disable-next-line react-internal/no-production-logging
345
+
346
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
347
+ }
348
+ }
349
+
350
+ /**
351
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
352
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
353
+ */
354
+ function is(x, y) {
355
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
356
+ ;
357
+ }
358
+
359
+ var objectIs = typeof Object.is === 'function' ? Object.is : is;
360
+
361
+ // dispatch for CommonJS interop named imports.
362
+
363
+ var useState = React.useState,
364
+ useEffect = React.useEffect,
365
+ useLayoutEffect = React.useLayoutEffect,
366
+ useDebugValue = React.useDebugValue;
367
+ var didWarnOld18Alpha = false;
368
+ var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
369
+ // because of a very particular set of implementation details and assumptions
370
+ // -- change any one of them and it will break. The most important assumption
371
+ // is that updates are always synchronous, because concurrent rendering is
372
+ // only available in versions of React that also have a built-in
373
+ // useSyncExternalStore API. And we only use this shim when the built-in API
374
+ // does not exist.
375
+ //
376
+ // Do not assume that the clever hacks used by this hook also work in general.
377
+ // The point of this shim is to replace the need for hacks by other libraries.
378
+
379
+ function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
380
+ // React do not expose a way to check if we're hydrating. So users of the shim
381
+ // will need to track that themselves and return the correct value
382
+ // from `getSnapshot`.
383
+ getServerSnapshot) {
384
+ {
385
+ if (!didWarnOld18Alpha) {
386
+ if (React.startTransition !== undefined) {
387
+ didWarnOld18Alpha = true;
388
+
389
+ error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
390
+ }
391
+ }
392
+ } // Read the current snapshot from the store on every render. Again, this
393
+ // breaks the rules of React, and only works here because of specific
394
+ // implementation details, most importantly that updates are
395
+ // always synchronous.
396
+
397
+
398
+ var value = getSnapshot();
399
+
400
+ {
401
+ if (!didWarnUncachedGetSnapshot) {
402
+ var cachedValue = getSnapshot();
403
+
404
+ if (!objectIs(value, cachedValue)) {
405
+ error('The result of getSnapshot should be cached to avoid an infinite loop');
406
+
407
+ didWarnUncachedGetSnapshot = true;
408
+ }
409
+ }
410
+ } // Because updates are synchronous, we don't queue them. Instead we force a
411
+ // re-render whenever the subscribed state changes by updating an some
412
+ // arbitrary useState hook. Then, during render, we call getSnapshot to read
413
+ // the current value.
414
+ //
415
+ // Because we don't actually use the state returned by the useState hook, we
416
+ // can save a bit of memory by storing other stuff in that slot.
417
+ //
418
+ // To implement the early bailout, we need to track some things on a mutable
419
+ // object. Usually, we would put that in a useRef hook, but we can stash it in
420
+ // our useState hook instead.
421
+ //
422
+ // To force a re-render, we call forceUpdate({inst}). That works because the
423
+ // new object always fails an equality check.
424
+
425
+
426
+ var _useState = useState({
427
+ inst: {
428
+ value: value,
429
+ getSnapshot: getSnapshot
430
+ }
431
+ }),
432
+ inst = _useState[0].inst,
433
+ forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
434
+ // in the layout phase so we can access it during the tearing check that
435
+ // happens on subscribe.
436
+
437
+
438
+ useLayoutEffect(function () {
439
+ inst.value = value;
440
+ inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
441
+ // commit phase if there was an interleaved mutation. In concurrent mode
442
+ // this can happen all the time, but even in synchronous mode, an earlier
443
+ // effect may have mutated the store.
444
+
445
+ if (checkIfSnapshotChanged(inst)) {
446
+ // Force a re-render.
447
+ forceUpdate({
448
+ inst: inst
449
+ });
450
+ }
451
+ }, [subscribe, value, getSnapshot]);
452
+ useEffect(function () {
453
+ // Check for changes right before subscribing. Subsequent changes will be
454
+ // detected in the subscription handler.
455
+ if (checkIfSnapshotChanged(inst)) {
456
+ // Force a re-render.
457
+ forceUpdate({
458
+ inst: inst
459
+ });
460
+ }
461
+
462
+ var handleStoreChange = function () {
463
+ // TODO: Because there is no cross-renderer API for batching updates, it's
464
+ // up to the consumer of this library to wrap their subscription event
465
+ // with unstable_batchedUpdates. Should we try to detect when this isn't
466
+ // the case and print a warning in development?
467
+ // The store changed. Check if the snapshot changed since the last time we
468
+ // read from the store.
469
+ if (checkIfSnapshotChanged(inst)) {
470
+ // Force a re-render.
471
+ forceUpdate({
472
+ inst: inst
473
+ });
474
+ }
475
+ }; // Subscribe to the store and return a clean-up function.
476
+
477
+
478
+ return subscribe(handleStoreChange);
479
+ }, [subscribe]);
480
+ useDebugValue(value);
481
+ return value;
482
+ }
483
+
484
+ function checkIfSnapshotChanged(inst) {
485
+ var latestGetSnapshot = inst.getSnapshot;
486
+ var prevValue = inst.value;
487
+
488
+ try {
489
+ var nextValue = latestGetSnapshot();
490
+ return !objectIs(prevValue, nextValue);
491
+ } catch (error) {
492
+ return true;
493
+ }
494
+ }
495
+
496
+ function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
497
+ // Note: The shim does not use getServerSnapshot, because pre-18 versions of
498
+ // React do not expose a way to check if we're hydrating. So users of the shim
499
+ // will need to track that themselves and return the correct value
500
+ // from `getSnapshot`.
501
+ return getSnapshot();
502
+ }
503
+
504
+ var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
505
+
506
+ var isServerEnvironment = !canUseDOM;
507
+
508
+ var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
509
+ var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
510
+
511
+ useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
512
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
513
+ if (
514
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
515
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
516
+ 'function'
517
+ ) {
518
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
519
+ }
520
+
521
+ })();
522
+ }
523
+ return useSyncExternalStoreShim_development;
524
+ }
525
+
526
+ var hasRequiredShim;
527
+
528
+ function requireShim () {
529
+ if (hasRequiredShim) return shim.exports;
530
+ hasRequiredShim = 1;
531
+ (function (module) {
532
+
533
+ if (process.env.NODE_ENV === 'production') {
534
+ module.exports = requireUseSyncExternalStoreShim_production_min();
535
+ } else {
536
+ module.exports = requireUseSyncExternalStoreShim_development();
537
+ }
538
+ } (shim));
539
+ return shim.exports;
540
+ }
541
+
542
+ /**
543
+ * @license React
544
+ * use-sync-external-store-shim/with-selector.production.min.js
545
+ *
546
+ * Copyright (c) Facebook, Inc. and its affiliates.
547
+ *
548
+ * This source code is licensed under the MIT license found in the
549
+ * LICENSE file in the root directory of this source tree.
550
+ */
551
+
552
+ var hasRequiredWithSelector_production_min;
553
+
554
+ function requireWithSelector_production_min () {
555
+ if (hasRequiredWithSelector_production_min) return withSelector_production_min;
556
+ hasRequiredWithSelector_production_min = 1;
557
+ var h=require$$0,n=requireShim();function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q="function"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;
558
+ withSelector_production_min.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f;}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return [function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);
559
+ u(function(){f.hasValue=!0;f.value=d;},[d]);w(d);return d};
560
+ return withSelector_production_min;
561
+ }
562
+
563
+ var withSelector_development = {};
564
+
565
+ /**
566
+ * @license React
567
+ * use-sync-external-store-shim/with-selector.development.js
568
+ *
569
+ * Copyright (c) Facebook, Inc. and its affiliates.
570
+ *
571
+ * This source code is licensed under the MIT license found in the
572
+ * LICENSE file in the root directory of this source tree.
573
+ */
574
+
575
+ var hasRequiredWithSelector_development;
576
+
577
+ function requireWithSelector_development () {
578
+ if (hasRequiredWithSelector_development) return withSelector_development;
579
+ hasRequiredWithSelector_development = 1;
580
+
581
+ if (process.env.NODE_ENV !== "production") {
582
+ (function() {
583
+
584
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
585
+ if (
586
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
587
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
588
+ 'function'
589
+ ) {
590
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
591
+ }
592
+ var React = require$$0;
593
+ var shim = requireShim();
594
+
595
+ /**
596
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
597
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
598
+ */
599
+ function is(x, y) {
600
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
601
+ ;
602
+ }
603
+
604
+ var objectIs = typeof Object.is === 'function' ? Object.is : is;
605
+
606
+ var useSyncExternalStore = shim.useSyncExternalStore;
607
+
608
+ // for CommonJS interop.
609
+
610
+ var useRef = React.useRef,
611
+ useEffect = React.useEffect,
612
+ useMemo = React.useMemo,
613
+ useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
614
+
615
+ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
616
+ // Use this to track the rendered snapshot.
617
+ var instRef = useRef(null);
618
+ var inst;
619
+
620
+ if (instRef.current === null) {
621
+ inst = {
622
+ hasValue: false,
623
+ value: null
624
+ };
625
+ instRef.current = inst;
626
+ } else {
627
+ inst = instRef.current;
628
+ }
629
+
630
+ var _useMemo = useMemo(function () {
631
+ // Track the memoized state using closure variables that are local to this
632
+ // memoized instance of a getSnapshot function. Intentionally not using a
633
+ // useRef hook, because that state would be shared across all concurrent
634
+ // copies of the hook/component.
635
+ var hasMemo = false;
636
+ var memoizedSnapshot;
637
+ var memoizedSelection;
638
+
639
+ var memoizedSelector = function (nextSnapshot) {
640
+ if (!hasMemo) {
641
+ // The first time the hook is called, there is no memoized result.
642
+ hasMemo = true;
643
+ memoizedSnapshot = nextSnapshot;
644
+
645
+ var _nextSelection = selector(nextSnapshot);
646
+
647
+ if (isEqual !== undefined) {
648
+ // Even if the selector has changed, the currently rendered selection
649
+ // may be equal to the new selection. We should attempt to reuse the
650
+ // current value if possible, to preserve downstream memoizations.
651
+ if (inst.hasValue) {
652
+ var currentSelection = inst.value;
653
+
654
+ if (isEqual(currentSelection, _nextSelection)) {
655
+ memoizedSelection = currentSelection;
656
+ return currentSelection;
657
+ }
658
+ }
659
+ }
660
+
661
+ memoizedSelection = _nextSelection;
662
+ return _nextSelection;
663
+ } // We may be able to reuse the previous invocation's result.
664
+
665
+
666
+ // We may be able to reuse the previous invocation's result.
667
+ var prevSnapshot = memoizedSnapshot;
668
+ var prevSelection = memoizedSelection;
669
+
670
+ if (objectIs(prevSnapshot, nextSnapshot)) {
671
+ // The snapshot is the same as last time. Reuse the previous selection.
672
+ return prevSelection;
673
+ } // The snapshot has changed, so we need to compute a new selection.
674
+
675
+
676
+ // The snapshot has changed, so we need to compute a new selection.
677
+ var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
678
+ // has changed. If it hasn't, return the previous selection. That signals
679
+ // to React that the selections are conceptually equal, and we can bail
680
+ // out of rendering.
681
+
682
+ // If a custom isEqual function is provided, use that to check if the data
683
+ // has changed. If it hasn't, return the previous selection. That signals
684
+ // to React that the selections are conceptually equal, and we can bail
685
+ // out of rendering.
686
+ if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
687
+ return prevSelection;
688
+ }
689
+
690
+ memoizedSnapshot = nextSnapshot;
691
+ memoizedSelection = nextSelection;
692
+ return nextSelection;
693
+ }; // Assigning this to a constant so that Flow knows it can't change.
694
+
695
+
696
+ // Assigning this to a constant so that Flow knows it can't change.
697
+ var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
698
+
699
+ var getSnapshotWithSelector = function () {
700
+ return memoizedSelector(getSnapshot());
701
+ };
702
+
703
+ var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
704
+ return memoizedSelector(maybeGetServerSnapshot());
705
+ };
706
+ return [getSnapshotWithSelector, getServerSnapshotWithSelector];
707
+ }, [getSnapshot, getServerSnapshot, selector, isEqual]),
708
+ getSelection = _useMemo[0],
709
+ getServerSelection = _useMemo[1];
710
+
711
+ var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
712
+ useEffect(function () {
713
+ inst.hasValue = true;
714
+ inst.value = value;
715
+ }, [value]);
716
+ useDebugValue(value);
717
+ return value;
718
+ }
719
+
720
+ withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
721
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
722
+ if (
723
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
724
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
725
+ 'function'
726
+ ) {
727
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
728
+ }
729
+
730
+ })();
731
+ }
732
+ return withSelector_development;
733
+ }
734
+
735
+ (function (module) {
736
+
737
+ if (process.env.NODE_ENV === 'production') {
738
+ module.exports = requireWithSelector_production_min();
739
+ } else {
740
+ module.exports = requireWithSelector_development();
741
+ }
742
+ } (withSelector));
743
+
744
+ var useSyncExternalStoreExports = /*@__PURE__*/getDefaultExportFromCjs(withSelector.exports);
745
+
746
+ const { useSyncExternalStoreWithSelector } = useSyncExternalStoreExports;
747
+ function useStore(api, selector = api.getState, equalityFn) {
748
+ const slice = useSyncExternalStoreWithSelector(
749
+ api.subscribe,
750
+ api.getState,
751
+ api.getServerState || api.getState,
752
+ selector,
753
+ equalityFn
754
+ );
755
+ useDebugValue(slice);
756
+ return slice;
757
+ }
758
+ const createImpl = (createState) => {
759
+ const api = typeof createState === "function" ? createStore(createState) : createState;
760
+ const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
761
+ Object.assign(useBoundStore, api);
762
+ return useBoundStore;
763
+ };
764
+ const create = (createState) => createState ? createImpl(createState) : createImpl;
765
+
766
+ var useDisplayErrorPage = function useDisplayErrorPage() {
767
+ return useErrorDisplayStore(prop("show404Page"));
768
+ };
769
+
770
+ var useErrorDisplayStore = create(function () {
771
+ return {
772
+ show404Page: false
773
+ };
774
+ });
775
+
220
776
  var shouldNot = function shouldNot(skip) {
221
777
  return _typeof(skip) === "object" || !skip;
222
778
  };
@@ -244,7 +800,7 @@ var createPipe = function createPipe(functions) {
244
800
  };
245
801
  };
246
802
 
247
- var transformKeysToCamelCase = function transformKeysToCamelCase(response) {
803
+ var transformResponseKeysToCamelCase = function transformResponseKeysToCamelCase(response) {
248
804
  var _response$config$tran = response.config.transformResponseCase,
249
805
  transformResponseCase = _response$config$tran === void 0 ? true : _response$config$tran;
250
806
 
@@ -255,6 +811,17 @@ var transformKeysToCamelCase = function transformKeysToCamelCase(response) {
255
811
  return response;
256
812
  };
257
813
 
814
+ var transformErrorKeysToCamelCase = function transformErrorKeysToCamelCase(error) {
815
+ var _error$config$transfo = error.config.transformResponseCase,
816
+ transformResponseCase = _error$config$transfo === void 0 ? true : _error$config$transfo;
817
+
818
+ if (error.response.data && transformResponseCase) {
819
+ error.response.data = keysToCamelCase(error.response.data);
820
+ }
821
+
822
+ return error;
823
+ };
824
+
258
825
  var showSuccessToastr = function showSuccessToastr(response) {
259
826
  var _response$config$show = response.config.showToastr,
260
827
  showToastr = _response$config$show === void 0 ? true : _response$config$show;
@@ -274,7 +841,7 @@ var pullDataFromResponse = function pullDataFromResponse(response) {
274
841
 
275
842
  var buildSuccessResponseHandler = function buildSuccessResponseHandler(skip) {
276
843
  var interceptors = [];
277
- if (!(skip !== null && skip !== void 0 && skip.transformCase)) interceptors.push(transformKeysToCamelCase);
844
+ if (!(skip !== null && skip !== void 0 && skip.transformCase)) interceptors.push(transformResponseKeysToCamelCase);
278
845
  if (!(skip !== null && skip !== void 0 && skip.showToastr)) interceptors.push(showSuccessToastr);
279
846
  if (!(skip !== null && skip !== void 0 && skip.pullDataFromResponse)) interceptors.push(pullDataFromResponse);
280
847
  return createPipe(interceptors);
@@ -314,14 +881,17 @@ var showErrorToastr = function showErrorToastr(error) {
314
881
  return error;
315
882
  };
316
883
 
317
- var redirect404 = function redirect404(error) {
884
+ var handle404ErrorResponse = function handle404ErrorResponse(error) {
318
885
  var _error$response2;
319
886
 
320
- var _error$config$redirec2 = error.config.redirectOnError,
321
- redirectOnError = _error$config$redirec2 === void 0 ? true : _error$config$redirec2;
887
+ if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) !== 404) return error;
888
+ var _error$config$show = error.config.show404ErrorPage,
889
+ show404ErrorPage = _error$config$show === void 0 ? true : _error$config$show;
322
890
 
323
- if (redirectOnError && ((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 404) {
324
- window.location.href = "/page-not-found";
891
+ if (show404ErrorPage) {
892
+ useErrorDisplayStore.setState({
893
+ show404Page: true
894
+ });
325
895
  }
326
896
 
327
897
  return error;
@@ -329,7 +899,8 @@ var redirect404 = function redirect404(error) {
329
899
 
330
900
  var buildErrorResponseHandler = function buildErrorResponseHandler(skip) {
331
901
  var interceptors = [];
332
- if (!(skip !== null && skip !== void 0 && skip.redirectOn404)) interceptors.push(redirect404);
902
+ if (!(skip !== null && skip !== void 0 && skip.transformCase)) interceptors.push(transformErrorKeysToCamelCase);
903
+ if (!(skip !== null && skip !== void 0 && skip.show404ErrorPage)) interceptors.push(handle404ErrorResponse);
333
904
  if (!(skip !== null && skip !== void 0 && skip.logoutOn401)) interceptors.push(handleUnauthorizedErrorResponse);
334
905
  if (!(skip !== null && skip !== void 0 && skip.showToastr)) interceptors.push(showErrorToastr);
335
906
  interceptors.push(Promise.reject.bind(Promise));
@@ -394,8 +965,8 @@ var neetoCommons = {
394
965
  reload: "Reload"
395
966
  },
396
967
  sidebar: {
397
- myProfile: "My Profile",
398
- myOrganization: "My Organization",
968
+ myProfile: "My profile",
969
+ myOrganization: "My organization",
399
970
  logout: "Logout",
400
971
  help: "Help"
401
972
  },
@@ -592,4 +1163,4 @@ function initializeApplication(_ref) {
592
1163
  if (!(skip !== null && skip !== void 0 && skip.logger)) initializeLogger();
593
1164
  }
594
1165
 
595
- export { initializeApplication as default, globalProps$1 as globalProps };
1166
+ export { initializeApplication as default, globalProps$1 as globalProps, useDisplayErrorPage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "2.0.18",
3
+ "version": "2.0.20",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",