@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/LuxityDesktopHeader.js
CHANGED
|
@@ -310,7 +310,9 @@
|
|
|
310
310
|
isSearchFocused = _ref.isSearchFocused,
|
|
311
311
|
setIsSearchFocused = _ref.setIsSearchFocused,
|
|
312
312
|
currency = _ref.currency,
|
|
313
|
-
currencySymbol = _ref.currencySymbol
|
|
313
|
+
currencySymbol = _ref.currencySymbol,
|
|
314
|
+
onProductSearchResultClick = _ref.onProductSearchResultClick,
|
|
315
|
+
onBrandSearchResultClick = _ref.onBrandSearchResultClick;
|
|
314
316
|
|
|
315
317
|
var _useState = React.useState(false),
|
|
316
318
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -358,7 +360,18 @@
|
|
|
358
360
|
return /*#__PURE__*/React__default.createElement("a", {
|
|
359
361
|
key: product.link,
|
|
360
362
|
href: product.link,
|
|
361
|
-
className: "product-card"
|
|
363
|
+
className: "product-card",
|
|
364
|
+
onClick: function onClick() {
|
|
365
|
+
if (typeof onProductSearchResultClick === 'function') {
|
|
366
|
+
onProductSearchResultClick({
|
|
367
|
+
product_name: product.name,
|
|
368
|
+
product_brand: product.brand,
|
|
369
|
+
product_link: product.link,
|
|
370
|
+
search_string: searchValue,
|
|
371
|
+
is_popular: shouldShowInitialData
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
362
375
|
}, product.featured_image && /*#__PURE__*/React__default.createElement("div", {
|
|
363
376
|
className: "product-card__image-container"
|
|
364
377
|
}, /*#__PURE__*/React__default.createElement("img", {
|
|
@@ -411,13 +424,33 @@
|
|
|
411
424
|
return /*#__PURE__*/React__default.createElement("a", {
|
|
412
425
|
key: brand.id,
|
|
413
426
|
href: getBrandLink(brand),
|
|
414
|
-
className: "search-results__item"
|
|
427
|
+
className: "search-results__item",
|
|
428
|
+
onClick: function onClick() {
|
|
429
|
+
if (typeof onBrandSearchResultClick === 'function') {
|
|
430
|
+
onBrandSearchResultClick({
|
|
431
|
+
brand_name: brand.name,
|
|
432
|
+
brand_link: getBrandLink(brand),
|
|
433
|
+
search_string: searchValue,
|
|
434
|
+
is_trending: true
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
415
438
|
}, brand.name);
|
|
416
439
|
}) : (_limitBrands2 = limitBrands(searchResults === null || searchResults === void 0 ? void 0 : searchResults.brands)) === null || _limitBrands2 === void 0 ? void 0 : _limitBrands2.map(function (brand) {
|
|
417
440
|
return /*#__PURE__*/React__default.createElement("a", {
|
|
418
441
|
key: brand.link,
|
|
419
442
|
href: brand.link,
|
|
420
|
-
className: "search-results__item"
|
|
443
|
+
className: "search-results__item",
|
|
444
|
+
onClick: function onClick() {
|
|
445
|
+
if (typeof onBrandSearchResultClick === 'function') {
|
|
446
|
+
onBrandSearchResultClick({
|
|
447
|
+
brand_name: brand.name,
|
|
448
|
+
brand_link: brand.link,
|
|
449
|
+
search_string: searchValue,
|
|
450
|
+
is_trending: false
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
421
454
|
}, brand.name);
|
|
422
455
|
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
423
456
|
className: "search-results__section"
|
|
@@ -665,7 +698,8 @@
|
|
|
665
698
|
var useSearch = function useSearch(_ref) {
|
|
666
699
|
var endpoint = _ref.endpoint,
|
|
667
700
|
onProductIdsReceived = _ref.onProductIdsReceived,
|
|
668
|
-
currency = _ref.currency
|
|
701
|
+
currency = _ref.currency,
|
|
702
|
+
onSearchPreview = _ref.onSearchPreview;
|
|
669
703
|
var currentSearchRequestToken = React.useRef(null);
|
|
670
704
|
var debounce = React.useCallback(function (func, wait) {
|
|
671
705
|
var timeout;
|
|
@@ -726,6 +760,16 @@
|
|
|
726
760
|
onProductIdsReceived(searchResults.luxity_product_ids);
|
|
727
761
|
}
|
|
728
762
|
|
|
763
|
+
if (typeof onSearchPreview === 'function') {
|
|
764
|
+
var _searchResults$brands, _searchResults$produc;
|
|
765
|
+
|
|
766
|
+
var hasResults = ((_searchResults$brands = searchResults.brands) === null || _searchResults$brands === void 0 ? void 0 : _searchResults$brands.length) > 0 || ((_searchResults$produc = searchResults.products) === null || _searchResults$produc === void 0 ? void 0 : _searchResults$produc.length) > 0;
|
|
767
|
+
onSearchPreview({
|
|
768
|
+
search_string: searchQuery,
|
|
769
|
+
has_results: hasResults
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
|
|
729
773
|
currentSearchRequestToken.current = null;
|
|
730
774
|
}
|
|
731
775
|
}).catch(function (error) {
|
|
@@ -738,7 +782,7 @@
|
|
|
738
782
|
currentSearchRequestToken.current = null;
|
|
739
783
|
}
|
|
740
784
|
});
|
|
741
|
-
}, [endpoint, currency, onProductIdsReceived]);
|
|
785
|
+
}, [endpoint, currency, onSearchPreview, onProductIdsReceived]);
|
|
742
786
|
var debouncedSearch = React.useMemo(function () {
|
|
743
787
|
return debounce(function (searchQuery, setSearchResults) {
|
|
744
788
|
return performSearch(searchQuery, setSearchResults);
|
|
@@ -874,7 +918,10 @@
|
|
|
874
918
|
endpoint = _ref.endpoint,
|
|
875
919
|
initialSearchData = _ref.initialSearchData,
|
|
876
920
|
onSearchSubmit = _ref.onSearchSubmit,
|
|
877
|
-
|
|
921
|
+
onSearchBarClick = _ref.onSearchBarClick,
|
|
922
|
+
onSearchPreview = _ref.onSearchPreview,
|
|
923
|
+
onProductSearchResultClick = _ref.onProductSearchResultClick,
|
|
924
|
+
onBrandSearchResultClick = _ref.onBrandSearchResultClick,
|
|
878
925
|
onProductIdsReceived = _ref.onProductIdsReceived,
|
|
879
926
|
currency = _ref.currency,
|
|
880
927
|
currencySymbol = _ref.currencySymbol,
|
|
@@ -894,7 +941,8 @@
|
|
|
894
941
|
var _useSearch = useSearch({
|
|
895
942
|
endpoint: endpoint,
|
|
896
943
|
onProductIdsReceived: onProductIdsReceived,
|
|
897
|
-
currency: currency
|
|
944
|
+
currency: currency,
|
|
945
|
+
onSearchPreview: onSearchPreview
|
|
898
946
|
}),
|
|
899
947
|
fetchInitialSearchData = _useSearch.fetchInitialSearchData,
|
|
900
948
|
createDebouncedSearch = _useSearch.createDebouncedSearch,
|
|
@@ -959,15 +1007,15 @@
|
|
|
959
1007
|
useSearchClickOutside(searchResultsRef, searchResults, setCachedResults, setIsSearchFocused, setSearchResults);
|
|
960
1008
|
|
|
961
1009
|
var handleSearchClick = function handleSearchClick() {
|
|
962
|
-
if (typeof
|
|
963
|
-
|
|
1010
|
+
if (typeof onSearchBarClick === 'function') {
|
|
1011
|
+
onSearchBarClick();
|
|
964
1012
|
return;
|
|
965
1013
|
}
|
|
966
1014
|
|
|
967
1015
|
handleSearchFocus();
|
|
968
1016
|
};
|
|
969
1017
|
|
|
970
|
-
var handleSearchFocus = useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults
|
|
1018
|
+
var handleSearchFocus = useSearchInputFocus(searchValue, setIsSearchFocused, cachedResults, setSearchResults);
|
|
971
1019
|
var handleKeyDown = useSearchInputKeyDown(searchValue, immediateSearch, setIsSearchFocused);
|
|
972
1020
|
|
|
973
1021
|
function addCategoryToElements(elements, categoryName) {
|
|
@@ -1090,7 +1138,9 @@
|
|
|
1090
1138
|
isSearchFocused: isSearchFocused,
|
|
1091
1139
|
setIsSearchFocused: setIsSearchFocused,
|
|
1092
1140
|
currency: currency,
|
|
1093
|
-
currencySymbol: currencySymbol
|
|
1141
|
+
currencySymbol: currencySymbol,
|
|
1142
|
+
onProductSearchResultClick: onProductSearchResultClick,
|
|
1143
|
+
onBrandSearchResultClick: onBrandSearchResultClick
|
|
1094
1144
|
}), /*#__PURE__*/React__default.createElement("nav", {
|
|
1095
1145
|
className: "navbar__nav-links navbar__nav-links--wrap"
|
|
1096
1146
|
}, renderDropdownLinks(), !!stores.length && /*#__PURE__*/React__default.createElement("li", {
|
|
@@ -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.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
|
|
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.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));
|
|
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/LuxityMobileHeader.js
CHANGED
|
@@ -930,7 +930,9 @@
|
|
|
930
930
|
isSearchFocused = _ref.isSearchFocused,
|
|
931
931
|
setIsSearchFocused = _ref.setIsSearchFocused,
|
|
932
932
|
currency = _ref.currency,
|
|
933
|
-
currencySymbol = _ref.currencySymbol
|
|
933
|
+
currencySymbol = _ref.currencySymbol,
|
|
934
|
+
onProductSearchResultClick = _ref.onProductSearchResultClick,
|
|
935
|
+
onBrandSearchResultClick = _ref.onBrandSearchResultClick;
|
|
934
936
|
|
|
935
937
|
var _useState = React.useState(false),
|
|
936
938
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -978,7 +980,18 @@
|
|
|
978
980
|
return /*#__PURE__*/React__default.createElement("a", {
|
|
979
981
|
key: product.link,
|
|
980
982
|
href: product.link,
|
|
981
|
-
className: "product-card"
|
|
983
|
+
className: "product-card",
|
|
984
|
+
onClick: function onClick() {
|
|
985
|
+
if (typeof onProductSearchResultClick === 'function') {
|
|
986
|
+
onProductSearchResultClick({
|
|
987
|
+
product_name: product.name,
|
|
988
|
+
product_brand: product.brand,
|
|
989
|
+
product_link: product.link,
|
|
990
|
+
search_string: searchValue,
|
|
991
|
+
is_popular: shouldShowInitialData
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
}
|
|
982
995
|
}, product.featured_image && /*#__PURE__*/React__default.createElement("div", {
|
|
983
996
|
className: "product-card__image-container"
|
|
984
997
|
}, /*#__PURE__*/React__default.createElement("img", {
|
|
@@ -1031,13 +1044,33 @@
|
|
|
1031
1044
|
return /*#__PURE__*/React__default.createElement("a", {
|
|
1032
1045
|
key: brand.id,
|
|
1033
1046
|
href: getBrandLink(brand),
|
|
1034
|
-
className: "search-results__item"
|
|
1047
|
+
className: "search-results__item",
|
|
1048
|
+
onClick: function onClick() {
|
|
1049
|
+
if (typeof onBrandSearchResultClick === 'function') {
|
|
1050
|
+
onBrandSearchResultClick({
|
|
1051
|
+
brand_name: brand.name,
|
|
1052
|
+
brand_link: getBrandLink(brand),
|
|
1053
|
+
search_string: searchValue,
|
|
1054
|
+
is_trending: true
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1035
1058
|
}, brand.name);
|
|
1036
1059
|
}) : (_limitBrands2 = limitBrands(searchResults === null || searchResults === void 0 ? void 0 : searchResults.brands)) === null || _limitBrands2 === void 0 ? void 0 : _limitBrands2.map(function (brand) {
|
|
1037
1060
|
return /*#__PURE__*/React__default.createElement("a", {
|
|
1038
1061
|
key: brand.link,
|
|
1039
1062
|
href: brand.link,
|
|
1040
|
-
className: "search-results__item"
|
|
1063
|
+
className: "search-results__item",
|
|
1064
|
+
onClick: function onClick() {
|
|
1065
|
+
if (typeof onBrandSearchResultClick === 'function') {
|
|
1066
|
+
onBrandSearchResultClick({
|
|
1067
|
+
brand_name: brand.name,
|
|
1068
|
+
brand_link: brand.link,
|
|
1069
|
+
search_string: searchValue,
|
|
1070
|
+
is_trending: false
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1041
1074
|
}, brand.name);
|
|
1042
1075
|
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
1043
1076
|
className: "search-results__section"
|
|
@@ -1082,7 +1115,8 @@
|
|
|
1082
1115
|
var useSearch = function useSearch(_ref) {
|
|
1083
1116
|
var endpoint = _ref.endpoint,
|
|
1084
1117
|
onProductIdsReceived = _ref.onProductIdsReceived,
|
|
1085
|
-
currency = _ref.currency
|
|
1118
|
+
currency = _ref.currency,
|
|
1119
|
+
onSearchPreview = _ref.onSearchPreview;
|
|
1086
1120
|
var currentSearchRequestToken = React.useRef(null);
|
|
1087
1121
|
var debounce = React.useCallback(function (func, wait) {
|
|
1088
1122
|
var timeout;
|
|
@@ -1143,6 +1177,16 @@
|
|
|
1143
1177
|
onProductIdsReceived(searchResults.luxity_product_ids);
|
|
1144
1178
|
}
|
|
1145
1179
|
|
|
1180
|
+
if (typeof onSearchPreview === 'function') {
|
|
1181
|
+
var _searchResults$brands, _searchResults$produc;
|
|
1182
|
+
|
|
1183
|
+
var hasResults = ((_searchResults$brands = searchResults.brands) === null || _searchResults$brands === void 0 ? void 0 : _searchResults$brands.length) > 0 || ((_searchResults$produc = searchResults.products) === null || _searchResults$produc === void 0 ? void 0 : _searchResults$produc.length) > 0;
|
|
1184
|
+
onSearchPreview({
|
|
1185
|
+
search_string: searchQuery,
|
|
1186
|
+
has_results: hasResults
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1146
1190
|
currentSearchRequestToken.current = null;
|
|
1147
1191
|
}
|
|
1148
1192
|
}).catch(function (error) {
|
|
@@ -1155,7 +1199,7 @@
|
|
|
1155
1199
|
currentSearchRequestToken.current = null;
|
|
1156
1200
|
}
|
|
1157
1201
|
});
|
|
1158
|
-
}, [endpoint, currency, onProductIdsReceived]);
|
|
1202
|
+
}, [endpoint, currency, onSearchPreview, onProductIdsReceived]);
|
|
1159
1203
|
var debouncedSearch = React.useMemo(function () {
|
|
1160
1204
|
return debounce(function (searchQuery, setSearchResults) {
|
|
1161
1205
|
return performSearch(searchQuery, setSearchResults);
|
|
@@ -1290,6 +1334,10 @@
|
|
|
1290
1334
|
endpoint = _ref.endpoint,
|
|
1291
1335
|
initialSearchData = _ref.initialSearchData,
|
|
1292
1336
|
onSearchSubmit = _ref.onSearchSubmit,
|
|
1337
|
+
onSearchBarClick = _ref.onSearchBarClick,
|
|
1338
|
+
onSearchPreview = _ref.onSearchPreview,
|
|
1339
|
+
onProductSearchResultClick = _ref.onProductSearchResultClick,
|
|
1340
|
+
onBrandSearchResultClick = _ref.onBrandSearchResultClick,
|
|
1293
1341
|
onProductIdsReceived = _ref.onProductIdsReceived,
|
|
1294
1342
|
onLogoutClick = _ref.onLogoutClick,
|
|
1295
1343
|
onInterestClick = _ref.onInterestClick,
|
|
@@ -1316,7 +1364,8 @@
|
|
|
1316
1364
|
var _useSearch = useSearch({
|
|
1317
1365
|
endpoint: endpoint,
|
|
1318
1366
|
onProductIdsReceived: onProductIdsReceived,
|
|
1319
|
-
currency: currency
|
|
1367
|
+
currency: currency,
|
|
1368
|
+
onSearchPreview: onSearchPreview
|
|
1320
1369
|
}),
|
|
1321
1370
|
fetchInitialSearchData = _useSearch.fetchInitialSearchData,
|
|
1322
1371
|
createDebouncedSearch = _useSearch.createDebouncedSearch,
|
|
@@ -1391,6 +1440,10 @@
|
|
|
1391
1440
|
}, [showSearchBar]);
|
|
1392
1441
|
|
|
1393
1442
|
var onSearchClick = function onSearchClick() {
|
|
1443
|
+
if (!showSearchBar && typeof onSearchBarClick === 'function') {
|
|
1444
|
+
onSearchBarClick();
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1394
1447
|
setShowSearchbar(function (prev) {
|
|
1395
1448
|
return !prev;
|
|
1396
1449
|
});
|
|
@@ -1594,7 +1647,9 @@
|
|
|
1594
1647
|
isSearchFocused: isSearchFocused,
|
|
1595
1648
|
setIsSearchFocused: setIsSearchFocused,
|
|
1596
1649
|
currency: currency,
|
|
1597
|
-
currencySymbol: currencySymbol
|
|
1650
|
+
currencySymbol: currencySymbol,
|
|
1651
|
+
onProductSearchResultClick: onProductSearchResultClick,
|
|
1652
|
+
onBrandSearchResultClick: onBrandSearchResultClick
|
|
1598
1653
|
}))), shop && /*#__PURE__*/React__default.createElement(LuxitySideNav, {
|
|
1599
1654
|
accordionIcon: accordionIcon,
|
|
1600
1655
|
logoSrc: logoSrc,
|