ordering-ui-external 10.2.2 → 10.3.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.
Files changed (23) hide show
  1. package/_bundles/{7.ordering-ui.2c4c0317bc47a947e415.js → 7.ordering-ui.e758aec40c3bf292cadb.js} +1 -1
  2. package/_bundles/ordering-ui.e758aec40c3bf292cadb.js +2 -0
  3. package/_modules/themes/five/src/components/GiftCard/PurchaseGiftCard/index.js +17 -3
  4. package/_modules/themes/five/src/components/GiftCard/PurchaseGiftCard/styles.js +23 -11
  5. package/_modules/themes/six/src/components/Header/index.js +113 -9
  6. package/_modules/utils/index.js +18 -8
  7. package/package.json +2 -2
  8. package/src/themes/five/src/components/GiftCard/PurchaseGiftCard/index.js +18 -3
  9. package/src/themes/five/src/components/GiftCard/PurchaseGiftCard/styles.js +32 -6
  10. package/src/themes/six/src/components/Header/index.js +113 -4
  11. package/src/utils/index.js +11 -4
  12. package/template/app.js +8 -8
  13. package/_bundles/ordering-ui.2c4c0317bc47a947e415.js +0 -2
  14. /package/_bundles/{0.ordering-ui.2c4c0317bc47a947e415.js → 0.ordering-ui.e758aec40c3bf292cadb.js} +0 -0
  15. /package/_bundles/{1.ordering-ui.2c4c0317bc47a947e415.js → 1.ordering-ui.e758aec40c3bf292cadb.js} +0 -0
  16. /package/_bundles/{2.ordering-ui.2c4c0317bc47a947e415.js → 2.ordering-ui.e758aec40c3bf292cadb.js} +0 -0
  17. /package/_bundles/{4.ordering-ui.2c4c0317bc47a947e415.js → 4.ordering-ui.e758aec40c3bf292cadb.js} +0 -0
  18. /package/_bundles/{5.ordering-ui.2c4c0317bc47a947e415.js → 5.ordering-ui.e758aec40c3bf292cadb.js} +0 -0
  19. /package/_bundles/{6.ordering-ui.2c4c0317bc47a947e415.js → 6.ordering-ui.e758aec40c3bf292cadb.js} +0 -0
  20. /package/_bundles/{7.ordering-ui.2c4c0317bc47a947e415.js.LICENSE.txt → 7.ordering-ui.e758aec40c3bf292cadb.js.LICENSE.txt} +0 -0
  21. /package/_bundles/{8.ordering-ui.2c4c0317bc47a947e415.js → 8.ordering-ui.e758aec40c3bf292cadb.js} +0 -0
  22. /package/_bundles/{9.ordering-ui.2c4c0317bc47a947e415.js → 9.ordering-ui.e758aec40c3bf292cadb.js} +0 -0
  23. /package/_bundles/{ordering-ui.2c4c0317bc47a947e415.js.LICENSE.txt → ordering-ui.e758aec40c3bf292cadb.js.LICENSE.txt} +0 -0
@@ -8,6 +8,7 @@ exports.PurchaseGiftCard = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _orderingComponentsExternal = require("ordering-components-external");
10
10
  var _reactLoadingSkeleton = _interopRequireDefault(require("react-loading-skeleton"));
11
+ var _styledComponents = require("styled-components");
11
12
  var _Buttons = require("../../../styles/Buttons");
12
13
  var _RiRadioButtonFill = _interopRequireDefault(require("@meronex/icons/ri/RiRadioButtonFill"));
13
14
  var _MdRadioButtonUnchecked = _interopRequireDefault(require("@meronex/icons/md/MdRadioButtonUnchecked"));
@@ -34,16 +35,27 @@ var PurchaseGiftCardUI = function PurchaseGiftCardUI(props) {
34
35
  selectedProduct = props.selectedProduct,
35
36
  setSelectedProduct = props.setSelectedProduct,
36
37
  handleAccept = props.handleAccept;
38
+ var theme = (0, _styledComponents.useTheme)();
37
39
  var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
38
40
  _useLanguage2 = _slicedToArray(_useLanguage, 2),
39
41
  t = _useLanguage2[1];
42
+ var _useUtils = (0, _orderingComponentsExternal.useUtils)(),
43
+ _useUtils2 = _slicedToArray(_useUtils, 1),
44
+ optimizeImage = _useUtils2[0].optimizeImage;
40
45
  return /*#__PURE__*/_react.default.createElement(_styles.Container, null, /*#__PURE__*/_react.default.createElement("h2", null, t('PURCHASE_GIFT_CARD', 'Purchase gift card')), /*#__PURE__*/_react.default.createElement(_styles.GiftCardsListContainer, null, /*#__PURE__*/_react.default.createElement("p", null, t('SELECT_ONE_OPTION', 'Select one option')), /*#__PURE__*/_react.default.createElement(_styles.GiftCardsWrapper, null, productsListState.loading && _toConsumableArray(Array(5).keys()).map(function (i) {
41
46
  return /*#__PURE__*/_react.default.createElement(_styles.GiftCardItem, {
42
47
  key: i
43
- }, /*#__PURE__*/_react.default.createElement(_reactLoadingSkeleton.default, {
44
- width: 150
48
+ }, /*#__PURE__*/_react.default.createElement(_styles.IconControl, null, /*#__PURE__*/_react.default.createElement(_reactLoadingSkeleton.default, {
49
+ width: 16,
50
+ height: 16
51
+ })), /*#__PURE__*/_react.default.createElement(_styles.CardImageStyled, null, /*#__PURE__*/_react.default.createElement(_reactLoadingSkeleton.default, {
52
+ width: 38,
53
+ height: 38
54
+ })), /*#__PURE__*/_react.default.createElement(_reactLoadingSkeleton.default, {
55
+ width: 100
45
56
  }));
46
57
  }), productsListState.products.map(function (product) {
58
+ var _theme$images, _theme$images$dummies;
47
59
  return /*#__PURE__*/_react.default.createElement(_styles.GiftCardItem, {
48
60
  key: product.id,
49
61
  onClick: function onClick() {
@@ -51,7 +63,9 @@ var PurchaseGiftCardUI = function PurchaseGiftCardUI(props) {
51
63
  }
52
64
  }, /*#__PURE__*/_react.default.createElement(_styles.IconControl, null, (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.id) === product.id ? /*#__PURE__*/_react.default.createElement(_RiRadioButtonFill.default, null) : /*#__PURE__*/_react.default.createElement(_MdRadioButtonUnchecked.default, {
53
65
  disabled: true
54
- })), /*#__PURE__*/_react.default.createElement("span", null, product.name));
66
+ })), /*#__PURE__*/_react.default.createElement(_styles.CardImage, {
67
+ bgimage: optimizeImage((product === null || product === void 0 ? void 0 : product.image) || (theme === null || theme === void 0 ? void 0 : (_theme$images = theme.images) === null || _theme$images === void 0 ? void 0 : (_theme$images$dummies = _theme$images.dummies) === null || _theme$images$dummies === void 0 ? void 0 : _theme$images$dummies.product), 'h_86,c_limit')
68
+ }), /*#__PURE__*/_react.default.createElement("span", null, product.name));
55
69
  }), !productsListState.loading && productsListState.products.length === 0 && /*#__PURE__*/_react.default.createElement(_NotFoundSource.NotFoundSource, null))), /*#__PURE__*/_react.default.createElement(_styles.ActionButtonContainer, null, /*#__PURE__*/_react.default.createElement(_Buttons.Button, {
56
70
  type: "button",
57
71
  color: "primary",
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.IconControl = exports.GiftCardsWrapper = exports.GiftCardsListContainer = exports.GiftCardItem = exports.Container = exports.ActionButtonContainer = void 0;
8
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
6
+ exports.IconControl = exports.GiftCardsWrapper = exports.GiftCardsListContainer = exports.GiftCardItem = exports.Container = exports.CardImageStyled = exports.CardImage = exports.ActionButtonContainer = void 0;
7
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
12
12
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
13
13
  var Container = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n padding-top: 30px;\n\n h2 {\n font-size: 24px;\n font-weight: 600;\n text-align: center;\n margin-top: 0;\n margin-bottom: 24px;\n }\n > p {\n font-size: 16px;\n line-height: 24px;\n margin-top: 0;\n }\n"])));
14
14
  exports.Container = Container;
@@ -20,16 +20,28 @@ var GiftCardItem = _styledComponents.default.div(_templateObject4 || (_templateO
20
20
  return props.theme.colors.gray200;
21
21
  });
22
22
  exports.GiftCardItem = GiftCardItem;
23
- var IconControl = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n color: ", ";\n margin-right: 40px;\n ", "\n svg {\n font-size: 24px;\n }\n\n svg[disabled] {\n color: ", ";\n }\n"])), function (props) {
23
+ var IconControl = _styledComponents.default.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n color: ", ";\n svg {\n font-size: 24px;\n }\n\n svg[disabled] {\n color: ", ";\n }\n"])), function (props) {
24
24
  return props.theme.colors.primary;
25
- }, function (props) {
26
- var _props$theme;
27
- return ((_props$theme = props.theme) === null || _props$theme === void 0 ? void 0 : _props$theme.rtl) && (0, _styledComponents.css)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n margin-left: 40px;\n margin-right: 0px;\n "])));
28
25
  }, function (props) {
29
26
  return props.theme.colors.lightGray;
30
27
  });
31
28
  exports.IconControl = IconControl;
32
- var ActionButtonContainer = _styledComponents.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: sticky;\n bottom: 0px;\n background-color: ", ";\n padding: 15px 20px;\n > button {\n height: 44px;\n width: 100%;\n }\n"])), function (props) {
29
+ var ActionButtonContainer = _styledComponents.default.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: sticky;\n bottom: 0px;\n background-color: ", ";\n padding: 15px 20px;\n > button {\n height: 44px;\n width: 100%;\n }\n"])), function (props) {
33
30
  return props.theme.colors.backgroundPage;
34
31
  });
35
- exports.ActionButtonContainer = ActionButtonContainer;
32
+ exports.ActionButtonContainer = ActionButtonContainer;
33
+ var CardImageStyled = _styledComponents.default.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n box-sizing: border-box;\n position: relative;\n background-repeat: no-repeat, repeat;\n background-size: cover;\n background-position: center;\n object-fit: cover;\n height: 38px;\n width: 38px;\n min-width: 38px;\n min-height: 38px;\n border-radius: 8px;\n box-shadow: 0px 1px 4px rgba(0,0,0,0.1);\n margin: 0 12px;\n"])));
34
+ exports.CardImageStyled = CardImageStyled;
35
+ var CardImage = function CardImage(props) {
36
+ var style = {};
37
+ if (props.bgimage) {
38
+ style.backgroundImage = "url(".concat(props.bgimage, ")");
39
+ }
40
+ if (props.soldOut) {
41
+ style.filter = 'brightness(70%)';
42
+ }
43
+ return /*#__PURE__*/_react.default.createElement(CardImageStyled, _extends({}, props, {
44
+ style: style
45
+ }), props.children);
46
+ };
47
+ exports.CardImage = CardImage;
@@ -28,6 +28,9 @@ var _LanguageSelector = require("../LanguageSelector");
28
28
  var _CartContent = require("../CartContent");
29
29
  var _SidebarMenu = require("../SidebarMenu");
30
30
  var _HeaderOption = require("../HeaderOption");
31
+ var _LoginForm = require("../../../../../themes/five/src/components/LoginForm");
32
+ var _SignUpForm = require("../../../../../themes/five/src/components/SignUpForm");
33
+ var _ForgotPasswordForm = require("../../../../../themes/five/src/components/ForgotPasswordForm");
31
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
35
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
36
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -44,12 +47,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
44
47
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
45
48
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
46
49
  var Header = function Header(props) {
47
- var _configState$configs, _configState$configs$, _customerState$user, _props$beforeElements, _props$beforeComponen, _theme$images, _theme$images$logos, _theme$images2, _theme$images2$logos, _orderState$options2, _configState$configs2, _configState$configs3, _configState$configs4, _configState$configs5, _orderState$options3, _orderState$options3$, _orderState$options3$2, _orderState$options3$3, _theme$defaultLanguag2, _theme$defaultLanguag3, _orderState$options4, _customerState$user2, _customerState$user3, _theme$defaultLanguag4, _theme$defaultLanguag5, _props$afterComponent, _props$afterElements;
50
+ var _configState$configs, _configState$configs$, _customerState$user, _props$beforeElements, _props$beforeComponen, _theme$images, _theme$images$logos, _theme$images2, _theme$images2$logos, _orderState$options2, _configState$configs2, _configState$configs3, _configState$configs4, _configState$configs5, _orderState$options3, _orderState$options3$, _orderState$options3$2, _orderState$options3$3, _theme$defaultLanguag2, _theme$defaultLanguag3, _orderState$options4, _customerState$user2, _customerState$user3, _theme$defaultLanguag4, _theme$defaultLanguag5, _theme$defaultLanguag6, _theme$defaultLanguag7, _theme$defaultLanguag8, _theme$defaultLanguag9, _props$afterComponent, _props$afterElements;
48
51
  var isHome = props.isHome,
49
52
  location = props.location,
50
53
  isShowOrderOptions = props.isShowOrderOptions,
51
54
  isHideSignup = props.isHideSignup,
52
- isCustomerMode = props.isCustomerMode;
55
+ isCustomerMode = props.isCustomerMode,
56
+ notificationState = props.notificationState,
57
+ useModalMode = props.useModalMode;
53
58
  var _useLocation = (0, _reactRouterDom.useLocation)(),
54
59
  pathname = _useLocation.pathname;
55
60
  var _useEvent = (0, _orderingComponentsExternal.useEvent)(),
@@ -59,8 +64,9 @@ var Header = function Header(props) {
59
64
  _useLanguage2 = _slicedToArray(_useLanguage, 2),
60
65
  t = _useLanguage2[1];
61
66
  var _useSession = (0, _orderingComponentsExternal.useSession)(),
62
- _useSession2 = _slicedToArray(_useSession, 1),
63
- auth = _useSession2[0].auth;
67
+ _useSession2 = _slicedToArray(_useSession, 2),
68
+ auth = _useSession2[0].auth,
69
+ login = _useSession2[1].login;
64
70
  var _useOrder = (0, _orderingComponentsExternal.useOrder)(),
65
71
  _useOrder2 = _slicedToArray(_useOrder, 2),
66
72
  orderState = _useOrder2[0],
@@ -98,6 +104,14 @@ var Header = function Header(props) {
98
104
  _useState10 = _slicedToArray(_useState9, 2),
99
105
  confirm = _useState10[0],
100
106
  setConfirm = _useState10[1];
107
+ var _useState11 = (0, _react.useState)(false),
108
+ _useState12 = _slicedToArray(_useState11, 2),
109
+ authModalOpen = _useState12[0],
110
+ setAuthModalOpen = _useState12[1];
111
+ var _useState13 = (0, _react.useState)(null),
112
+ _useState14 = _slicedToArray(_useState13, 2),
113
+ modalPageToShow = _useState14[0],
114
+ setModalPageToShow = _useState14[1];
101
115
  var cartsWithProducts = (orderState === null || orderState === void 0 ? void 0 : orderState.carts) && Object.values(orderState === null || orderState === void 0 ? void 0 : orderState.carts).filter(function (cart) {
102
116
  var _cart$products;
103
117
  return cart.products && ((_cart$products = cart.products) === null || _cart$products === void 0 ? void 0 : _cart$products.length) > 0;
@@ -148,6 +162,37 @@ var Header = function Header(props) {
148
162
  refreshOrderOptions();
149
163
  }
150
164
  };
165
+ var handleCustomModalClick = function handleCustomModalClick(e, _ref) {
166
+ var page = _ref.page;
167
+ e.preventDefault();
168
+ setModalPageToShow(page);
169
+ };
170
+ var closeAuthModal = function closeAuthModal() {
171
+ setAuthModalOpen(false);
172
+ setModalPageToShow(null);
173
+ };
174
+ var handleSuccessSignup = function handleSuccessSignup(user) {
175
+ var _user$session;
176
+ login({
177
+ user: user,
178
+ token: user === null || user === void 0 ? void 0 : (_user$session = user.session) === null || _user$session === void 0 ? void 0 : _user$session.access_token
179
+ });
180
+ };
181
+ var handleSuccessLogin = function handleSuccessLogin(user) {
182
+ if (user) {
183
+ closeAuthModal();
184
+ }
185
+ };
186
+ var handleOpenLoginSignUp = function handleOpenLoginSignUp(index) {
187
+ if (isCustomerMode) {
188
+ events.emit('go_to_page', {
189
+ page: 'home'
190
+ });
191
+ } else {
192
+ setModalPageToShow(index);
193
+ setAuthModalOpen(true);
194
+ }
195
+ };
151
196
  (0, _react.useEffect)(function () {
152
197
  if (isCustomerMode) {
153
198
  setCustomerModalOpen(false);
@@ -209,14 +254,14 @@ var Header = function Header(props) {
209
254
  }
210
255
  })), !auth && windowSize.width > 768 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_styles.MenuLink, {
211
256
  onClick: function onClick() {
212
- return handleGoToPage({
257
+ return useModalMode ? handleOpenLoginSignUp('login') : handleGoToPage({
213
258
  page: 'signin'
214
259
  });
215
260
  },
216
261
  name: "signin"
217
262
  }, t((theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag2 = theme.defaultLanguages) === null || _theme$defaultLanguag2 === void 0 ? void 0 : _theme$defaultLanguag2.SIGN_IN) || 'Sign in')), !isHideSignup && /*#__PURE__*/_react.default.createElement(_styles.MenuLink, {
218
263
  onClick: function onClick() {
219
- return handleGoToPage({
264
+ return useModalMode ? handleOpenLoginSignUp('signup') : handleGoToPage({
220
265
  page: 'signup'
221
266
  });
222
267
  },
@@ -305,10 +350,69 @@ var Header = function Header(props) {
305
350
  changeOrderAddressWithDefault: true,
306
351
  userCustomerSetup: customerState.user,
307
352
  setCustomerModalOpen: setCustomerModalOpen
308
- })))), /*#__PURE__*/_react.default.createElement(_Confirm.Confirm, {
309
- title: t('CUSTOMER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag4 = theme.defaultLanguages) === null || _theme$defaultLanguag4 === void 0 ? void 0 : _theme$defaultLanguag4.CUSTOMER) || 'Customer'),
353
+ })))), authModalOpen && !auth && /*#__PURE__*/_react.default.createElement(_Modal.Modal, {
354
+ open: authModalOpen,
355
+ onRemove: function onRemove() {
356
+ return closeAuthModal();
357
+ },
358
+ onClose: function onClose() {
359
+ return closeAuthModal();
360
+ },
361
+ width: "50%",
362
+ authModal: true,
363
+ closeOnBackdrop: true
364
+ }, modalPageToShow === 'login' && /*#__PURE__*/_react.default.createElement(_LoginForm.LoginForm, {
365
+ notificationState: notificationState,
366
+ handleSuccessLogin: handleSuccessLogin,
367
+ elementLinkToSignup: /*#__PURE__*/_react.default.createElement("a", {
368
+ onClick: function onClick(e) {
369
+ return handleCustomModalClick(e, {
370
+ page: 'signup'
371
+ });
372
+ },
373
+ href: "#"
374
+ }, t('CREATE_ACCOUNT', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag4 = theme.defaultLanguages) === null || _theme$defaultLanguag4 === void 0 ? void 0 : _theme$defaultLanguag4.CREATE_ACCOUNT) || 'Create account')),
375
+ elementLinkToForgotPassword: /*#__PURE__*/_react.default.createElement("a", {
376
+ onClick: function onClick(e) {
377
+ return handleCustomModalClick(e, {
378
+ page: 'forgotpassword'
379
+ });
380
+ },
381
+ href: "#"
382
+ }, t('RESET_PASSWORD', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag5 = theme.defaultLanguages) === null || _theme$defaultLanguag5 === void 0 ? void 0 : _theme$defaultLanguag5.RESET_PASSWORD) || 'Reset password')),
383
+ useLoginByCellphone: true,
384
+ isPopup: true
385
+ }), modalPageToShow === 'signup' && /*#__PURE__*/_react.default.createElement(_SignUpForm.SignUpForm, {
386
+ notificationState: notificationState,
387
+ elementLinkToLogin: /*#__PURE__*/_react.default.createElement("a", {
388
+ onClick: function onClick(e) {
389
+ return handleCustomModalClick(e, {
390
+ page: 'login'
391
+ });
392
+ },
393
+ href: "#"
394
+ }, t('LOGIN', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag6 = theme.defaultLanguages) === null || _theme$defaultLanguag6 === void 0 ? void 0 : _theme$defaultLanguag6.LOGIN) || 'Login')),
395
+ useLoginByCellphone: true,
396
+ useChekoutFileds: true,
397
+ handleSuccessSignup: handleSuccessSignup,
398
+ isPopup: true,
399
+ closeModal: function closeModal() {
400
+ return closeAuthModal();
401
+ }
402
+ }), modalPageToShow === 'forgotpassword' && /*#__PURE__*/_react.default.createElement(_ForgotPasswordForm.ForgotPasswordForm, {
403
+ elementLinkToLogin: /*#__PURE__*/_react.default.createElement("a", {
404
+ onClick: function onClick(e) {
405
+ return handleCustomModalClick(e, {
406
+ page: 'login'
407
+ });
408
+ },
409
+ href: "#"
410
+ }, t('LOGIN', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag7 = theme.defaultLanguages) === null || _theme$defaultLanguag7 === void 0 ? void 0 : _theme$defaultLanguag7.LOGIN) || 'Login')),
411
+ isPopup: true
412
+ })), /*#__PURE__*/_react.default.createElement(_Confirm.Confirm, {
413
+ title: t('CUSTOMER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag8 = theme.defaultLanguages) === null || _theme$defaultLanguag8 === void 0 ? void 0 : _theme$defaultLanguag8.CUSTOMER) || 'Customer'),
310
414
  content: confirm.content,
311
- acceptText: t('ACCEPT', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag5 = theme.defaultLanguages) === null || _theme$defaultLanguag5 === void 0 ? void 0 : _theme$defaultLanguag5.ACCEPT) || 'Accept'),
415
+ acceptText: t('ACCEPT', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag9 = theme.defaultLanguages) === null || _theme$defaultLanguag9 === void 0 ? void 0 : _theme$defaultLanguag9.ACCEPT) || 'Accept'),
312
416
  open: isCustomerMode && confirm.open,
313
417
  onClose: function onClose() {
314
418
  return setConfirm(_objectSpread(_objectSpread({}, confirm), {}, {
@@ -1133,14 +1133,24 @@ var calendarLanguages = {
1133
1133
  };
1134
1134
  exports.calendarLanguages = calendarLanguages;
1135
1135
  var getCateringValues = function getCateringValues(cateringTypeString, configs) {
1136
- var splitCateringValue = function splitCateringValue(configName) {
1137
- var _Object$values, _Object$values$find, _Object$values$find$v, _Object$values$find$v2, _Object$values$find$v3;
1138
- return (_Object$values = Object.values(configs || {})) === null || _Object$values === void 0 ? void 0 : (_Object$values$find = _Object$values.find(function (config) {
1139
- return (config === null || config === void 0 ? void 0 : config.key) === configName;
1140
- })) === null || _Object$values$find === void 0 ? void 0 : (_Object$values$find$v = _Object$values$find.value) === null || _Object$values$find$v === void 0 ? void 0 : (_Object$values$find$v2 = _Object$values$find$v.split('|')) === null || _Object$values$find$v2 === void 0 ? void 0 : (_Object$values$find$v3 = _Object$values$find$v2.find(function (val) {
1141
- return val.includes(cateringTypeString);
1142
- })) === null || _Object$values$find$v3 === void 0 ? void 0 : _Object$values$find$v3.split(',')[1];
1143
- };
1136
+ var splitCateringValue;
1137
+ if (configs !== null && configs !== void 0 && configs.preorder_slot_interval) {
1138
+ splitCateringValue = function splitCateringValue(configName) {
1139
+ var _configs$configName, _configs$configName$v, _configs$configName$v2, _configs$configName$v3;
1140
+ return (_configs$configName = configs[configName]) === null || _configs$configName === void 0 ? void 0 : (_configs$configName$v = _configs$configName.value) === null || _configs$configName$v === void 0 ? void 0 : (_configs$configName$v2 = _configs$configName$v.split('|')) === null || _configs$configName$v2 === void 0 ? void 0 : (_configs$configName$v3 = _configs$configName$v2.find(function (val) {
1141
+ return val.includes(cateringTypeString);
1142
+ })) === null || _configs$configName$v3 === void 0 ? void 0 : _configs$configName$v3.split(',')[1];
1143
+ };
1144
+ } else {
1145
+ splitCateringValue = function splitCateringValue(configName) {
1146
+ var _Object$values, _Object$values$find, _Object$values$find$v, _Object$values$find$v2, _Object$values$find$v3;
1147
+ return (_Object$values = Object.values(configs || {})) === null || _Object$values === void 0 ? void 0 : (_Object$values$find = _Object$values.find(function (config) {
1148
+ return (config === null || config === void 0 ? void 0 : config.key) === configName;
1149
+ })) === null || _Object$values$find === void 0 ? void 0 : (_Object$values$find$v = _Object$values$find.value) === null || _Object$values$find$v === void 0 ? void 0 : (_Object$values$find$v2 = _Object$values$find$v.split('|')) === null || _Object$values$find$v2 === void 0 ? void 0 : (_Object$values$find$v3 = _Object$values$find$v2.find(function (val) {
1150
+ return val.includes(cateringTypeString);
1151
+ })) === null || _Object$values$find$v3 === void 0 ? void 0 : _Object$values$find$v3.split(',')[1];
1152
+ };
1153
+ }
1144
1154
  var preorderSlotInterval = parseInt(splitCateringValue('preorder_slot_interval'));
1145
1155
  var preorderLeadTime = parseInt(splitCateringValue('preorder_lead_time'));
1146
1156
  var preorderTimeRange = parseInt(splitCateringValue('preorder_time_range'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-external",
3
- "version": "10.2.2",
3
+ "version": "10.3.0",
4
4
  "description": "Ordering UI Components",
5
5
  "main": "./_modules/index.js",
6
6
  "exports": {
@@ -88,7 +88,7 @@
88
88
  "lodash": "^4.17.19",
89
89
  "moment": "^2.29.4",
90
90
  "nanoid": "^4.0.0",
91
- "ordering-components-external": "9.2.1",
91
+ "ordering-components-external": "9.3.0",
92
92
  "payment": "^2.4.6",
93
93
  "polished": "^3.6.6",
94
94
  "react-bootstrap-icons": "^1.7.2",
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
- import { useLanguage, PurchaseGiftCard as PurchaseGiftCardController } from 'ordering-components-external'
2
+ import { useLanguage, useUtils, PurchaseGiftCard as PurchaseGiftCardController } from 'ordering-components-external'
3
3
  import Skeleton from 'react-loading-skeleton'
4
+ import { useTheme } from 'styled-components'
4
5
  import { Button } from '../../../styles/Buttons'
5
6
  import RiRadioButtonFill from '@meronex/icons/ri/RiRadioButtonFill'
6
7
  import MdRadioButtonUnchecked from '@meronex/icons/md/MdRadioButtonUnchecked'
@@ -12,7 +13,9 @@ import {
12
13
  GiftCardsWrapper,
13
14
  GiftCardItem,
14
15
  IconControl,
15
- ActionButtonContainer
16
+ ActionButtonContainer,
17
+ CardImage,
18
+ CardImageStyled
16
19
  } from './styles'
17
20
 
18
21
  const PurchaseGiftCardUI = (props) => {
@@ -22,7 +25,10 @@ const PurchaseGiftCardUI = (props) => {
22
25
  setSelectedProduct,
23
26
  handleAccept
24
27
  } = props
28
+
29
+ const theme = useTheme()
25
30
  const [, t] = useLanguage()
31
+ const [{ optimizeImage }] = useUtils()
26
32
 
27
33
  return (
28
34
  <Container>
@@ -33,7 +39,13 @@ const PurchaseGiftCardUI = (props) => {
33
39
  {productsListState.loading && (
34
40
  [...Array(5).keys()].map(i => (
35
41
  <GiftCardItem key={i}>
36
- <Skeleton width={150} />
42
+ <IconControl>
43
+ <Skeleton width={16} height={16} />
44
+ </IconControl>
45
+ <CardImageStyled>
46
+ <Skeleton width={38} height={38} />
47
+ </CardImageStyled>
48
+ <Skeleton width={100} />
37
49
  </GiftCardItem>
38
50
  ))
39
51
  )}
@@ -49,6 +61,9 @@ const PurchaseGiftCardUI = (props) => {
49
61
  <MdRadioButtonUnchecked disabled />
50
62
  )}
51
63
  </IconControl>
64
+ <CardImage
65
+ bgimage={optimizeImage(product?.image || theme?.images?.dummies?.product, 'h_86,c_limit')}
66
+ />
52
67
  <span>{product.name}</span>
53
68
  </GiftCardItem>
54
69
  ))}
@@ -1,4 +1,5 @@
1
- import styled, { css } from 'styled-components'
1
+ import styled from 'styled-components'
2
+ import React from 'react'
2
3
 
3
4
  export const Container = styled.div`
4
5
  display: flex;
@@ -38,11 +39,6 @@ export const GiftCardItem = styled.div`
38
39
  export const IconControl = styled.div`
39
40
  display: flex;
40
41
  color: ${props => props.theme.colors.primary};
41
- margin-right: 40px;
42
- ${props => props.theme?.rtl && css`
43
- margin-left: 40px;
44
- margin-right: 0px;
45
- `}
46
42
  svg {
47
43
  font-size: 24px;
48
44
  }
@@ -61,3 +57,33 @@ export const ActionButtonContainer = styled.div`
61
57
  width: 100%;
62
58
  }
63
59
  `
60
+
61
+ export const CardImageStyled = styled.div`
62
+ box-sizing: border-box;
63
+ position: relative;
64
+ background-repeat: no-repeat, repeat;
65
+ background-size: cover;
66
+ background-position: center;
67
+ object-fit: cover;
68
+ height: 38px;
69
+ width: 38px;
70
+ min-width: 38px;
71
+ min-height: 38px;
72
+ border-radius: 8px;
73
+ box-shadow: 0px 1px 4px rgba(0,0,0,0.1);
74
+ margin: 0 12px;
75
+ `
76
+ export const CardImage = (props) => {
77
+ const style = {}
78
+ if (props.bgimage) {
79
+ style.backgroundImage = `url(${props.bgimage})`
80
+ }
81
+ if (props.soldOut) {
82
+ style.filter = 'brightness(70%)'
83
+ }
84
+ return (
85
+ <CardImageStyled {...props} style={style}>
86
+ {props.children}
87
+ </CardImageStyled>
88
+ )
89
+ }
@@ -32,18 +32,25 @@ import { LanguageSelector } from '../LanguageSelector'
32
32
  import { CartContent } from '../CartContent'
33
33
  import { SidebarMenu } from '../SidebarMenu'
34
34
  import { HeaderOption } from '../HeaderOption'
35
+ import { LoginForm } from '../../../../../themes/five/src/components/LoginForm'
36
+ import { SignUpForm } from '../../../../../themes/five/src/components/SignUpForm'
37
+ import { ForgotPasswordForm } from '../../../../../themes/five/src/components/ForgotPasswordForm'
38
+
39
+
35
40
  export const Header = (props) => {
36
41
  const {
37
42
  isHome,
38
43
  location,
39
44
  isShowOrderOptions,
40
45
  isHideSignup,
41
- isCustomerMode
46
+ isCustomerMode,
47
+ notificationState,
48
+ useModalMode
42
49
  } = props
43
50
  const { pathname } = useLocation()
44
51
  const [events] = useEvent()
45
52
  const [, t] = useLanguage()
46
- const [{ auth }] = useSession()
53
+ const [{ auth }, { login }] = useSession()
47
54
  const [orderState, { refreshOrderOptions }] = useOrder()
48
55
  const [openPopover, setOpenPopover] = useState({})
49
56
  const theme = useTheme()
@@ -54,6 +61,9 @@ export const Header = (props) => {
54
61
  const [customerModalOpen, setCustomerModalOpen] = useState(false)
55
62
  const [modalSelected, setModalSelected] = useState(null)
56
63
  const [confirm, setConfirm] = useState({ open: false, content: null, handleOnAccept: null })
64
+ const [authModalOpen, setAuthModalOpen] = useState(false)
65
+ const [modalPageToShow, setModalPageToShow] = useState(null)
66
+
57
67
  const cartsWithProducts = (orderState?.carts && Object.values(orderState?.carts).filter(cart => cart.products && cart.products?.length > 0)) || null
58
68
  const windowSize = useWindowSize()
59
69
  const onlineStatus = useOnlineStatus()
@@ -99,6 +109,39 @@ export const Header = (props) => {
99
109
  refreshOrderOptions()
100
110
  }
101
111
  }
112
+
113
+ const handleCustomModalClick = (e, { page }) => {
114
+ e.preventDefault()
115
+ setModalPageToShow(page)
116
+ }
117
+
118
+ const closeAuthModal = () => {
119
+ setAuthModalOpen(false)
120
+ setModalPageToShow(null)
121
+ }
122
+
123
+ const handleSuccessSignup = (user) => {
124
+ login({
125
+ user,
126
+ token: user?.session?.access_token
127
+ })
128
+ }
129
+
130
+ const handleSuccessLogin = (user) => {
131
+ if (user) {
132
+ closeAuthModal()
133
+ }
134
+ }
135
+
136
+ const handleOpenLoginSignUp = (index) => {
137
+ if (isCustomerMode) {
138
+ events.emit('go_to_page', { page: 'home' })
139
+ } else {
140
+ setModalPageToShow(index)
141
+ setAuthModalOpen(true)
142
+ }
143
+ }
144
+
102
145
  useEffect(() => {
103
146
  if (isCustomerMode) {
104
147
  setCustomerModalOpen(false)
@@ -171,9 +214,9 @@ export const Header = (props) => {
171
214
  {
172
215
  !auth && windowSize.width > 768 && (
173
216
  <>
174
- <MenuLink onClick={() => handleGoToPage({ page: 'signin' })} name='signin'>{t(theme?.defaultLanguages?.SIGN_IN || 'Sign in')}</MenuLink>
217
+ <MenuLink onClick={() => useModalMode ? handleOpenLoginSignUp('login') : handleGoToPage({ page: 'signin' })} name='signin'>{t(theme?.defaultLanguages?.SIGN_IN || 'Sign in')}</MenuLink>
175
218
  {!isHideSignup && (
176
- <MenuLink onClick={() => handleGoToPage({ page: 'signup' })} highlight={1} name='signup'>{t(theme?.defaultLanguages?.SIGN_UP || 'Join now')}</MenuLink>
219
+ <MenuLink onClick={() => useModalMode ? handleOpenLoginSignUp('signup') : handleGoToPage({ page: 'signup' })} highlight={1} name='signup'>{t(theme?.defaultLanguages?.SIGN_UP || 'Join now')}</MenuLink>
177
220
  )}
178
221
  </>
179
222
  )
@@ -288,6 +331,72 @@ export const Header = (props) => {
288
331
  </UserEdit>
289
332
  </Modal>
290
333
  )}
334
+ {authModalOpen && !auth && (
335
+ <Modal
336
+ open={authModalOpen}
337
+ onRemove={() => closeAuthModal()}
338
+ onClose={() => closeAuthModal()}
339
+ width='50%'
340
+ authModal
341
+ closeOnBackdrop
342
+ >
343
+ {modalPageToShow === 'login' && (
344
+ <LoginForm
345
+ notificationState={notificationState}
346
+ handleSuccessLogin={handleSuccessLogin}
347
+ elementLinkToSignup={
348
+ <a
349
+ onClick={
350
+ (e) => handleCustomModalClick(e, { page: 'signup' })
351
+ } href='#'
352
+ >{t('CREATE_ACCOUNT', theme?.defaultLanguages?.CREATE_ACCOUNT || 'Create account')}
353
+ </a>
354
+ }
355
+ elementLinkToForgotPassword={
356
+ <a
357
+ onClick={
358
+ (e) => handleCustomModalClick(e, { page: 'forgotpassword' })
359
+ } href='#'
360
+ >{t('RESET_PASSWORD', theme?.defaultLanguages?.RESET_PASSWORD || 'Reset password')}
361
+ </a>
362
+ }
363
+ useLoginByCellphone
364
+ isPopup
365
+ />
366
+ )}
367
+ {modalPageToShow === 'signup' && (
368
+ <SignUpForm
369
+ notificationState={notificationState}
370
+ elementLinkToLogin={
371
+ <a
372
+ onClick={
373
+ (e) => handleCustomModalClick(e, { page: 'login' })
374
+ } href='#'
375
+ >{t('LOGIN', theme?.defaultLanguages?.LOGIN || 'Login')}
376
+ </a>
377
+ }
378
+ useLoginByCellphone
379
+ useChekoutFileds
380
+ handleSuccessSignup={handleSuccessSignup}
381
+ isPopup
382
+ closeModal={() => closeAuthModal()}
383
+ />
384
+ )}
385
+ {modalPageToShow === 'forgotpassword' && (
386
+ <ForgotPasswordForm
387
+ elementLinkToLogin={
388
+ <a
389
+ onClick={
390
+ (e) => handleCustomModalClick(e, { page: 'login' })
391
+ } href='#'
392
+ >{t('LOGIN', theme?.defaultLanguages?.LOGIN || 'Login')}
393
+ </a>
394
+ }
395
+ isPopup
396
+ />
397
+ )}
398
+ </Modal>
399
+ )}
291
400
  <Confirm
292
401
  title={t('CUSTOMER', theme?.defaultLanguages?.CUSTOMER || 'Customer')}
293
402
  content={confirm.content}
@@ -707,10 +707,17 @@ export const calendarLanguages = {
707
707
  }
708
708
 
709
709
  export const getCateringValues = (cateringTypeString, configs) => {
710
- const splitCateringValue = (configName) => Object.values(configs || {})
711
- ?.find(config => config?.key === configName)
712
- ?.value?.split('|')
713
- ?.find(val => val.includes(cateringTypeString))?.split(',')[1]
710
+ let splitCateringValue
711
+ if (configs?.preorder_slot_interval) {
712
+ splitCateringValue = (configName) => configs[configName]
713
+ ?.value?.split('|')
714
+ ?.find(val => val.includes(cateringTypeString))?.split(',')[1]
715
+ } else {
716
+ splitCateringValue = (configName) => Object.values(configs || {})
717
+ ?.find(config => config?.key === configName)
718
+ ?.value?.split('|')
719
+ ?.find(val => val.includes(cateringTypeString))?.split(',')[1]
720
+ }
714
721
  const preorderSlotInterval = parseInt(splitCateringValue('preorder_slot_interval'))
715
722
  const preorderLeadTime = parseInt(splitCateringValue('preorder_lead_time'))
716
723
  const preorderTimeRange = parseInt(splitCateringValue('preorder_time_range'))