@bonlineza/luxity-lib 2.35.4 → 2.35.6
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/AddProductInterest.js +127 -5
- package/GraphQLDropdownSelector.js +126 -5
- package/Interests.js +127 -5
- package/LuxityDesktopHeader.js +300 -237
- package/LuxityGraphQLDropdownSelector.js +126 -5
- package/LuxityMobileHeader.js +318 -228
- package/MaterialSelector.js +126 -5
- package/ModelSelector.js +126 -5
- package/build/bundle.css +1 -1
- package/build/bundle.js +509 -293
- package/package.json +1 -1
- package/build/.gitignore +0 -3
- package/build/.npmignore +0 -0
package/AddProductInterest.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('styled-components'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['react', 'styled-components', '
|
|
4
|
-
(global = global || self, global.AddProductInterest = factory(global.React, global.styled, global.
|
|
5
|
-
}(this, (function (React, styled,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('styled-components'), require('axios'), require('js-cookie'), require('react-notify-toast'), require('stylis-rule-sheet'), require('react-dom'), require('prop-types'), require('raf'), require('react-input-autosize'), require('react-transition-group')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['react', 'styled-components', 'axios', 'js-cookie', 'react-notify-toast', 'stylis-rule-sheet', 'react-dom', 'prop-types', 'raf', 'react-input-autosize', 'react-transition-group'], factory) :
|
|
4
|
+
(global = global || self, global.AddProductInterest = factory(global.React, global.styled, global.axios, global.Cookies, global['react-notify-toast'], global['stylis-rule-sheet'], global.reactDom, global.PropTypes, global.raf, global['react-input-autosize'], global['react-transition-group']));
|
|
5
|
+
}(this, (function (React, styled, axios, Cookies, Notifications, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var React__default = 'default' in React ? React['default'] : React;
|
|
8
8
|
var styled__default = 'default' in styled ? styled['default'] : styled;
|
|
9
|
-
|
|
9
|
+
axios = axios && Object.prototype.hasOwnProperty.call(axios, 'default') ? axios['default'] : axios;
|
|
10
|
+
Cookies = Cookies && Object.prototype.hasOwnProperty.call(Cookies, 'default') ? Cookies['default'] : Cookies;
|
|
10
11
|
var Notifications__default = 'default' in Notifications ? Notifications['default'] : Notifications;
|
|
11
12
|
stylisRuleSheet = stylisRuleSheet && Object.prototype.hasOwnProperty.call(stylisRuleSheet, 'default') ? stylisRuleSheet['default'] : stylisRuleSheet;
|
|
12
13
|
PropTypes = PropTypes && Object.prototype.hasOwnProperty.call(PropTypes, 'default') ? PropTypes['default'] : PropTypes;
|
|
@@ -559,6 +560,127 @@
|
|
|
559
560
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
560
561
|
}
|
|
561
562
|
|
|
563
|
+
function getToken() {
|
|
564
|
+
var _Cookies$get;
|
|
565
|
+
|
|
566
|
+
return (_Cookies$get = Cookies.get('_tk')) === null || _Cookies$get === void 0 ? void 0 : _Cookies$get.replace('*', 'Bearer ');
|
|
567
|
+
}
|
|
568
|
+
function setToken(value) {
|
|
569
|
+
Cookies.set('_tk', value, 30);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/** @format */
|
|
573
|
+
|
|
574
|
+
function getEncodedSearch(currentUrl) {
|
|
575
|
+
var splitUrl = currentUrl.split('?');
|
|
576
|
+
var baseUrl = splitUrl[0];
|
|
577
|
+
var nextUrlSegments = splitUrl[1].split('&');
|
|
578
|
+
var nextQueryString = splitUrl[1];
|
|
579
|
+
|
|
580
|
+
if (nextUrlSegments.length > 0) {
|
|
581
|
+
nextQueryString = nextUrlSegments.map(function (v) {
|
|
582
|
+
var nextValue = v;
|
|
583
|
+
|
|
584
|
+
if (v.includes('search=')) {
|
|
585
|
+
var temp = v.split('=');
|
|
586
|
+
nextValue = "".concat(temp[0], "=").concat(encodeURIComponent(temp[1]));
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
return nextValue;
|
|
590
|
+
}).join('&');
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return "".concat(baseUrl, "?").concat(nextQueryString);
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Gets an instance of Axios that is configured with the custom failure handlers
|
|
597
|
+
* @param {Function} onAuthFailed - callback triggers when auth fails - ie, server error is one of ['token_invalid', 'token_not_provided', 'user_not_found', 'token_expired'] or http status is one of [401, 503, 400]
|
|
598
|
+
* @param {Function} onForbidden - callback triggers when http status = 403
|
|
599
|
+
*/
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
var axiosInstance = function axiosInstance(onAuthFailed, onForbidden) {
|
|
603
|
+
var instance = axios.create({
|
|
604
|
+
validateStatus: function validateStatus(status) {
|
|
605
|
+
return status >= 200 && status < 300;
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
var token = getToken();
|
|
609
|
+
|
|
610
|
+
if (token !== '') {
|
|
611
|
+
instance.defaults.headers.common.Authorization = token;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
instance.defaults.headers.common['Content-Type'] = 'application/json;charset=UTF-8'; // Add a request interceptor
|
|
615
|
+
|
|
616
|
+
instance.interceptors.request.use(function (request, error) {
|
|
617
|
+
if (error) {
|
|
618
|
+
return Promise.reject(error.response);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
if (request.url.includes('search') && request.url.includes('?')) {
|
|
622
|
+
// do some uri manipulation for ie
|
|
623
|
+
// https://stackoverflow.com/questions/18220057
|
|
624
|
+
// eslint-disable-next-line no-param-reassign
|
|
625
|
+
request.url = getEncodedSearch(request.url);
|
|
626
|
+
} // eslint-disable-next-line no-param-reassign
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
request.headers.common['Content-Type'] = 'application/json; charset=utf-8';
|
|
630
|
+
|
|
631
|
+
if (typeof request.body === 'undefined') {
|
|
632
|
+
request.body = {};
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
token = getToken();
|
|
636
|
+
|
|
637
|
+
if (token !== '') {
|
|
638
|
+
// eslint-disable-next-line no-param-reassign
|
|
639
|
+
request.headers.common.Authorization = token;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
return request;
|
|
643
|
+
}, function (error) {
|
|
644
|
+
return Promise.reject(error.message);
|
|
645
|
+
}); // Add a response interceptor
|
|
646
|
+
|
|
647
|
+
instance.interceptors.response.use(function (response, error) {
|
|
648
|
+
if (error) {
|
|
649
|
+
return Promise.reject(error.response);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (response.headers.authorization) {
|
|
653
|
+
setToken(response.headers.authorization);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
return response;
|
|
657
|
+
}, function (error) {
|
|
658
|
+
if (error.response) {
|
|
659
|
+
// network error
|
|
660
|
+
if (error.response.data && error.response.data.error && (error.response.data.error === 'token_invalid' || error.response.data.error === 'token_not_provided' || error.response.data.error === 'user_not_found' || error.response.data.error === 'token_expired') || error.response.status === 401 || error.response.status === 503 || error.response.status === 400) {
|
|
661
|
+
onAuthFailed();
|
|
662
|
+
} // if (error.response.status === 500) {
|
|
663
|
+
// // INTERNAL SERVER ERROR
|
|
664
|
+
// store.dispatch({
|
|
665
|
+
// type: AppConstants.OVERLAY.SERVER_ERROR,
|
|
666
|
+
// });
|
|
667
|
+
// return Promise.reject(error.response);
|
|
668
|
+
// }
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
if (error.response.status === 403) {
|
|
672
|
+
// FORBIDDEN
|
|
673
|
+
onForbidden();
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
return Promise.reject(error.response);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
return Promise.reject(error);
|
|
680
|
+
});
|
|
681
|
+
return instance;
|
|
682
|
+
}; // NOTE: this to be instanciated with params: onAuthFailed, onForbidden
|
|
683
|
+
|
|
562
684
|
var defaultNotifyTime = 5000;
|
|
563
685
|
var error = function error(message) {
|
|
564
686
|
Notifications.notify.show(message, 'error', defaultNotifyTime);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('styled-components'), require('@bonlineza/b-lib/EllipsisLoader'), require('@bonlineza/b-lib/PageReady'), require('react-animate-height'), require('numeral'), require('stylis-rule-sheet'), require('react-dom'), require('prop-types'), require('raf'), require('react-input-autosize'), require('react-transition-group'), require('@bonlineza/b-lib/functions'), require('rc-slider'), require('react-notify-toast'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['react', 'styled-components', '@bonlineza/b-lib/EllipsisLoader', '@bonlineza/b-lib/PageReady', 'react-animate-height', 'numeral', 'stylis-rule-sheet', 'react-dom', 'prop-types', 'raf', 'react-input-autosize', 'react-transition-group', '@bonlineza/b-lib/functions', 'rc-slider', 'react-notify-toast', '
|
|
4
|
-
(global = global || self, global.GraphQLDropdownSelector = factory(global.React, global.styled, global.EllipsisLoader, global.PageReady, global.AnimateHeight, global.numeral, global['stylis-rule-sheet'], global.reactDom, global.PropTypes, global.raf, global['react-input-autosize'], global['react-transition-group'], global.function, global.rcSlider, global['react-notify-toast'], global.
|
|
5
|
-
}(this, (function (React, styled, EllipsisLoader, PageReady, AnimateHeight, numeral, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup, functions, rcSlider, Notifications,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('styled-components'), require('@bonlineza/b-lib/EllipsisLoader'), require('@bonlineza/b-lib/PageReady'), require('react-animate-height'), require('numeral'), require('stylis-rule-sheet'), require('react-dom'), require('prop-types'), require('raf'), require('react-input-autosize'), require('react-transition-group'), require('@bonlineza/b-lib/functions'), require('rc-slider'), require('react-notify-toast'), require('axios'), require('js-cookie')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['react', 'styled-components', '@bonlineza/b-lib/EllipsisLoader', '@bonlineza/b-lib/PageReady', 'react-animate-height', 'numeral', 'stylis-rule-sheet', 'react-dom', 'prop-types', 'raf', 'react-input-autosize', 'react-transition-group', '@bonlineza/b-lib/functions', 'rc-slider', 'react-notify-toast', 'axios', 'js-cookie'], factory) :
|
|
4
|
+
(global = global || self, global.GraphQLDropdownSelector = factory(global.React, global.styled, global.EllipsisLoader, global.PageReady, global.AnimateHeight, global.numeral, global['stylis-rule-sheet'], global.reactDom, global.PropTypes, global.raf, global['react-input-autosize'], global['react-transition-group'], global.function, global.rcSlider, global['react-notify-toast'], global.axios, global.Cookies));
|
|
5
|
+
}(this, (function (React, styled, EllipsisLoader, PageReady, AnimateHeight, numeral, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup, functions, rcSlider, Notifications, axios, Cookies) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var React__default = 'default' in React ? React['default'] : React;
|
|
8
8
|
var styled__default = 'default' in styled ? styled['default'] : styled;
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
raf = raf && Object.prototype.hasOwnProperty.call(raf, 'default') ? raf['default'] : raf;
|
|
16
16
|
AutosizeInput = AutosizeInput && Object.prototype.hasOwnProperty.call(AutosizeInput, 'default') ? AutosizeInput['default'] : AutosizeInput;
|
|
17
17
|
var Notifications__default = 'default' in Notifications ? Notifications['default'] : Notifications;
|
|
18
|
-
axiosInstance = axiosInstance && Object.prototype.hasOwnProperty.call(axiosInstance, 'default') ? axiosInstance['default'] : axiosInstance;
|
|
19
18
|
axios = axios && Object.prototype.hasOwnProperty.call(axios, 'default') ? axios['default'] : axios;
|
|
19
|
+
Cookies = Cookies && Object.prototype.hasOwnProperty.call(Cookies, 'default') ? Cookies['default'] : Cookies;
|
|
20
20
|
|
|
21
21
|
function ownKeys(object, enumerableOnly) {
|
|
22
22
|
var keys = Object.keys(object);
|
|
@@ -11009,6 +11009,127 @@
|
|
|
11009
11009
|
}));
|
|
11010
11010
|
});
|
|
11011
11011
|
|
|
11012
|
+
function getToken() {
|
|
11013
|
+
var _Cookies$get;
|
|
11014
|
+
|
|
11015
|
+
return (_Cookies$get = Cookies.get('_tk')) === null || _Cookies$get === void 0 ? void 0 : _Cookies$get.replace('*', 'Bearer ');
|
|
11016
|
+
}
|
|
11017
|
+
function setToken(value) {
|
|
11018
|
+
Cookies.set('_tk', value, 30);
|
|
11019
|
+
}
|
|
11020
|
+
|
|
11021
|
+
/** @format */
|
|
11022
|
+
|
|
11023
|
+
function getEncodedSearch(currentUrl) {
|
|
11024
|
+
var splitUrl = currentUrl.split('?');
|
|
11025
|
+
var baseUrl = splitUrl[0];
|
|
11026
|
+
var nextUrlSegments = splitUrl[1].split('&');
|
|
11027
|
+
var nextQueryString = splitUrl[1];
|
|
11028
|
+
|
|
11029
|
+
if (nextUrlSegments.length > 0) {
|
|
11030
|
+
nextQueryString = nextUrlSegments.map(function (v) {
|
|
11031
|
+
var nextValue = v;
|
|
11032
|
+
|
|
11033
|
+
if (v.includes('search=')) {
|
|
11034
|
+
var temp = v.split('=');
|
|
11035
|
+
nextValue = "".concat(temp[0], "=").concat(encodeURIComponent(temp[1]));
|
|
11036
|
+
}
|
|
11037
|
+
|
|
11038
|
+
return nextValue;
|
|
11039
|
+
}).join('&');
|
|
11040
|
+
}
|
|
11041
|
+
|
|
11042
|
+
return "".concat(baseUrl, "?").concat(nextQueryString);
|
|
11043
|
+
}
|
|
11044
|
+
/**
|
|
11045
|
+
* Gets an instance of Axios that is configured with the custom failure handlers
|
|
11046
|
+
* @param {Function} onAuthFailed - callback triggers when auth fails - ie, server error is one of ['token_invalid', 'token_not_provided', 'user_not_found', 'token_expired'] or http status is one of [401, 503, 400]
|
|
11047
|
+
* @param {Function} onForbidden - callback triggers when http status = 403
|
|
11048
|
+
*/
|
|
11049
|
+
|
|
11050
|
+
|
|
11051
|
+
var axiosInstance = function axiosInstance(onAuthFailed, onForbidden) {
|
|
11052
|
+
var instance = axios.create({
|
|
11053
|
+
validateStatus: function validateStatus(status) {
|
|
11054
|
+
return status >= 200 && status < 300;
|
|
11055
|
+
}
|
|
11056
|
+
});
|
|
11057
|
+
var token = getToken();
|
|
11058
|
+
|
|
11059
|
+
if (token !== '') {
|
|
11060
|
+
instance.defaults.headers.common.Authorization = token;
|
|
11061
|
+
}
|
|
11062
|
+
|
|
11063
|
+
instance.defaults.headers.common['Content-Type'] = 'application/json;charset=UTF-8'; // Add a request interceptor
|
|
11064
|
+
|
|
11065
|
+
instance.interceptors.request.use(function (request, error) {
|
|
11066
|
+
if (error) {
|
|
11067
|
+
return Promise.reject(error.response);
|
|
11068
|
+
}
|
|
11069
|
+
|
|
11070
|
+
if (request.url.includes('search') && request.url.includes('?')) {
|
|
11071
|
+
// do some uri manipulation for ie
|
|
11072
|
+
// https://stackoverflow.com/questions/18220057
|
|
11073
|
+
// eslint-disable-next-line no-param-reassign
|
|
11074
|
+
request.url = getEncodedSearch(request.url);
|
|
11075
|
+
} // eslint-disable-next-line no-param-reassign
|
|
11076
|
+
|
|
11077
|
+
|
|
11078
|
+
request.headers.common['Content-Type'] = 'application/json; charset=utf-8';
|
|
11079
|
+
|
|
11080
|
+
if (typeof request.body === 'undefined') {
|
|
11081
|
+
request.body = {};
|
|
11082
|
+
}
|
|
11083
|
+
|
|
11084
|
+
token = getToken();
|
|
11085
|
+
|
|
11086
|
+
if (token !== '') {
|
|
11087
|
+
// eslint-disable-next-line no-param-reassign
|
|
11088
|
+
request.headers.common.Authorization = token;
|
|
11089
|
+
}
|
|
11090
|
+
|
|
11091
|
+
return request;
|
|
11092
|
+
}, function (error) {
|
|
11093
|
+
return Promise.reject(error.message);
|
|
11094
|
+
}); // Add a response interceptor
|
|
11095
|
+
|
|
11096
|
+
instance.interceptors.response.use(function (response, error) {
|
|
11097
|
+
if (error) {
|
|
11098
|
+
return Promise.reject(error.response);
|
|
11099
|
+
}
|
|
11100
|
+
|
|
11101
|
+
if (response.headers.authorization) {
|
|
11102
|
+
setToken(response.headers.authorization);
|
|
11103
|
+
}
|
|
11104
|
+
|
|
11105
|
+
return response;
|
|
11106
|
+
}, function (error) {
|
|
11107
|
+
if (error.response) {
|
|
11108
|
+
// network error
|
|
11109
|
+
if (error.response.data && error.response.data.error && (error.response.data.error === 'token_invalid' || error.response.data.error === 'token_not_provided' || error.response.data.error === 'user_not_found' || error.response.data.error === 'token_expired') || error.response.status === 401 || error.response.status === 503 || error.response.status === 400) {
|
|
11110
|
+
onAuthFailed();
|
|
11111
|
+
} // if (error.response.status === 500) {
|
|
11112
|
+
// // INTERNAL SERVER ERROR
|
|
11113
|
+
// store.dispatch({
|
|
11114
|
+
// type: AppConstants.OVERLAY.SERVER_ERROR,
|
|
11115
|
+
// });
|
|
11116
|
+
// return Promise.reject(error.response);
|
|
11117
|
+
// }
|
|
11118
|
+
|
|
11119
|
+
|
|
11120
|
+
if (error.response.status === 403) {
|
|
11121
|
+
// FORBIDDEN
|
|
11122
|
+
onForbidden();
|
|
11123
|
+
}
|
|
11124
|
+
|
|
11125
|
+
return Promise.reject(error.response);
|
|
11126
|
+
}
|
|
11127
|
+
|
|
11128
|
+
return Promise.reject(error);
|
|
11129
|
+
});
|
|
11130
|
+
return instance;
|
|
11131
|
+
}; // NOTE: this to be instanciated with params: onAuthFailed, onForbidden
|
|
11132
|
+
|
|
11012
11133
|
var _excluded$8 = ["children"];
|
|
11013
11134
|
|
|
11014
11135
|
var DropdownSelector = function DropdownSelector(_ref) {
|
package/Interests.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('styled-components'), require('react-notify-toast'), require('@bonlineza/b-lib/EllipsisLoader'), require('@bonlineza/b-lib/PageReady'), require('stylis-rule-sheet'), require('react-dom'), require('prop-types'), require('raf'), require('react-input-autosize'), require('react-transition-group'), require('@bonlineza/b-lib/functions'), require('rc-slider'), require('numeral'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['react', 'styled-components', 'react-notify-toast', '@bonlineza/b-lib/EllipsisLoader', '@bonlineza/b-lib/PageReady', 'stylis-rule-sheet', 'react-dom', 'prop-types', 'raf', 'react-input-autosize', 'react-transition-group', '@bonlineza/b-lib/functions', 'rc-slider', 'numeral', '
|
|
4
|
-
(global = global || self, global.Interests = factory(global.React, global.styled, global['react-notify-toast'], global.EllipsisLoader, global.PageReady, global['stylis-rule-sheet'], global.reactDom, global.PropTypes, global.raf, global['react-input-autosize'], global['react-transition-group'], global.function, global.rcSlider, global.numeral, global.
|
|
5
|
-
}(this, (function (React, styled, Notifications, EllipsisLoader, PageReady, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup, functions, rcSlider, numeral,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react'), require('styled-components'), require('react-notify-toast'), require('@bonlineza/b-lib/EllipsisLoader'), require('@bonlineza/b-lib/PageReady'), require('stylis-rule-sheet'), require('react-dom'), require('prop-types'), require('raf'), require('react-input-autosize'), require('react-transition-group'), require('@bonlineza/b-lib/functions'), require('rc-slider'), require('numeral'), require('axios'), require('js-cookie')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['react', 'styled-components', 'react-notify-toast', '@bonlineza/b-lib/EllipsisLoader', '@bonlineza/b-lib/PageReady', 'stylis-rule-sheet', 'react-dom', 'prop-types', 'raf', 'react-input-autosize', 'react-transition-group', '@bonlineza/b-lib/functions', 'rc-slider', 'numeral', 'axios', 'js-cookie'], factory) :
|
|
4
|
+
(global = global || self, global.Interests = factory(global.React, global.styled, global['react-notify-toast'], global.EllipsisLoader, global.PageReady, global['stylis-rule-sheet'], global.reactDom, global.PropTypes, global.raf, global['react-input-autosize'], global['react-transition-group'], global.function, global.rcSlider, global.numeral, global.axios, global.Cookies));
|
|
5
|
+
}(this, (function (React, styled, Notifications, EllipsisLoader, PageReady, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup, functions, rcSlider, numeral, axios, Cookies) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var React__default = 'default' in React ? React['default'] : React;
|
|
8
8
|
var styled__default = 'default' in styled ? styled['default'] : styled;
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
raf = raf && Object.prototype.hasOwnProperty.call(raf, 'default') ? raf['default'] : raf;
|
|
15
15
|
AutosizeInput = AutosizeInput && Object.prototype.hasOwnProperty.call(AutosizeInput, 'default') ? AutosizeInput['default'] : AutosizeInput;
|
|
16
16
|
numeral = numeral && Object.prototype.hasOwnProperty.call(numeral, 'default') ? numeral['default'] : numeral;
|
|
17
|
-
|
|
17
|
+
axios = axios && Object.prototype.hasOwnProperty.call(axios, 'default') ? axios['default'] : axios;
|
|
18
|
+
Cookies = Cookies && Object.prototype.hasOwnProperty.call(Cookies, 'default') ? Cookies['default'] : Cookies;
|
|
18
19
|
|
|
19
20
|
function ownKeys(object, enumerableOnly) {
|
|
20
21
|
var keys = Object.keys(object);
|
|
@@ -10872,6 +10873,127 @@
|
|
|
10872
10873
|
}));
|
|
10873
10874
|
});
|
|
10874
10875
|
|
|
10876
|
+
function getToken() {
|
|
10877
|
+
var _Cookies$get;
|
|
10878
|
+
|
|
10879
|
+
return (_Cookies$get = Cookies.get('_tk')) === null || _Cookies$get === void 0 ? void 0 : _Cookies$get.replace('*', 'Bearer ');
|
|
10880
|
+
}
|
|
10881
|
+
function setToken(value) {
|
|
10882
|
+
Cookies.set('_tk', value, 30);
|
|
10883
|
+
}
|
|
10884
|
+
|
|
10885
|
+
/** @format */
|
|
10886
|
+
|
|
10887
|
+
function getEncodedSearch(currentUrl) {
|
|
10888
|
+
var splitUrl = currentUrl.split('?');
|
|
10889
|
+
var baseUrl = splitUrl[0];
|
|
10890
|
+
var nextUrlSegments = splitUrl[1].split('&');
|
|
10891
|
+
var nextQueryString = splitUrl[1];
|
|
10892
|
+
|
|
10893
|
+
if (nextUrlSegments.length > 0) {
|
|
10894
|
+
nextQueryString = nextUrlSegments.map(function (v) {
|
|
10895
|
+
var nextValue = v;
|
|
10896
|
+
|
|
10897
|
+
if (v.includes('search=')) {
|
|
10898
|
+
var temp = v.split('=');
|
|
10899
|
+
nextValue = "".concat(temp[0], "=").concat(encodeURIComponent(temp[1]));
|
|
10900
|
+
}
|
|
10901
|
+
|
|
10902
|
+
return nextValue;
|
|
10903
|
+
}).join('&');
|
|
10904
|
+
}
|
|
10905
|
+
|
|
10906
|
+
return "".concat(baseUrl, "?").concat(nextQueryString);
|
|
10907
|
+
}
|
|
10908
|
+
/**
|
|
10909
|
+
* Gets an instance of Axios that is configured with the custom failure handlers
|
|
10910
|
+
* @param {Function} onAuthFailed - callback triggers when auth fails - ie, server error is one of ['token_invalid', 'token_not_provided', 'user_not_found', 'token_expired'] or http status is one of [401, 503, 400]
|
|
10911
|
+
* @param {Function} onForbidden - callback triggers when http status = 403
|
|
10912
|
+
*/
|
|
10913
|
+
|
|
10914
|
+
|
|
10915
|
+
var axiosInstance = function axiosInstance(onAuthFailed, onForbidden) {
|
|
10916
|
+
var instance = axios.create({
|
|
10917
|
+
validateStatus: function validateStatus(status) {
|
|
10918
|
+
return status >= 200 && status < 300;
|
|
10919
|
+
}
|
|
10920
|
+
});
|
|
10921
|
+
var token = getToken();
|
|
10922
|
+
|
|
10923
|
+
if (token !== '') {
|
|
10924
|
+
instance.defaults.headers.common.Authorization = token;
|
|
10925
|
+
}
|
|
10926
|
+
|
|
10927
|
+
instance.defaults.headers.common['Content-Type'] = 'application/json;charset=UTF-8'; // Add a request interceptor
|
|
10928
|
+
|
|
10929
|
+
instance.interceptors.request.use(function (request, error) {
|
|
10930
|
+
if (error) {
|
|
10931
|
+
return Promise.reject(error.response);
|
|
10932
|
+
}
|
|
10933
|
+
|
|
10934
|
+
if (request.url.includes('search') && request.url.includes('?')) {
|
|
10935
|
+
// do some uri manipulation for ie
|
|
10936
|
+
// https://stackoverflow.com/questions/18220057
|
|
10937
|
+
// eslint-disable-next-line no-param-reassign
|
|
10938
|
+
request.url = getEncodedSearch(request.url);
|
|
10939
|
+
} // eslint-disable-next-line no-param-reassign
|
|
10940
|
+
|
|
10941
|
+
|
|
10942
|
+
request.headers.common['Content-Type'] = 'application/json; charset=utf-8';
|
|
10943
|
+
|
|
10944
|
+
if (typeof request.body === 'undefined') {
|
|
10945
|
+
request.body = {};
|
|
10946
|
+
}
|
|
10947
|
+
|
|
10948
|
+
token = getToken();
|
|
10949
|
+
|
|
10950
|
+
if (token !== '') {
|
|
10951
|
+
// eslint-disable-next-line no-param-reassign
|
|
10952
|
+
request.headers.common.Authorization = token;
|
|
10953
|
+
}
|
|
10954
|
+
|
|
10955
|
+
return request;
|
|
10956
|
+
}, function (error) {
|
|
10957
|
+
return Promise.reject(error.message);
|
|
10958
|
+
}); // Add a response interceptor
|
|
10959
|
+
|
|
10960
|
+
instance.interceptors.response.use(function (response, error) {
|
|
10961
|
+
if (error) {
|
|
10962
|
+
return Promise.reject(error.response);
|
|
10963
|
+
}
|
|
10964
|
+
|
|
10965
|
+
if (response.headers.authorization) {
|
|
10966
|
+
setToken(response.headers.authorization);
|
|
10967
|
+
}
|
|
10968
|
+
|
|
10969
|
+
return response;
|
|
10970
|
+
}, function (error) {
|
|
10971
|
+
if (error.response) {
|
|
10972
|
+
// network error
|
|
10973
|
+
if (error.response.data && error.response.data.error && (error.response.data.error === 'token_invalid' || error.response.data.error === 'token_not_provided' || error.response.data.error === 'user_not_found' || error.response.data.error === 'token_expired') || error.response.status === 401 || error.response.status === 503 || error.response.status === 400) {
|
|
10974
|
+
onAuthFailed();
|
|
10975
|
+
} // if (error.response.status === 500) {
|
|
10976
|
+
// // INTERNAL SERVER ERROR
|
|
10977
|
+
// store.dispatch({
|
|
10978
|
+
// type: AppConstants.OVERLAY.SERVER_ERROR,
|
|
10979
|
+
// });
|
|
10980
|
+
// return Promise.reject(error.response);
|
|
10981
|
+
// }
|
|
10982
|
+
|
|
10983
|
+
|
|
10984
|
+
if (error.response.status === 403) {
|
|
10985
|
+
// FORBIDDEN
|
|
10986
|
+
onForbidden();
|
|
10987
|
+
}
|
|
10988
|
+
|
|
10989
|
+
return Promise.reject(error.response);
|
|
10990
|
+
}
|
|
10991
|
+
|
|
10992
|
+
return Promise.reject(error);
|
|
10993
|
+
});
|
|
10994
|
+
return instance;
|
|
10995
|
+
}; // NOTE: this to be instanciated with params: onAuthFailed, onForbidden
|
|
10996
|
+
|
|
10875
10997
|
var _excluded$8 = ["children"];
|
|
10876
10998
|
|
|
10877
10999
|
var DropdownSelector = function DropdownSelector(_ref) {
|