@bonlineza/luxity-lib 2.37.0 → 2.37.2
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 +10 -133
- package/GraphQLDropdownSelector.js +10 -132
- package/Interests.js +10 -133
- package/LuxityDesktopHeader.js +62 -12
- package/LuxityGraphQLDropdownSelector.js +10 -132
- package/LuxityMobileHeader.js +63 -8
- package/MaterialSelector.js +10 -132
- package/ModelSelector.js +10 -132
- package/TestComponent.js +15 -0
- package/build/CountryCodeSelect/index.js +18 -0
- package/build/ReactSelectWrapper/index.js +34 -0
- package/build/bundle.css +1 -1
- package/build/bundle.js +85 -146
- package/package.json +1 -1
- package/postcss.config.js +6 -0
- package/build/.gitignore +0 -3
- package/build/.npmignore +0 -0
package/AddProductInterest.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
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('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', '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['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, 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
|
-
axios = axios && Object.prototype.hasOwnProperty.call(axios, 'default') ? axios['default'] : axios;
|
|
10
|
-
Cookies = Cookies && Object.prototype.hasOwnProperty.call(Cookies, 'default') ? Cookies['default'] : Cookies;
|
|
11
9
|
var Notifications__default = 'default' in Notifications ? Notifications['default'] : Notifications;
|
|
12
10
|
stylisRuleSheet = stylisRuleSheet && Object.prototype.hasOwnProperty.call(stylisRuleSheet, 'default') ? stylisRuleSheet['default'] : stylisRuleSheet;
|
|
13
11
|
PropTypes = PropTypes && Object.prototype.hasOwnProperty.call(PropTypes, 'default') ? PropTypes['default'] : PropTypes;
|
|
@@ -560,127 +558,6 @@
|
|
|
560
558
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
561
559
|
}
|
|
562
560
|
|
|
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
|
-
|
|
684
561
|
var defaultNotifyTime = 5000;
|
|
685
562
|
var error = function error(message) {
|
|
686
563
|
Notifications.notify.show(message, 'error', defaultNotifyTime);
|
|
@@ -7626,7 +7503,7 @@
|
|
|
7626
7503
|
case 0:
|
|
7627
7504
|
_context.prev = 0;
|
|
7628
7505
|
_context.next = 3;
|
|
7629
|
-
return
|
|
7506
|
+
return requestInstance.post("".concat(baseGraphApi, "?id=getBrands"), {
|
|
7630
7507
|
query: getBrandsGraphQuery(1000, 1, 'id|desc')
|
|
7631
7508
|
});
|
|
7632
7509
|
|
|
@@ -7657,7 +7534,7 @@
|
|
|
7657
7534
|
}
|
|
7658
7535
|
}
|
|
7659
7536
|
}, _callee, null, [[0, 7]]);
|
|
7660
|
-
})), [baseGraphApi, getBrandsGraphQuery]);
|
|
7537
|
+
})), [baseGraphApi, getBrandsGraphQuery, requestInstance]);
|
|
7661
7538
|
var fetchModels = React.useCallback( /*#__PURE__*/function () {
|
|
7662
7539
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(brandId) {
|
|
7663
7540
|
var _response$data2, _response$data2$data, _response$data2$data$, response, formattedModels;
|
|
@@ -7668,7 +7545,7 @@
|
|
|
7668
7545
|
case 0:
|
|
7669
7546
|
_context2.prev = 0;
|
|
7670
7547
|
_context2.next = 3;
|
|
7671
|
-
return
|
|
7548
|
+
return requestInstance.post("".concat(baseGraphApi, "?id=getModels"), {
|
|
7672
7549
|
query: getModelsGraphQuery(brandId)
|
|
7673
7550
|
});
|
|
7674
7551
|
|
|
@@ -7704,7 +7581,7 @@
|
|
|
7704
7581
|
return function (_x) {
|
|
7705
7582
|
return _ref3.apply(this, arguments);
|
|
7706
7583
|
};
|
|
7707
|
-
}(), [baseGraphApi, getModelsGraphQuery]);
|
|
7584
|
+
}(), [baseGraphApi, getModelsGraphQuery, requestInstance]);
|
|
7708
7585
|
var fetchMaterials = React.useCallback( /*#__PURE__*/function () {
|
|
7709
7586
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(brandId) {
|
|
7710
7587
|
var _response$data3, _response$data3$data, _response$data3$data$, response, formattedMaterials;
|
|
@@ -7715,7 +7592,7 @@
|
|
|
7715
7592
|
case 0:
|
|
7716
7593
|
_context3.prev = 0;
|
|
7717
7594
|
_context3.next = 3;
|
|
7718
|
-
return
|
|
7595
|
+
return requestInstance.post("".concat(baseGraphApi, "?id=getMaterials"), {
|
|
7719
7596
|
query: getMaterialsGraphQuery(brandId)
|
|
7720
7597
|
});
|
|
7721
7598
|
|
|
@@ -7751,7 +7628,7 @@
|
|
|
7751
7628
|
return function (_x2) {
|
|
7752
7629
|
return _ref4.apply(this, arguments);
|
|
7753
7630
|
};
|
|
7754
|
-
}(), [baseGraphApi, getMaterialsGraphQuery]);
|
|
7631
|
+
}(), [baseGraphApi, getMaterialsGraphQuery, requestInstance]);
|
|
7755
7632
|
React.useEffect(function () {
|
|
7756
7633
|
fetchBrands();
|
|
7757
7634
|
}, [fetchBrands]);
|
|
@@ -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('axios')
|
|
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'
|
|
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
|
|
5
|
-
}(this, (function (React, styled, EllipsisLoader, PageReady, AnimateHeight, numeral, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup, functions, rcSlider, Notifications, axios
|
|
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')) :
|
|
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'], 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));
|
|
5
|
+
}(this, (function (React, styled, EllipsisLoader, PageReady, AnimateHeight, numeral, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup, functions, rcSlider, Notifications, axios) { '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;
|
|
@@ -16,7 +16,6 @@
|
|
|
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
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
19
|
|
|
21
20
|
function ownKeys(object, enumerableOnly) {
|
|
22
21
|
var keys = Object.keys(object);
|
|
@@ -11010,127 +11009,6 @@
|
|
|
11010
11009
|
}));
|
|
11011
11010
|
});
|
|
11012
11011
|
|
|
11013
|
-
function getToken() {
|
|
11014
|
-
var _Cookies$get;
|
|
11015
|
-
|
|
11016
|
-
return (_Cookies$get = Cookies.get('_tk')) === null || _Cookies$get === void 0 ? void 0 : _Cookies$get.replace('*', 'Bearer ');
|
|
11017
|
-
}
|
|
11018
|
-
function setToken(value) {
|
|
11019
|
-
Cookies.set('_tk', value, 30);
|
|
11020
|
-
}
|
|
11021
|
-
|
|
11022
|
-
/** @format */
|
|
11023
|
-
|
|
11024
|
-
function getEncodedSearch(currentUrl) {
|
|
11025
|
-
var splitUrl = currentUrl.split('?');
|
|
11026
|
-
var baseUrl = splitUrl[0];
|
|
11027
|
-
var nextUrlSegments = splitUrl[1].split('&');
|
|
11028
|
-
var nextQueryString = splitUrl[1];
|
|
11029
|
-
|
|
11030
|
-
if (nextUrlSegments.length > 0) {
|
|
11031
|
-
nextQueryString = nextUrlSegments.map(function (v) {
|
|
11032
|
-
var nextValue = v;
|
|
11033
|
-
|
|
11034
|
-
if (v.includes('search=')) {
|
|
11035
|
-
var temp = v.split('=');
|
|
11036
|
-
nextValue = "".concat(temp[0], "=").concat(encodeURIComponent(temp[1]));
|
|
11037
|
-
}
|
|
11038
|
-
|
|
11039
|
-
return nextValue;
|
|
11040
|
-
}).join('&');
|
|
11041
|
-
}
|
|
11042
|
-
|
|
11043
|
-
return "".concat(baseUrl, "?").concat(nextQueryString);
|
|
11044
|
-
}
|
|
11045
|
-
/**
|
|
11046
|
-
* Gets an instance of Axios that is configured with the custom failure handlers
|
|
11047
|
-
* @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]
|
|
11048
|
-
* @param {Function} onForbidden - callback triggers when http status = 403
|
|
11049
|
-
*/
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
var axiosInstance = function axiosInstance(onAuthFailed, onForbidden) {
|
|
11053
|
-
var instance = axios.create({
|
|
11054
|
-
validateStatus: function validateStatus(status) {
|
|
11055
|
-
return status >= 200 && status < 300;
|
|
11056
|
-
}
|
|
11057
|
-
});
|
|
11058
|
-
var token = getToken();
|
|
11059
|
-
|
|
11060
|
-
if (token !== '') {
|
|
11061
|
-
instance.defaults.headers.common.Authorization = token;
|
|
11062
|
-
}
|
|
11063
|
-
|
|
11064
|
-
instance.defaults.headers.common['Content-Type'] = 'application/json;charset=UTF-8'; // Add a request interceptor
|
|
11065
|
-
|
|
11066
|
-
instance.interceptors.request.use(function (request, error) {
|
|
11067
|
-
if (error) {
|
|
11068
|
-
return Promise.reject(error.response);
|
|
11069
|
-
}
|
|
11070
|
-
|
|
11071
|
-
if (request.url.includes('search') && request.url.includes('?')) {
|
|
11072
|
-
// do some uri manipulation for ie
|
|
11073
|
-
// https://stackoverflow.com/questions/18220057
|
|
11074
|
-
// eslint-disable-next-line no-param-reassign
|
|
11075
|
-
request.url = getEncodedSearch(request.url);
|
|
11076
|
-
} // eslint-disable-next-line no-param-reassign
|
|
11077
|
-
|
|
11078
|
-
|
|
11079
|
-
request.headers.common['Content-Type'] = 'application/json; charset=utf-8';
|
|
11080
|
-
|
|
11081
|
-
if (typeof request.body === 'undefined') {
|
|
11082
|
-
request.body = {};
|
|
11083
|
-
}
|
|
11084
|
-
|
|
11085
|
-
token = getToken();
|
|
11086
|
-
|
|
11087
|
-
if (token !== '') {
|
|
11088
|
-
// eslint-disable-next-line no-param-reassign
|
|
11089
|
-
request.headers.common.Authorization = token;
|
|
11090
|
-
}
|
|
11091
|
-
|
|
11092
|
-
return request;
|
|
11093
|
-
}, function (error) {
|
|
11094
|
-
return Promise.reject(error.message);
|
|
11095
|
-
}); // Add a response interceptor
|
|
11096
|
-
|
|
11097
|
-
instance.interceptors.response.use(function (response, error) {
|
|
11098
|
-
if (error) {
|
|
11099
|
-
return Promise.reject(error.response);
|
|
11100
|
-
}
|
|
11101
|
-
|
|
11102
|
-
if (response.headers.authorization) {
|
|
11103
|
-
setToken(response.headers.authorization);
|
|
11104
|
-
}
|
|
11105
|
-
|
|
11106
|
-
return response;
|
|
11107
|
-
}, function (error) {
|
|
11108
|
-
if (error.response) {
|
|
11109
|
-
// network error
|
|
11110
|
-
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) {
|
|
11111
|
-
onAuthFailed();
|
|
11112
|
-
} // if (error.response.status === 500) {
|
|
11113
|
-
// // INTERNAL SERVER ERROR
|
|
11114
|
-
// store.dispatch({
|
|
11115
|
-
// type: AppConstants.OVERLAY.SERVER_ERROR,
|
|
11116
|
-
// });
|
|
11117
|
-
// return Promise.reject(error.response);
|
|
11118
|
-
// }
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
if (error.response.status === 403) {
|
|
11122
|
-
// FORBIDDEN
|
|
11123
|
-
onForbidden();
|
|
11124
|
-
}
|
|
11125
|
-
|
|
11126
|
-
return Promise.reject(error.response);
|
|
11127
|
-
}
|
|
11128
|
-
|
|
11129
|
-
return Promise.reject(error);
|
|
11130
|
-
});
|
|
11131
|
-
return instance;
|
|
11132
|
-
}; // NOTE: this to be instanciated with params: onAuthFailed, onForbidden
|
|
11133
|
-
|
|
11134
11012
|
var _excluded$8 = ["children"];
|
|
11135
11013
|
|
|
11136
11014
|
var DropdownSelector = function DropdownSelector(_ref) {
|
|
@@ -11352,7 +11230,7 @@
|
|
|
11352
11230
|
case 0:
|
|
11353
11231
|
_context.prev = 0;
|
|
11354
11232
|
_context.next = 3;
|
|
11355
|
-
return
|
|
11233
|
+
return requestInstance.post("".concat(baseGraphApi, "?id=getBrands"), {
|
|
11356
11234
|
query: getBrandsGraphQuery(1000, 1, 'id|desc')
|
|
11357
11235
|
});
|
|
11358
11236
|
|
|
@@ -11383,7 +11261,7 @@
|
|
|
11383
11261
|
}
|
|
11384
11262
|
}
|
|
11385
11263
|
}, _callee, null, [[0, 7]]);
|
|
11386
|
-
})), [baseGraphApi, getBrandsGraphQuery]);
|
|
11264
|
+
})), [baseGraphApi, getBrandsGraphQuery, requestInstance]);
|
|
11387
11265
|
var fetchModels = React.useCallback( /*#__PURE__*/function () {
|
|
11388
11266
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(brandId) {
|
|
11389
11267
|
var _response$data2, _response$data2$data, _response$data2$data$, response, formattedModels;
|
|
@@ -11394,7 +11272,7 @@
|
|
|
11394
11272
|
case 0:
|
|
11395
11273
|
_context2.prev = 0;
|
|
11396
11274
|
_context2.next = 3;
|
|
11397
|
-
return
|
|
11275
|
+
return requestInstance.post("".concat(baseGraphApi, "?id=getModels"), {
|
|
11398
11276
|
query: getModelsGraphQuery(brandId)
|
|
11399
11277
|
});
|
|
11400
11278
|
|
|
@@ -11430,7 +11308,7 @@
|
|
|
11430
11308
|
return function (_x) {
|
|
11431
11309
|
return _ref3.apply(this, arguments);
|
|
11432
11310
|
};
|
|
11433
|
-
}(), [baseGraphApi, getModelsGraphQuery]);
|
|
11311
|
+
}(), [baseGraphApi, getModelsGraphQuery, requestInstance]);
|
|
11434
11312
|
var fetchMaterials = React.useCallback( /*#__PURE__*/function () {
|
|
11435
11313
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(brandId) {
|
|
11436
11314
|
var _response$data3, _response$data3$data, _response$data3$data$, response, formattedMaterials;
|
|
@@ -11441,7 +11319,7 @@
|
|
|
11441
11319
|
case 0:
|
|
11442
11320
|
_context3.prev = 0;
|
|
11443
11321
|
_context3.next = 3;
|
|
11444
|
-
return
|
|
11322
|
+
return requestInstance.post("".concat(baseGraphApi, "?id=getMaterials"), {
|
|
11445
11323
|
query: getMaterialsGraphQuery(brandId)
|
|
11446
11324
|
});
|
|
11447
11325
|
|
|
@@ -11477,7 +11355,7 @@
|
|
|
11477
11355
|
return function (_x2) {
|
|
11478
11356
|
return _ref4.apply(this, arguments);
|
|
11479
11357
|
};
|
|
11480
|
-
}(), [baseGraphApi, getMaterialsGraphQuery]);
|
|
11358
|
+
}(), [baseGraphApi, getMaterialsGraphQuery, requestInstance]);
|
|
11481
11359
|
React.useEffect(function () {
|
|
11482
11360
|
fetchBrands();
|
|
11483
11361
|
}, [fetchBrands]);
|
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')
|
|
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
|
|
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')) :
|
|
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'], 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));
|
|
5
|
+
}(this, (function (React, styled, Notifications, EllipsisLoader, PageReady, stylisRuleSheet, reactDom, PropTypes, raf, AutosizeInput, reactTransitionGroup, functions, rcSlider, numeral) { '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,8 +14,6 @@
|
|
|
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
|
-
axios = axios && Object.prototype.hasOwnProperty.call(axios, 'default') ? axios['default'] : axios;
|
|
18
|
-
Cookies = Cookies && Object.prototype.hasOwnProperty.call(Cookies, 'default') ? Cookies['default'] : Cookies;
|
|
19
17
|
|
|
20
18
|
function ownKeys(object, enumerableOnly) {
|
|
21
19
|
var keys = Object.keys(object);
|
|
@@ -10874,127 +10872,6 @@
|
|
|
10874
10872
|
}));
|
|
10875
10873
|
});
|
|
10876
10874
|
|
|
10877
|
-
function getToken() {
|
|
10878
|
-
var _Cookies$get;
|
|
10879
|
-
|
|
10880
|
-
return (_Cookies$get = Cookies.get('_tk')) === null || _Cookies$get === void 0 ? void 0 : _Cookies$get.replace('*', 'Bearer ');
|
|
10881
|
-
}
|
|
10882
|
-
function setToken(value) {
|
|
10883
|
-
Cookies.set('_tk', value, 30);
|
|
10884
|
-
}
|
|
10885
|
-
|
|
10886
|
-
/** @format */
|
|
10887
|
-
|
|
10888
|
-
function getEncodedSearch(currentUrl) {
|
|
10889
|
-
var splitUrl = currentUrl.split('?');
|
|
10890
|
-
var baseUrl = splitUrl[0];
|
|
10891
|
-
var nextUrlSegments = splitUrl[1].split('&');
|
|
10892
|
-
var nextQueryString = splitUrl[1];
|
|
10893
|
-
|
|
10894
|
-
if (nextUrlSegments.length > 0) {
|
|
10895
|
-
nextQueryString = nextUrlSegments.map(function (v) {
|
|
10896
|
-
var nextValue = v;
|
|
10897
|
-
|
|
10898
|
-
if (v.includes('search=')) {
|
|
10899
|
-
var temp = v.split('=');
|
|
10900
|
-
nextValue = "".concat(temp[0], "=").concat(encodeURIComponent(temp[1]));
|
|
10901
|
-
}
|
|
10902
|
-
|
|
10903
|
-
return nextValue;
|
|
10904
|
-
}).join('&');
|
|
10905
|
-
}
|
|
10906
|
-
|
|
10907
|
-
return "".concat(baseUrl, "?").concat(nextQueryString);
|
|
10908
|
-
}
|
|
10909
|
-
/**
|
|
10910
|
-
* Gets an instance of Axios that is configured with the custom failure handlers
|
|
10911
|
-
* @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]
|
|
10912
|
-
* @param {Function} onForbidden - callback triggers when http status = 403
|
|
10913
|
-
*/
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
var axiosInstance = function axiosInstance(onAuthFailed, onForbidden) {
|
|
10917
|
-
var instance = axios.create({
|
|
10918
|
-
validateStatus: function validateStatus(status) {
|
|
10919
|
-
return status >= 200 && status < 300;
|
|
10920
|
-
}
|
|
10921
|
-
});
|
|
10922
|
-
var token = getToken();
|
|
10923
|
-
|
|
10924
|
-
if (token !== '') {
|
|
10925
|
-
instance.defaults.headers.common.Authorization = token;
|
|
10926
|
-
}
|
|
10927
|
-
|
|
10928
|
-
instance.defaults.headers.common['Content-Type'] = 'application/json;charset=UTF-8'; // Add a request interceptor
|
|
10929
|
-
|
|
10930
|
-
instance.interceptors.request.use(function (request, error) {
|
|
10931
|
-
if (error) {
|
|
10932
|
-
return Promise.reject(error.response);
|
|
10933
|
-
}
|
|
10934
|
-
|
|
10935
|
-
if (request.url.includes('search') && request.url.includes('?')) {
|
|
10936
|
-
// do some uri manipulation for ie
|
|
10937
|
-
// https://stackoverflow.com/questions/18220057
|
|
10938
|
-
// eslint-disable-next-line no-param-reassign
|
|
10939
|
-
request.url = getEncodedSearch(request.url);
|
|
10940
|
-
} // eslint-disable-next-line no-param-reassign
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
request.headers.common['Content-Type'] = 'application/json; charset=utf-8';
|
|
10944
|
-
|
|
10945
|
-
if (typeof request.body === 'undefined') {
|
|
10946
|
-
request.body = {};
|
|
10947
|
-
}
|
|
10948
|
-
|
|
10949
|
-
token = getToken();
|
|
10950
|
-
|
|
10951
|
-
if (token !== '') {
|
|
10952
|
-
// eslint-disable-next-line no-param-reassign
|
|
10953
|
-
request.headers.common.Authorization = token;
|
|
10954
|
-
}
|
|
10955
|
-
|
|
10956
|
-
return request;
|
|
10957
|
-
}, function (error) {
|
|
10958
|
-
return Promise.reject(error.message);
|
|
10959
|
-
}); // Add a response interceptor
|
|
10960
|
-
|
|
10961
|
-
instance.interceptors.response.use(function (response, error) {
|
|
10962
|
-
if (error) {
|
|
10963
|
-
return Promise.reject(error.response);
|
|
10964
|
-
}
|
|
10965
|
-
|
|
10966
|
-
if (response.headers.authorization) {
|
|
10967
|
-
setToken(response.headers.authorization);
|
|
10968
|
-
}
|
|
10969
|
-
|
|
10970
|
-
return response;
|
|
10971
|
-
}, function (error) {
|
|
10972
|
-
if (error.response) {
|
|
10973
|
-
// network error
|
|
10974
|
-
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) {
|
|
10975
|
-
onAuthFailed();
|
|
10976
|
-
} // if (error.response.status === 500) {
|
|
10977
|
-
// // INTERNAL SERVER ERROR
|
|
10978
|
-
// store.dispatch({
|
|
10979
|
-
// type: AppConstants.OVERLAY.SERVER_ERROR,
|
|
10980
|
-
// });
|
|
10981
|
-
// return Promise.reject(error.response);
|
|
10982
|
-
// }
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
if (error.response.status === 403) {
|
|
10986
|
-
// FORBIDDEN
|
|
10987
|
-
onForbidden();
|
|
10988
|
-
}
|
|
10989
|
-
|
|
10990
|
-
return Promise.reject(error.response);
|
|
10991
|
-
}
|
|
10992
|
-
|
|
10993
|
-
return Promise.reject(error);
|
|
10994
|
-
});
|
|
10995
|
-
return instance;
|
|
10996
|
-
}; // NOTE: this to be instanciated with params: onAuthFailed, onForbidden
|
|
10997
|
-
|
|
10998
10875
|
var _excluded$8 = ["children"];
|
|
10999
10876
|
|
|
11000
10877
|
var DropdownSelector = function DropdownSelector(_ref) {
|
|
@@ -11216,7 +11093,7 @@
|
|
|
11216
11093
|
case 0:
|
|
11217
11094
|
_context.prev = 0;
|
|
11218
11095
|
_context.next = 3;
|
|
11219
|
-
return
|
|
11096
|
+
return requestInstance.post("".concat(baseGraphApi, "?id=getBrands"), {
|
|
11220
11097
|
query: getBrandsGraphQuery(1000, 1, 'id|desc')
|
|
11221
11098
|
});
|
|
11222
11099
|
|
|
@@ -11247,7 +11124,7 @@
|
|
|
11247
11124
|
}
|
|
11248
11125
|
}
|
|
11249
11126
|
}, _callee, null, [[0, 7]]);
|
|
11250
|
-
})), [baseGraphApi, getBrandsGraphQuery]);
|
|
11127
|
+
})), [baseGraphApi, getBrandsGraphQuery, requestInstance]);
|
|
11251
11128
|
var fetchModels = React.useCallback( /*#__PURE__*/function () {
|
|
11252
11129
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(brandId) {
|
|
11253
11130
|
var _response$data2, _response$data2$data, _response$data2$data$, response, formattedModels;
|
|
@@ -11258,7 +11135,7 @@
|
|
|
11258
11135
|
case 0:
|
|
11259
11136
|
_context2.prev = 0;
|
|
11260
11137
|
_context2.next = 3;
|
|
11261
|
-
return
|
|
11138
|
+
return requestInstance.post("".concat(baseGraphApi, "?id=getModels"), {
|
|
11262
11139
|
query: getModelsGraphQuery(brandId)
|
|
11263
11140
|
});
|
|
11264
11141
|
|
|
@@ -11294,7 +11171,7 @@
|
|
|
11294
11171
|
return function (_x) {
|
|
11295
11172
|
return _ref3.apply(this, arguments);
|
|
11296
11173
|
};
|
|
11297
|
-
}(), [baseGraphApi, getModelsGraphQuery]);
|
|
11174
|
+
}(), [baseGraphApi, getModelsGraphQuery, requestInstance]);
|
|
11298
11175
|
var fetchMaterials = React.useCallback( /*#__PURE__*/function () {
|
|
11299
11176
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(brandId) {
|
|
11300
11177
|
var _response$data3, _response$data3$data, _response$data3$data$, response, formattedMaterials;
|
|
@@ -11305,7 +11182,7 @@
|
|
|
11305
11182
|
case 0:
|
|
11306
11183
|
_context3.prev = 0;
|
|
11307
11184
|
_context3.next = 3;
|
|
11308
|
-
return
|
|
11185
|
+
return requestInstance.post("".concat(baseGraphApi, "?id=getMaterials"), {
|
|
11309
11186
|
query: getMaterialsGraphQuery(brandId)
|
|
11310
11187
|
});
|
|
11311
11188
|
|
|
@@ -11341,7 +11218,7 @@
|
|
|
11341
11218
|
return function (_x2) {
|
|
11342
11219
|
return _ref4.apply(this, arguments);
|
|
11343
11220
|
};
|
|
11344
|
-
}(), [baseGraphApi, getMaterialsGraphQuery]);
|
|
11221
|
+
}(), [baseGraphApi, getMaterialsGraphQuery, requestInstance]);
|
|
11345
11222
|
React.useEffect(function () {
|
|
11346
11223
|
fetchBrands();
|
|
11347
11224
|
}, [fetchBrands]);
|