@bonlineza/luxity-lib 2.35.3 → 2.36.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AddProductInterest.js +127 -5
- package/GraphQLDropdownSelector.js +126 -5
- package/Interests.js +127 -5
- package/LuxityDesktopHeader.js +60 -138
- package/LuxityFooter.js +4 -4
- package/LuxityGraphQLDropdownSelector.js +126 -5
- package/LuxityMobileHeader.js +99 -225
- package/LuxitySideNav.js +91 -219
- package/MaterialSelector.js +126 -5
- package/ModelSelector.js +126 -5
- package/build/bundle.css +1 -1
- package/build/bundle.js +288 -348
- package/package.json +1 -1
- package/TestComponent.js +0 -15
- package/build/CountryCodeSelect/index.js +0 -18
- package/build/ReactSelectWrapper/index.js +0 -34
- package/postcss.config.js +0 -6
package/LuxityDesktopHeader.js
CHANGED
|
@@ -434,37 +434,6 @@
|
|
|
434
434
|
}, contactNumber)));
|
|
435
435
|
};
|
|
436
436
|
|
|
437
|
-
var categories = {
|
|
438
|
-
shoes: {
|
|
439
|
-
name: 'Shoes',
|
|
440
|
-
slug: 'shoes'
|
|
441
|
-
},
|
|
442
|
-
bags: {
|
|
443
|
-
name: 'Bags',
|
|
444
|
-
slug: 'bags'
|
|
445
|
-
},
|
|
446
|
-
clothing: {
|
|
447
|
-
name: 'Clothing',
|
|
448
|
-
slug: 'apparel'
|
|
449
|
-
},
|
|
450
|
-
watches: {
|
|
451
|
-
name: 'Watches',
|
|
452
|
-
slug: 'watches'
|
|
453
|
-
},
|
|
454
|
-
accessories: {
|
|
455
|
-
name: 'Accessories',
|
|
456
|
-
slug: 'accessories'
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
var removeCategoryByName = function removeCategoryByName(categories, name) {
|
|
461
|
-
var _categories$filter;
|
|
462
|
-
|
|
463
|
-
return (_categories$filter = categories === null || categories === void 0 ? void 0 : categories.filter(function (category) {
|
|
464
|
-
return category.name !== name;
|
|
465
|
-
})) !== null && _categories$filter !== void 0 ? _categories$filter : [];
|
|
466
|
-
};
|
|
467
|
-
|
|
468
437
|
var SearchResults = function SearchResults(_ref) {
|
|
469
438
|
var searchValue = _ref.searchValue,
|
|
470
439
|
searchResults = _ref.searchResults,
|
|
@@ -721,6 +690,14 @@
|
|
|
721
690
|
}))));
|
|
722
691
|
};
|
|
723
692
|
|
|
693
|
+
var removeCategoryByName = function removeCategoryByName(categories, name) {
|
|
694
|
+
var _categories$filter;
|
|
695
|
+
|
|
696
|
+
return (_categories$filter = categories === null || categories === void 0 ? void 0 : categories.filter(function (category) {
|
|
697
|
+
return category.name.toLowerCase() !== name.toLowerCase();
|
|
698
|
+
})) !== null && _categories$filter !== void 0 ? _categories$filter : [];
|
|
699
|
+
};
|
|
700
|
+
|
|
724
701
|
var LuxityDesktopHeader = function LuxityDesktopHeader(_ref) {
|
|
725
702
|
var accountIcon = _ref.accountIcon,
|
|
726
703
|
cartIcon = _ref.cartIcon,
|
|
@@ -728,12 +705,6 @@
|
|
|
728
705
|
cartCount = _ref.cartCount,
|
|
729
706
|
logoSrc = _ref.logoSrc,
|
|
730
707
|
categoryElements = _ref.categoryElements,
|
|
731
|
-
newBrandsImage = _ref.newBrandsImage,
|
|
732
|
-
bagsImage = _ref.bagsImage,
|
|
733
|
-
shoesImage = _ref.shoesImage,
|
|
734
|
-
clothingImage = _ref.clothingImage,
|
|
735
|
-
accessoriesImage = _ref.accessoriesImage,
|
|
736
|
-
watchesImage = _ref.watchesImage,
|
|
737
708
|
stores = _ref.stores,
|
|
738
709
|
contactNumber = _ref.contactNumber,
|
|
739
710
|
productsUrl = _ref.productsUrl,
|
|
@@ -748,7 +719,6 @@
|
|
|
748
719
|
ourStoryLink = _ref.ourStoryLink,
|
|
749
720
|
onLogoClick = _ref.onLogoClick,
|
|
750
721
|
endpoint = _ref.endpoint,
|
|
751
|
-
menuData = _ref.menuData,
|
|
752
722
|
onSearchSubmit = _ref.onSearchSubmit,
|
|
753
723
|
onProductIdsReceived = _ref.onProductIdsReceived,
|
|
754
724
|
currency = _ref.currency,
|
|
@@ -760,7 +730,8 @@
|
|
|
760
730
|
name = _ref.name,
|
|
761
731
|
isVip = _ref.isVip,
|
|
762
732
|
shop = _ref.shop,
|
|
763
|
-
app = _ref.app
|
|
733
|
+
app = _ref.app,
|
|
734
|
+
categoryConfig = _ref.categoryConfig;
|
|
764
735
|
|
|
765
736
|
var _useState = React.useState(''),
|
|
766
737
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -772,16 +743,7 @@
|
|
|
772
743
|
loading = _useState4[0],
|
|
773
744
|
setLoading = _useState4[1];
|
|
774
745
|
|
|
775
|
-
var _useState5 = React.useState({
|
|
776
|
-
latestArrivals: [],
|
|
777
|
-
bags: [],
|
|
778
|
-
shoes: [],
|
|
779
|
-
clothing: [],
|
|
780
|
-
accessories: [],
|
|
781
|
-
watches: [],
|
|
782
|
-
accessoriesCategories: [],
|
|
783
|
-
apparelStyles: []
|
|
784
|
-
}),
|
|
746
|
+
var _useState5 = React.useState({}),
|
|
785
747
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
786
748
|
dropdownData = _useState6[0],
|
|
787
749
|
setDropdownData = _useState6[1];
|
|
@@ -882,35 +844,60 @@
|
|
|
882
844
|
}
|
|
883
845
|
};
|
|
884
846
|
|
|
885
|
-
function
|
|
847
|
+
React.useMemo(function () {
|
|
848
|
+
setLoading(true);
|
|
849
|
+
axios.get("".concat(categoryConfig.menuData)).then(function (_ref2) {
|
|
850
|
+
var data = _ref2.data;
|
|
851
|
+
setLoading(false);
|
|
852
|
+
setDropdownData(data);
|
|
853
|
+
}).catch(function () {
|
|
854
|
+
return setHasError(true);
|
|
855
|
+
});
|
|
856
|
+
}, [categoryConfig.menuData]);
|
|
857
|
+
|
|
858
|
+
var addCategoryToElements = function addCategoryToElements(elements, categoryName) {
|
|
886
859
|
return elements.map(function (element) {
|
|
887
860
|
return _objectSpread2(_objectSpread2({}, element), {}, {
|
|
888
861
|
category: categoryName
|
|
889
862
|
});
|
|
890
863
|
});
|
|
891
|
-
}
|
|
864
|
+
};
|
|
892
865
|
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
866
|
+
var renderDropdownLinks = function renderDropdownLinks() {
|
|
867
|
+
return categoryConfig.categories.map(function (category) {
|
|
868
|
+
var title = category.title,
|
|
869
|
+
imageSrc = category.imageSrc,
|
|
870
|
+
categorySlug = category.categorySlug,
|
|
871
|
+
categoryName = category.categoryName,
|
|
872
|
+
elementsKey = category.elementsKey,
|
|
873
|
+
subCategoryElementsKey = category.subCategoryElementsKey,
|
|
874
|
+
styleElementsKey = category.styleElementsKey;
|
|
875
|
+
var categoryElementsProcessed = categoryElements;
|
|
876
|
+
|
|
877
|
+
if (subCategoryElementsKey && dropdownData[subCategoryElementsKey]) {
|
|
878
|
+
// show subcategory elements
|
|
879
|
+
categoryElementsProcessed = removeCategoryByName(dropdownData[subCategoryElementsKey], categoryName);
|
|
880
|
+
} else if (styleElementsKey && dropdownData[styleElementsKey]) {
|
|
881
|
+
categoryElementsProcessed = addCategoryToElements(dropdownData[styleElementsKey], categorySlug);
|
|
882
|
+
} else {
|
|
883
|
+
categoryElementsProcessed = addCategoryToElements(categoryElementsProcessed, categorySlug);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
return /*#__PURE__*/React__default.createElement(DropdownLink, {
|
|
887
|
+
key: categorySlug,
|
|
888
|
+
title: title,
|
|
889
|
+
imageSrc: imageSrc,
|
|
890
|
+
categoryElements: categoryElementsProcessed,
|
|
891
|
+
brandElements: dropdownData[elementsKey] || [],
|
|
892
|
+
productsUrl: productsUrl,
|
|
893
|
+
categorySlug: categorySlug,
|
|
894
|
+
categoryTitle: categoryName,
|
|
895
|
+
isLoading: loading,
|
|
896
|
+
hasError: hasError,
|
|
897
|
+
LinkComponent: LinkComponent
|
|
909
898
|
});
|
|
910
|
-
}).catch(function () {
|
|
911
|
-
return setHasError(true);
|
|
912
899
|
});
|
|
913
|
-
}
|
|
900
|
+
};
|
|
914
901
|
|
|
915
902
|
var getMarginRight = function getMarginRight(userIsVip, userName) {
|
|
916
903
|
if (userIsVip) return '15px';
|
|
@@ -967,74 +954,9 @@
|
|
|
967
954
|
setSearchValue: setSearchValue
|
|
968
955
|
}), /*#__PURE__*/React__default.createElement("nav", {
|
|
969
956
|
className: "navbar__nav-links navbar__nav-links--wrap"
|
|
970
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
categoryElements: categoryElements,
|
|
974
|
-
brandElements: dropdownData.latestArrivals,
|
|
975
|
-
productsUrl: productsUrl,
|
|
976
|
-
categorySlug: "brands",
|
|
977
|
-
categoryTitle: "Brands",
|
|
978
|
-
isLoading: loading,
|
|
979
|
-
hasError: hasError,
|
|
980
|
-
LinkComponent: LinkComponent
|
|
981
|
-
}), /*#__PURE__*/React__default.createElement(DropdownLink, {
|
|
982
|
-
title: "Bags",
|
|
983
|
-
imageSrc: bagsImage,
|
|
984
|
-
categoryElements: addCategoryToElements(categoryElements, categories.bags.slug),
|
|
985
|
-
brandElements: dropdownData.bags,
|
|
986
|
-
productsUrl: productsUrl,
|
|
987
|
-
categorySlug: categories.bags.slug,
|
|
988
|
-
categoryTitle: categories.bags.name,
|
|
989
|
-
isLoading: loading,
|
|
990
|
-
hasError: hasError,
|
|
991
|
-
LinkComponent: LinkComponent
|
|
992
|
-
}), /*#__PURE__*/React__default.createElement(DropdownLink, {
|
|
993
|
-
title: "Shoes",
|
|
994
|
-
imageSrc: shoesImage,
|
|
995
|
-
categoryElements: addCategoryToElements(categoryElements, categories.shoes.slug),
|
|
996
|
-
brandElements: dropdownData.shoes,
|
|
997
|
-
productsUrl: productsUrl,
|
|
998
|
-
categorySlug: categories.shoes.slug,
|
|
999
|
-
categoryTitle: categories.shoes.name,
|
|
1000
|
-
isLoading: loading,
|
|
1001
|
-
hasError: hasError,
|
|
1002
|
-
LinkComponent: LinkComponent
|
|
1003
|
-
}), /*#__PURE__*/React__default.createElement(DropdownLink, {
|
|
1004
|
-
title: "Clothing",
|
|
1005
|
-
imageSrc: clothingImage,
|
|
1006
|
-
categoryElements: addCategoryToElements(dropdownData.apparelStyles, categories.clothing.slug),
|
|
1007
|
-
brandElements: dropdownData.apparel,
|
|
1008
|
-
productsUrl: productsUrl,
|
|
1009
|
-
categorySlug: categories.clothing.slug,
|
|
1010
|
-
categoryTitle: categories.clothing.name,
|
|
1011
|
-
isLoading: loading,
|
|
1012
|
-
hasError: hasError,
|
|
1013
|
-
LinkComponent: LinkComponent
|
|
1014
|
-
}), /*#__PURE__*/React__default.createElement(DropdownLink, {
|
|
1015
|
-
title: "Accessories",
|
|
1016
|
-
imageSrc: accessoriesImage,
|
|
1017
|
-
categoryElements: removeCategoryByName(dropdownData.accessoriesCategories, 'ACCESSORIES'),
|
|
1018
|
-
brandElements: dropdownData.accessories,
|
|
1019
|
-
productsUrl: productsUrl,
|
|
1020
|
-
categorySlug: categories.accessories.slug,
|
|
1021
|
-
categoryTitle: categories.accessories.name,
|
|
1022
|
-
isLoading: loading,
|
|
1023
|
-
hasError: hasError,
|
|
1024
|
-
LinkComponent: LinkComponent
|
|
1025
|
-
}), /*#__PURE__*/React__default.createElement(DropdownLink, {
|
|
1026
|
-
title: "Watches",
|
|
1027
|
-
imageSrc: watchesImage,
|
|
1028
|
-
categoryElements: addCategoryToElements(categoryElements, categories.watches.slug),
|
|
1029
|
-
brandElements: dropdownData.watches,
|
|
1030
|
-
productsUrl: productsUrl,
|
|
1031
|
-
categorySlug: categories.watches.slug,
|
|
1032
|
-
categoryTitle: categories.watches.name,
|
|
1033
|
-
isLoading: loading,
|
|
1034
|
-
hasError: hasError,
|
|
1035
|
-
LinkComponent: LinkComponent
|
|
1036
|
-
}), /*#__PURE__*/React__default.createElement("li", {
|
|
1037
|
-
className: "navbar__link"
|
|
957
|
+
}, renderDropdownLinks(), !!stores.length && /*#__PURE__*/React__default.createElement("li", {
|
|
958
|
+
className: "navbar__link",
|
|
959
|
+
key: "Stores"
|
|
1038
960
|
}, /*#__PURE__*/React__default.createElement(LinkComponent, {
|
|
1039
961
|
href: contactUsLink,
|
|
1040
962
|
className: "navbar__link-item navbar__link-item--desktop"
|
package/LuxityFooter.js
CHANGED
|
@@ -2102,13 +2102,13 @@
|
|
|
2102
2102
|
setError = _useForm.setError;
|
|
2103
2103
|
|
|
2104
2104
|
var renderLinks = function renderLinks(links, title) {
|
|
2105
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
2105
|
+
return !!links.length && /*#__PURE__*/React__default.createElement("div", {
|
|
2106
2106
|
className: "footer__link-container"
|
|
2107
2107
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2108
2108
|
className: "footer__link-title"
|
|
2109
2109
|
}, title), /*#__PURE__*/React__default.createElement("div", {
|
|
2110
2110
|
className: "footer__links"
|
|
2111
|
-
},
|
|
2111
|
+
}, links.map(function (link) {
|
|
2112
2112
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
2113
2113
|
className: "footer__link-wrapper",
|
|
2114
2114
|
key: link.label
|
|
@@ -2291,13 +2291,13 @@
|
|
|
2291
2291
|
}), /*#__PURE__*/React__default.createElement(AccordionSection, {
|
|
2292
2292
|
title: "POPULAR",
|
|
2293
2293
|
links: popularLinks
|
|
2294
|
-
}), /*#__PURE__*/React__default.createElement(AccordionSection, {
|
|
2294
|
+
}), !!sellLinks.length && /*#__PURE__*/React__default.createElement(AccordionSection, {
|
|
2295
2295
|
title: "SELL",
|
|
2296
2296
|
links: sellLinks
|
|
2297
2297
|
}), /*#__PURE__*/React__default.createElement(AccordionSection, {
|
|
2298
2298
|
title: "COMPANY",
|
|
2299
2299
|
links: companyLinks
|
|
2300
|
-
}), /*#__PURE__*/React__default.createElement(AccordionSection, {
|
|
2300
|
+
}), !!storeLinks.length && /*#__PURE__*/React__default.createElement(AccordionSection, {
|
|
2301
2301
|
title: "CONNECT",
|
|
2302
2302
|
links: storeLinks
|
|
2303
2303
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -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.LuxityGraphQLDropdownSelector = 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.LuxityGraphQLDropdownSelector = 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) {
|