@bonlineza/luxity-lib 2.34.8 → 2.35.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/build/bundle.js CHANGED
@@ -9685,7 +9685,7 @@
9685
9685
  });
9686
9686
 
9687
9687
  var _templateObject$E;
9688
- var NotifyContainer = styled__default.div(_templateObject$E || (_templateObject$E = _taggedTemplateLiteral(["\n .page-ready {\n display: flex;\n align-items: center;\n }\n\n .loader {\n min-width: 150px;\n }\n\n .notification-dropdown-select-container {\n min-width: 150px;\n\n .notification-dropdown-select__control {\n min-height: auto;\n background-color: ", ";\n border: none;\n border-radius: 0;\n\n &--is-focused {\n border: none;\n border-radius: 0;\n box-shadow: none;\n }\n\n .notification-dropdown-select__value-container {\n & > div {\n padding: 0;\n margin: 0;\n color: ", ";\n }\n & .notification-dropdown-select__single-value,\n & .notification-dropdown-select__placeholder {\n overflow: visible;\n font-weight: lighter;\n }\n }\n }\n }\n\n .notification-dropdown-select__indicators {\n padding: 0 !important;\n .notification-dropdown-select__dropdown-indicator {\n color: ", ";\n }\n }\n\n .notification-dropdown-select__menu {\n border-radius: 0;\n\n & > .notification-dropdown-select__menu-list {\n border-radius: 0;\n\n & > .notification-dropdown-select__option {\n font-weight: bold;\n &:last-child {\n border-bottom: none;\n }\n\n &.notification-dropdown-select__option--is-focused {\n background-color: ", ";\n border-style: hidden;\n }\n &.notification-dropdown-select__option--is-selected {\n color: ", ";\n background-color: ", ";\n border-style: hidden;\n }\n &.notification-dropdown-select__option--is-selected.notification-dropdown-select__option--is-focused {\n border-style: hidden;\n }\n }\n }\n }\n"])), function (props) {
9688
+ var NotifyContainer = styled__default.div(_templateObject$E || (_templateObject$E = _taggedTemplateLiteral(["\n .page-ready {\n display: flex;\n align-items: center;\n }\n\n .notification-settings {\n display: flex;\n align-items: center;\n }\n\n .notification-dropdown-label {\n margin-left: 20px;\n }\n\n .loader {\n min-width: 150px;\n }\n\n .notification-dropdown-select-container {\n min-width: 110px;\n\n .notification-dropdown-select__control {\n min-height: auto;\n background-color: ", ";\n border: none;\n border-radius: 0;\n\n &--is-focused {\n border: none;\n border-radius: 0;\n box-shadow: none;\n }\n\n .notification-dropdown-select__value-container {\n & > div {\n padding: 0;\n margin: 0;\n color: ", ";\n }\n & .notification-dropdown-select__single-value,\n & .notification-dropdown-select__placeholder {\n overflow: visible;\n font-weight: lighter;\n }\n }\n }\n }\n\n .notification-dropdown-select__indicators {\n padding: 0 !important;\n .notification-dropdown-select__dropdown-indicator {\n color: ", ";\n }\n }\n\n .notification-dropdown-select__menu {\n border-radius: 0;\n\n & > .notification-dropdown-select__menu-list {\n border-radius: 0;\n\n & > .notification-dropdown-select__option {\n font-weight: bold;\n &:last-child {\n border-bottom: none;\n }\n\n &.notification-dropdown-select__option--is-focused {\n background-color: ", ";\n border-style: hidden;\n }\n &.notification-dropdown-select__option--is-selected {\n color: ", ";\n background-color: ", ";\n border-style: hidden;\n }\n &.notification-dropdown-select__option--is-selected.notification-dropdown-select__option--is-focused {\n border-style: hidden;\n }\n }\n }\n }\n"])), function (props) {
9689
9689
  return props.theme.colors.ntrlMin;
9690
9690
  }, function (props) {
9691
9691
  return props.theme.colors.base;
@@ -9726,22 +9726,21 @@
9726
9726
 
9727
9727
  _this = _super.call(this, props);
9728
9728
 
9729
- _defineProperty(_assertThisInitialized(_this), "postUpdate", function (selectedOption) {
9729
+ _defineProperty(_assertThisInitialized(_this), "postUpdate", function (selectedOption, type) {
9730
9730
  _this.setState({
9731
9731
  request: _objectSpread2(_objectSpread2({}, request), {}, {
9732
9732
  fetching: true
9733
9733
  })
9734
9734
  });
9735
9735
 
9736
- _this.props.setSchedule(selectedOption.value).then(function () {
9737
- _this.setState({
9738
- selectedOption: selectedOption,
9739
- request: _objectSpread2(_objectSpread2({}, request), {}, {
9740
- success: true
9741
- })
9742
- });
9736
+ _this.props.setSchedule(selectedOption.value, type).then(function () {
9737
+ var _this$setState;
9738
+
9739
+ _this.setState((_this$setState = {}, _defineProperty(_this$setState, type === 'EMAIL' ? 'emailSelectedOption' : 'whatsappSelectedOption', selectedOption), _defineProperty(_this$setState, "request", _objectSpread2(_objectSpread2({}, request), {}, {
9740
+ success: true
9741
+ })), _this$setState));
9743
9742
 
9744
- success('Notification Frequency Updated');
9743
+ success("".concat(type === 'EMAIL' ? 'Email' : 'WhatsApp', " Notification Frequency Updated"));
9745
9744
  }).catch(function () {
9746
9745
  _this.setState({
9747
9746
  request: _objectSpread2(_objectSpread2({}, request), {}, {
@@ -9749,7 +9748,7 @@
9749
9748
  })
9750
9749
  });
9751
9750
 
9752
- error('Error Ocurred');
9751
+ error('Error Occurred');
9753
9752
  });
9754
9753
  });
9755
9754
 
@@ -9768,24 +9767,29 @@
9768
9767
 
9769
9768
  var options = _this.getOptionsFromEnumResult(data);
9770
9769
 
9771
- var currentValue = data.data.user.email_interest_send_schedule;
9770
+ var _data$data$user = data.data.user,
9771
+ email_interest_send_schedule = _data$data$user.email_interest_send_schedule,
9772
+ whatsapp_interest_send_schedule = _data$data$user.whatsapp_interest_send_schedule,
9773
+ vip = _data$data$user.vip;
9772
9774
 
9773
- _this.setState(function (prevState) {
9774
- return {
9775
- options: options,
9776
- selectedOption: prevState.selectedOption || options.filter(function (item) {
9777
- return item.value === currentValue;
9778
- }).reduce(function (pv, cv) {
9779
- return cv;
9780
- }, null)
9781
- };
9775
+ _this.setState({
9776
+ options: options,
9777
+ isVip: vip,
9778
+ emailSelectedOption: options.find(function (item) {
9779
+ return item.value === email_interest_send_schedule;
9780
+ }),
9781
+ whatsappSelectedOption: options.find(function (item) {
9782
+ return item.value === whatsapp_interest_send_schedule;
9783
+ })
9782
9784
  });
9783
9785
  });
9784
9786
 
9785
9787
  _defineProperty(_assertThisInitialized(_this), "render", function () {
9786
9788
  var _this$state = _this.state,
9787
9789
  options = _this$state.options,
9788
- selectedOption = _this$state.selectedOption,
9790
+ emailSelectedOption = _this$state.emailSelectedOption,
9791
+ whatsappSelectedOption = _this$state.whatsappSelectedOption,
9792
+ isVip = _this$state.isVip,
9789
9793
  updating = _this$state.request.fetching;
9790
9794
  return /*#__PURE__*/React__default.createElement(NotifyContainer, null, /*#__PURE__*/React__default.createElement(LuxityNotifications, null), /*#__PURE__*/React__default.createElement(LuxityPageReady, {
9791
9795
  getRequestPromise: _this.props.getSchedule,
@@ -9793,8 +9797,10 @@
9793
9797
  return _this.onData(data);
9794
9798
  }
9795
9799
  }, /*#__PURE__*/React__default.createElement(React.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
9800
+ className: "notification-settings"
9801
+ }, isVip && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
9796
9802
  className: "notification-dropdown-label"
9797
- }, "Notification:\xA0"), updating ? /*#__PURE__*/React__default.createElement(EllipsisLoader, null) : /*#__PURE__*/React__default.createElement(index$1$1, {
9803
+ }, "Notify me via WhatsApp:\xA0"), updating ? /*#__PURE__*/React__default.createElement(EllipsisLoader, null) : /*#__PURE__*/React__default.createElement(index$1$1, {
9798
9804
  isMulti: false,
9799
9805
  isSearchable: false,
9800
9806
  components: {
@@ -9805,14 +9811,35 @@
9805
9811
  options: options,
9806
9812
  className: "notification-dropdown-select-container",
9807
9813
  classNamePrefix: "notification-dropdown-select",
9808
- onChange: _this.postUpdate,
9809
- value: selectedOption
9810
- }))));
9814
+ onChange: function onChange(option) {
9815
+ return _this.postUpdate(option, 'WHATSAPP');
9816
+ },
9817
+ value: whatsappSelectedOption
9818
+ })), /*#__PURE__*/React__default.createElement("div", {
9819
+ className: "notification-dropdown-label"
9820
+ }, "Notify me via Email:\xA0"), updating ? /*#__PURE__*/React__default.createElement(EllipsisLoader, null) : /*#__PURE__*/React__default.createElement(index$1$1, {
9821
+ isMulti: false,
9822
+ isSearchable: false,
9823
+ components: {
9824
+ IndicatorSeparator: function IndicatorSeparator() {
9825
+ return null;
9826
+ }
9827
+ },
9828
+ options: options,
9829
+ className: "notification-dropdown-select-container",
9830
+ classNamePrefix: "notification-dropdown-select",
9831
+ onChange: function onChange(option) {
9832
+ return _this.postUpdate(option, 'EMAIL');
9833
+ },
9834
+ value: emailSelectedOption
9835
+ })))));
9811
9836
  });
9812
9837
 
9813
9838
  _this.state = {
9814
9839
  options: [],
9815
- selectedOption: null,
9840
+ emailSelectedOption: null,
9841
+ whatsappSelectedOption: null,
9842
+ isVip: false,
9816
9843
  request: _objectSpread2({}, request)
9817
9844
  };
9818
9845
  return _this;
@@ -14996,27 +15023,24 @@
14996
15023
  };
14997
15024
 
14998
15025
  var debouncedSearch = React.useCallback(debounce(function (nextValue) {
14999
- var isKeyDown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
15000
15026
  setSearchLoading(true);
15001
15027
  axios.post(endpoint, searchProducts(nextValue, 6)).then(function (response) {
15002
15028
  setSearchResults(response.data.data.luxity_products_serach_results);
15003
15029
  var ids = response.data.data.luxity_products_serach_results.luxity_product_ids;
15004
15030
  onProductIdsReceived(ids);
15005
-
15006
- if (isKeyDown) {
15007
- // reset the search results on keydown
15008
- setSearchResults({
15009
- brands: [],
15010
- products: []
15011
- });
15012
- onSearchSubmit(nextValue);
15013
- }
15014
-
15015
15031
  setSearchLoading(false);
15016
15032
  }).catch(function () {
15017
15033
  setSearchLoading(false);
15018
15034
  });
15019
15035
  }, 500), [endpoint]);
15036
+ var immediateSearch = React.useCallback(function (value) {
15037
+ setSearchValue('');
15038
+ setSearchResults({
15039
+ brands: [],
15040
+ products: []
15041
+ });
15042
+ onSearchSubmit(value);
15043
+ }, [onSearchSubmit]);
15020
15044
 
15021
15045
  var handleChange = function handleChange(event) {
15022
15046
  var value = event.target.value;
@@ -15047,7 +15071,11 @@
15047
15071
 
15048
15072
  var handleKeyDown = function handleKeyDown(event) {
15049
15073
  if (event.key === 'Enter') {
15050
- debouncedSearch(searchValue, true);
15074
+ event.preventDefault();
15075
+
15076
+ if (searchValue.trim().length >= 3) {
15077
+ immediateSearch(searchValue);
15078
+ }
15051
15079
  } else if (event.key === 'Escape') {
15052
15080
  setSearchValue('');
15053
15081
  }
@@ -15082,6 +15110,13 @@
15082
15110
  return setHasError(true);
15083
15111
  });
15084
15112
  }, [menuData]);
15113
+
15114
+ var getMarginRight = function getMarginRight(userIsVip, userName) {
15115
+ if (userIsVip) return '15px';
15116
+ if (userName) return '5px';
15117
+ return '18px';
15118
+ };
15119
+
15085
15120
  return /*#__PURE__*/React__default.createElement("div", {
15086
15121
  className: "navbar"
15087
15122
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -15222,7 +15257,7 @@
15222
15257
  className: "navbar__icon relative flex",
15223
15258
  onClick: onAccountClick,
15224
15259
  style: {
15225
- marginRight: isVip ? '15px' : '5px'
15260
+ marginRight: getMarginRight(isVip, name)
15226
15261
  }
15227
15262
  }, /*#__PURE__*/React__default.createElement("img", {
15228
15263
  src: accountIcon,
@@ -16044,27 +16079,24 @@
16044
16079
  };
16045
16080
 
16046
16081
  var debouncedSearch = React.useCallback(debounce(function (nextValue) {
16047
- var isKeyDown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
16048
16082
  setSearchLoading(true);
16049
16083
  axios.post(endpoint, searchProducts(nextValue, 6)).then(function (response) {
16050
16084
  setSearchResults(response.data.data.luxity_products_serach_results);
16051
16085
  var ids = response.data.data.luxity_products_serach_results.luxity_product_ids;
16052
16086
  onProductIdsReceived(ids);
16053
-
16054
- if (isKeyDown) {
16055
- // reset the search results on keydown
16056
- setSearchResults({
16057
- brands: [],
16058
- products: []
16059
- });
16060
- onSearchSubmit(nextValue);
16061
- }
16062
-
16063
16087
  setSearchLoading(false);
16064
16088
  }).catch(function () {
16065
16089
  setSearchLoading(false);
16066
16090
  });
16067
16091
  }, 500), [endpoint]);
16092
+ var immediateSearch = React.useCallback(function (value) {
16093
+ setSearchValue('');
16094
+ setSearchResults({
16095
+ brands: [],
16096
+ products: []
16097
+ });
16098
+ onSearchSubmit(value);
16099
+ }, [onSearchSubmit]);
16068
16100
 
16069
16101
  var handleChange = function handleChange(event) {
16070
16102
  var value = event.target.value;
@@ -16082,7 +16114,11 @@
16082
16114
 
16083
16115
  var handleKeyDown = function handleKeyDown(event) {
16084
16116
  if (event.key === 'Enter') {
16085
- debouncedSearch(searchValue, true);
16117
+ event.preventDefault();
16118
+
16119
+ if (searchValue.trim().length >= 3) {
16120
+ immediateSearch(searchValue);
16121
+ }
16086
16122
  } else if (event.key === 'Escape') {
16087
16123
  setSearchValue('');
16088
16124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonlineza/luxity-lib",
3
- "version": "2.34.8",
3
+ "version": "2.35.0",
4
4
  "scripts": {
5
5
  "start": "start-storybook -p 9001 -c .storybook -s ./public",
6
6
  "clean": "rimraf ./build/*.*",