ordering-ui-external 2.1.0 → 2.1.1
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/_modules/themes/five/src/components/HorizontalOrdersLayout/index.js +5 -55
- package/_modules/themes/five/src/components/PageBanner/index.js +120 -6
- package/package.json +1 -1
- package/src/themes/five/src/components/HorizontalOrdersLayout/index.js +26 -75
- package/src/themes/five/src/components/PageBanner/index.js +96 -4
|
@@ -5,34 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.HorizontalOrdersLayout = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _orderingComponentsExternal = require("ordering-components-external");
|
|
9
8
|
var _styles = require("./styles");
|
|
10
9
|
var _styles2 = require("../OrdersOption/styles");
|
|
11
|
-
var _Buttons = require("../../styles/Buttons");
|
|
12
10
|
var _SingleOrderCard = require("../SingleOrderCard");
|
|
13
11
|
var _Pagination = require("../Pagination");
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
13
|
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); }
|
|
16
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
18
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
20
|
-
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; } }
|
|
21
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
14
|
var HorizontalOrdersLayout = function HorizontalOrdersLayout(props) {
|
|
23
15
|
var pagination = props.pagination,
|
|
24
|
-
loadMoreOrders = props.loadMoreOrders,
|
|
25
16
|
isBusinessesPage = props.isBusinessesPage,
|
|
26
17
|
customArray = props.customArray,
|
|
27
18
|
businessesIds = props.businessesIds,
|
|
28
19
|
isCustomerMode = props.isCustomerMode,
|
|
29
|
-
isProducts = props.isProducts,
|
|
30
|
-
isBusiness = props.isBusiness,
|
|
31
20
|
handleChangePage = props.handleChangePage;
|
|
32
21
|
var orders = customArray || props.orders;
|
|
33
|
-
var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
|
|
34
|
-
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
35
|
-
t = _useLanguage2[1];
|
|
36
22
|
var ordersToShow = businessesIds && isCustomerMode ? orders.filter(function (order) {
|
|
37
23
|
return businessesIds === null || businessesIds === void 0 ? void 0 : businessesIds.includes(order === null || order === void 0 ? void 0 : order.business_id);
|
|
38
24
|
}) : businessesIds ? orders.filter(function (order) {
|
|
@@ -45,57 +31,21 @@ var HorizontalOrdersLayout = function HorizontalOrdersLayout(props) {
|
|
|
45
31
|
return a - b;
|
|
46
32
|
}));
|
|
47
33
|
}) : orders;
|
|
48
|
-
|
|
49
|
-
var Orders = function Orders() {
|
|
50
|
-
var _props$beforeElements, _props$beforeComponen, _props$afterComponent, _props$afterElements;
|
|
51
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (_props$beforeElements = props.beforeElements) === null || _props$beforeElements === void 0 ? void 0 : _props$beforeElements.map(function (BeforeElement, i) {
|
|
52
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
53
|
-
key: i
|
|
54
|
-
}, BeforeElement);
|
|
55
|
-
}), (_props$beforeComponen = props.beforeComponents) === null || _props$beforeComponen === void 0 ? void 0 : _props$beforeComponen.map(function (BeforeComponent, i) {
|
|
56
|
-
return /*#__PURE__*/_react.default.createElement(BeforeComponent, _extends({
|
|
57
|
-
key: i
|
|
58
|
-
}, props));
|
|
59
|
-
}), orders.length > 0 && !notOrders && ordersToShow.map(function (order) {
|
|
60
|
-
return /*#__PURE__*/_react.default.createElement(_SingleOrderCard.SingleOrderCard, _extends({}, props, {
|
|
61
|
-
key: order.id,
|
|
62
|
-
order: order
|
|
63
|
-
}));
|
|
64
|
-
}), (pagination === null || pagination === void 0 ? void 0 : pagination.totalPages) && !notOrders && (pagination === null || pagination === void 0 ? void 0 : pagination.currentPage) < (pagination === null || pagination === void 0 ? void 0 : pagination.totalPages) && !notOrders && /*#__PURE__*/_react.default.createElement(_styles.Card, {
|
|
65
|
-
flex: true,
|
|
66
|
-
nobg: true,
|
|
67
|
-
isBusinessesPage: isBusinessesPage,
|
|
68
|
-
isCustomerMode: isCustomerMode
|
|
69
|
-
}, /*#__PURE__*/_react.default.createElement(_Buttons.Button, {
|
|
70
|
-
className: "load-orders",
|
|
71
|
-
color: "primary",
|
|
72
|
-
outline: true,
|
|
73
|
-
onClick: loadMoreOrders
|
|
74
|
-
}, t('LOAD_MORE_ORDERS', 'Load more orders'))), (_props$afterComponent = props.afterComponents) === null || _props$afterComponent === void 0 ? void 0 : _props$afterComponent.map(function (AfterComponent, i) {
|
|
75
|
-
return /*#__PURE__*/_react.default.createElement(AfterComponent, _extends({
|
|
76
|
-
key: i
|
|
77
|
-
}, props));
|
|
78
|
-
}), (_props$afterElements = props.afterElements) === null || _props$afterElements === void 0 ? void 0 : _props$afterElements.map(function (AfterElement, i) {
|
|
79
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
80
|
-
key: i
|
|
81
|
-
}, AfterElement);
|
|
82
|
-
}));
|
|
83
|
-
};
|
|
84
|
-
return /*#__PURE__*/_react.default.createElement(_styles2.OrdersContainer, {
|
|
34
|
+
return orders.length > 0 && ordersToShow.length > 0 ? /*#__PURE__*/_react.default.createElement(_styles2.OrdersContainer, {
|
|
85
35
|
id: "orders-container",
|
|
86
36
|
activeOrders: true,
|
|
87
37
|
ordersLength: (orders === null || orders === void 0 ? void 0 : orders.length) <= 1,
|
|
88
38
|
isBusinessesPage: isBusinessesPage
|
|
89
|
-
}, /*#__PURE__*/_react.default.createElement(_styles.CardWrapper, null, /*#__PURE__*/_react.default.createElement(_styles.CardsContainer, null, orders.length > 0 && ordersToShow.map(function (order) {
|
|
39
|
+
}, /*#__PURE__*/_react.default.createElement(_styles.CardWrapper, null, /*#__PURE__*/_react.default.createElement(_styles.CardsContainer, null, orders.length > 0 && ordersToShow.map(function (order, i) {
|
|
90
40
|
var _order$id;
|
|
91
41
|
return /*#__PURE__*/_react.default.createElement(_SingleOrderCard.SingleOrderCard, _extends({}, props, {
|
|
92
|
-
key: order.id || ((_order$id = order.id) === null || _order$id === void 0 ? void 0 : _order$id[0]),
|
|
42
|
+
key: order.id || ((_order$id = order.id) === null || _order$id === void 0 ? void 0 : _order$id[0]) || i,
|
|
93
43
|
order: order
|
|
94
44
|
}));
|
|
95
|
-
})), /*#__PURE__*/_react.default.createElement(_Pagination.Pagination, {
|
|
45
|
+
})), orders.length > 0 && ordersToShow.length > 0 && /*#__PURE__*/_react.default.createElement(_Pagination.Pagination, {
|
|
96
46
|
currentPage: pagination.currentPage,
|
|
97
47
|
totalPages: Math.ceil(pagination === null || pagination === void 0 ? void 0 : pagination.totalPages),
|
|
98
48
|
handleChangePage: handleChangePage
|
|
99
|
-
})));
|
|
49
|
+
}))) : null;
|
|
100
50
|
};
|
|
101
51
|
exports.HorizontalOrdersLayout = HorizontalOrdersLayout;
|
|
@@ -1,5 +1,6 @@
|
|
|
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -11,30 +12,143 @@ var _react2 = require("swiper/react");
|
|
|
11
12
|
var _swiper = _interopRequireWildcard(require("swiper"));
|
|
12
13
|
require("swiper/swiper-bundle.min.css");
|
|
13
14
|
require("swiper/swiper.min.css");
|
|
15
|
+
var _utils = require("../../../../../utils");
|
|
14
16
|
var _styles = require("./styles");
|
|
15
17
|
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); }
|
|
16
18
|
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; }
|
|
17
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
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); }
|
|
19
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
21
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
22
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
23
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
23
24
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
25
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
26
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
28
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
29
|
+
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; } }
|
|
30
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
31
|
_swiper.default.use([_swiper.Navigation]);
|
|
25
32
|
var PageBannerUI = function PageBannerUI(props) {
|
|
26
|
-
var _pageBannerState$bann, _pageBannerState$bann2, _pageBannerState$bann3;
|
|
33
|
+
var _pageBannerState$bann, _pageBannerState$bann2, _pageBannerState$bann3, _pageBannerState$bann4;
|
|
27
34
|
var pageBannerState = props.pageBannerState;
|
|
35
|
+
var _useSite = (0, _orderingComponentsExternal.useSite)(),
|
|
36
|
+
_useSite2 = _slicedToArray(_useSite, 1),
|
|
37
|
+
site = _useSite2[0].site;
|
|
38
|
+
var _useEvent = (0, _orderingComponentsExternal.useEvent)(),
|
|
39
|
+
_useEvent2 = _slicedToArray(_useEvent, 1),
|
|
40
|
+
events = _useEvent2[0];
|
|
41
|
+
var businessUrlTemplate = (0, _utils.checkSiteUrl)(site === null || site === void 0 ? void 0 : site.business_url_template, '/store/:business_slug');
|
|
42
|
+
var productUrlTemplate = (0, _utils.checkSiteUrl)(site === null || site === void 0 ? void 0 : site.product_url_template, '/store/:business_slug?category=:category_id&product=:product_id');
|
|
43
|
+
var onProductRedirect = function onProductRedirect(_ref) {
|
|
44
|
+
var slug = _ref.slug,
|
|
45
|
+
category = _ref.category,
|
|
46
|
+
product = _ref.product;
|
|
47
|
+
if (!category && !product) {
|
|
48
|
+
if (businessUrlTemplate === '/store/:business_slug' || businessUrlTemplate === '/:business_slug') {
|
|
49
|
+
return events.emit('go_to_page', {
|
|
50
|
+
page: 'business',
|
|
51
|
+
params: {
|
|
52
|
+
business_slug: slug
|
|
53
|
+
},
|
|
54
|
+
replace: true
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
return events.emit('go_to_page', {
|
|
58
|
+
page: 'business',
|
|
59
|
+
search: "?".concat(businessUrlTemplate.split('?')[1].replace(':business_slug', '')).concat(slug),
|
|
60
|
+
replace: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
events.emit('product_banner_clicked');
|
|
65
|
+
if (productUrlTemplate === '/store/:business_slug/:category_slug/:product_slug' || productUrlTemplate === '/:business_slug/:category_slug/:product_slug') {
|
|
66
|
+
return events.emit('go_to_page', {
|
|
67
|
+
page: 'product',
|
|
68
|
+
params: {
|
|
69
|
+
business_slug: slug,
|
|
70
|
+
category_slug: category,
|
|
71
|
+
product_slug: product
|
|
72
|
+
},
|
|
73
|
+
replace: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (productUrlTemplate.includes('/store/:category_slug/:product_slug')) {
|
|
77
|
+
var businessParameter = businessUrlTemplate.replace('/store?', '').replace('=:business_slug', '');
|
|
78
|
+
return events.emit('go_to_page', {
|
|
79
|
+
page: 'product',
|
|
80
|
+
params: {
|
|
81
|
+
category_slug: category,
|
|
82
|
+
product_slug: product
|
|
83
|
+
},
|
|
84
|
+
search: "?".concat(businessParameter, "=").concat(slug),
|
|
85
|
+
replace: true
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (productUrlTemplate.includes('/store/:business_slug') && productUrlTemplate.includes('category_id')) {
|
|
89
|
+
var ids = productUrlTemplate.split('?')[1].split('&');
|
|
90
|
+
var categoryParameter = ids[0].replace('=:category_id', '');
|
|
91
|
+
var productParameter = ids[1].replace('=:product_id', '');
|
|
92
|
+
return events.emit('go_to_page', {
|
|
93
|
+
page: 'product',
|
|
94
|
+
params: {
|
|
95
|
+
business_slug: slug
|
|
96
|
+
},
|
|
97
|
+
search: "?".concat(categoryParameter, "=").concat(category, "&").concat(productParameter, "=").concat(product),
|
|
98
|
+
replace: true
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (productUrlTemplate.includes('/:business_slug') && !productUrlTemplate.includes('store')) {
|
|
102
|
+
var _ids = productUrlTemplate.split('?')[1].split('&');
|
|
103
|
+
var _categoryParameter = _ids[0].replace('=:category_id', '');
|
|
104
|
+
var _productParameter = _ids[1].replace('=:product_id', '');
|
|
105
|
+
return events.emit('go_to_page', {
|
|
106
|
+
page: 'product',
|
|
107
|
+
params: {
|
|
108
|
+
business_slug: slug
|
|
109
|
+
},
|
|
110
|
+
search: "?".concat(_categoryParameter, "=").concat(category, "&").concat(_productParameter, "=").concat(product),
|
|
111
|
+
replace: true
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var handleGoToPage = function handleGoToPage(action) {
|
|
116
|
+
if (!(action !== null && action !== void 0 && action.url)) return;
|
|
117
|
+
var slug;
|
|
118
|
+
if (action.type === 'business') {
|
|
119
|
+
slug = action.url.split('store/')[1];
|
|
120
|
+
onProductRedirect({
|
|
121
|
+
slug: slug
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (action.type === 'product') {
|
|
125
|
+
var _action$url$split$;
|
|
126
|
+
slug = (_action$url$split$ = action.url.split('store/')[1]) === null || _action$url$split$ === void 0 ? void 0 : _action$url$split$.split('?')[0];
|
|
127
|
+
var paramString = action.url.split('?')[1];
|
|
128
|
+
var urlParams = new URLSearchParams(paramString);
|
|
129
|
+
var product = urlParams.get('product');
|
|
130
|
+
var category = urlParams.get('category');
|
|
131
|
+
onProductRedirect({
|
|
132
|
+
slug: slug,
|
|
133
|
+
category: category,
|
|
134
|
+
product: product
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
28
138
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, pageBannerState.loading ? /*#__PURE__*/_react.default.createElement(_styles.BannerContainer, null, /*#__PURE__*/_react.default.createElement(_reactLoadingSkeleton.default, {
|
|
29
139
|
height: 250
|
|
30
|
-
})) : ((_pageBannerState$bann = pageBannerState.banner) === null || _pageBannerState$bann === void 0 ? void 0 : _pageBannerState$bann.items) && /*#__PURE__*/_react.default.createElement(_styles.BannerContainer, null, /*#__PURE__*/_react.default.createElement(_react2.Swiper, {
|
|
140
|
+
})) : ((_pageBannerState$bann = pageBannerState.banner) === null || _pageBannerState$bann === void 0 ? void 0 : (_pageBannerState$bann2 = _pageBannerState$bann.items) === null || _pageBannerState$bann2 === void 0 ? void 0 : _pageBannerState$bann2.length) > 0 && /*#__PURE__*/_react.default.createElement(_styles.BannerContainer, null, /*#__PURE__*/_react.default.createElement(_react2.Swiper, {
|
|
31
141
|
navigation: true,
|
|
32
142
|
spaceBetween: 0,
|
|
33
|
-
loop: ((_pageBannerState$
|
|
34
|
-
}, (_pageBannerState$
|
|
143
|
+
loop: ((_pageBannerState$bann3 = pageBannerState.banner) === null || _pageBannerState$bann3 === void 0 ? void 0 : _pageBannerState$bann3.items.length) > 1
|
|
144
|
+
}, (_pageBannerState$bann4 = pageBannerState.banner) === null || _pageBannerState$bann4 === void 0 ? void 0 : _pageBannerState$bann4.items.map(function (img, i) {
|
|
35
145
|
return /*#__PURE__*/_react.default.createElement(_react2.SwiperSlide, {
|
|
36
146
|
key: i
|
|
37
|
-
}, /*#__PURE__*/_react.default.createElement(_styles.ImageWrapper,
|
|
147
|
+
}, /*#__PURE__*/_react.default.createElement(_styles.ImageWrapper, {
|
|
148
|
+
onClick: function onClick() {
|
|
149
|
+
return handleGoToPage(img === null || img === void 0 ? void 0 : img.action);
|
|
150
|
+
}
|
|
151
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
38
152
|
src: img.url,
|
|
39
153
|
className: "banner-img",
|
|
40
154
|
alt: ""
|
package/package.json
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { useLanguage } from 'ordering-components-external'
|
|
3
2
|
import {
|
|
4
|
-
Card,
|
|
5
3
|
CardWrapper,
|
|
6
4
|
CardsContainer
|
|
7
5
|
} from './styles'
|
|
8
6
|
import { OrdersContainer } from '../OrdersOption/styles'
|
|
9
7
|
|
|
10
|
-
import { Button } from '../../styles/Buttons'
|
|
11
8
|
import { SingleOrderCard } from '../SingleOrderCard'
|
|
12
9
|
import { Pagination } from '../Pagination'
|
|
13
10
|
|
|
14
11
|
export const HorizontalOrdersLayout = (props) => {
|
|
15
12
|
const {
|
|
16
13
|
pagination,
|
|
17
|
-
loadMoreOrders,
|
|
18
14
|
isBusinessesPage,
|
|
19
15
|
customArray,
|
|
20
16
|
businessesIds,
|
|
21
17
|
isCustomerMode,
|
|
22
|
-
isProducts,
|
|
23
|
-
isBusiness,
|
|
24
18
|
handleChangePage
|
|
25
19
|
} = props
|
|
26
20
|
|
|
27
21
|
const orders = customArray || props.orders
|
|
28
22
|
|
|
29
|
-
const [, t] = useLanguage()
|
|
30
|
-
|
|
31
23
|
const ordersToShow = businessesIds && isCustomerMode
|
|
32
24
|
? orders.filter(order =>
|
|
33
25
|
businessesIds?.includes(order?.business_id))
|
|
@@ -37,74 +29,33 @@ export const HorizontalOrdersLayout = (props) => {
|
|
|
37
29
|
JSON.stringify(businessesIds.sort((a, b) => a - b)) === JSON.stringify(order?.business?.map(business => business?.id).sort((a, b) => a - b)))
|
|
38
30
|
: orders
|
|
39
31
|
|
|
40
|
-
const notOrders = isProducts || isBusiness
|
|
41
|
-
|
|
42
|
-
const Orders = () => {
|
|
43
|
-
return (
|
|
44
|
-
<>
|
|
45
|
-
{props.beforeElements?.map((BeforeElement, i) => (
|
|
46
|
-
<React.Fragment key={i}>
|
|
47
|
-
{BeforeElement}
|
|
48
|
-
</React.Fragment>))}
|
|
49
|
-
{props.beforeComponents?.map((BeforeComponent, i) => (
|
|
50
|
-
<BeforeComponent key={i} {...props} />))}
|
|
51
|
-
{orders.length > 0 && !notOrders && ordersToShow.map(order => (
|
|
52
|
-
<SingleOrderCard
|
|
53
|
-
{...props}
|
|
54
|
-
key={order.id}
|
|
55
|
-
order={order}
|
|
56
|
-
/>
|
|
57
|
-
))}
|
|
58
|
-
{pagination?.totalPages && !notOrders && pagination?.currentPage < pagination?.totalPages && !notOrders && (
|
|
59
|
-
<Card
|
|
60
|
-
flex
|
|
61
|
-
nobg
|
|
62
|
-
isBusinessesPage={isBusinessesPage}
|
|
63
|
-
isCustomerMode={isCustomerMode}
|
|
64
|
-
>
|
|
65
|
-
<Button
|
|
66
|
-
className='load-orders'
|
|
67
|
-
color='primary'
|
|
68
|
-
outline
|
|
69
|
-
onClick={loadMoreOrders}
|
|
70
|
-
>
|
|
71
|
-
{t('LOAD_MORE_ORDERS', 'Load more orders')}
|
|
72
|
-
</Button>
|
|
73
|
-
</Card>
|
|
74
|
-
)}
|
|
75
|
-
{props.afterComponents?.map((AfterComponent, i) => (
|
|
76
|
-
<AfterComponent key={i} {...props} />))}
|
|
77
|
-
{props.afterElements?.map((AfterElement, i) => (
|
|
78
|
-
<React.Fragment key={i}>
|
|
79
|
-
{AfterElement}
|
|
80
|
-
</React.Fragment>))}
|
|
81
|
-
</>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
32
|
return (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
33
|
+
orders.length > 0 && ordersToShow.length > 0 ? (
|
|
34
|
+
<OrdersContainer
|
|
35
|
+
id='orders-container'
|
|
36
|
+
activeOrders
|
|
37
|
+
ordersLength={orders?.length <= 1}
|
|
38
|
+
isBusinessesPage={isBusinessesPage}
|
|
39
|
+
>
|
|
40
|
+
<CardWrapper>
|
|
41
|
+
<CardsContainer>
|
|
42
|
+
{orders.length > 0 && ordersToShow.map((order, i) => (
|
|
43
|
+
<SingleOrderCard
|
|
44
|
+
{...props}
|
|
45
|
+
key={order.id || order.id?.[0] || i}
|
|
46
|
+
order={order}
|
|
47
|
+
/>
|
|
48
|
+
))}
|
|
49
|
+
</CardsContainer>
|
|
50
|
+
{orders.length > 0 && ordersToShow.length > 0 && (
|
|
51
|
+
<Pagination
|
|
52
|
+
currentPage={pagination.currentPage}
|
|
53
|
+
totalPages={Math.ceil(pagination?.totalPages)}
|
|
54
|
+
handleChangePage={handleChangePage}
|
|
99
55
|
/>
|
|
100
|
-
)
|
|
101
|
-
</
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
totalPages={Math.ceil(pagination?.totalPages)}
|
|
105
|
-
handleChangePage={handleChangePage}
|
|
106
|
-
/>
|
|
107
|
-
</CardWrapper>
|
|
108
|
-
</OrdersContainer>
|
|
56
|
+
)}
|
|
57
|
+
</CardWrapper>
|
|
58
|
+
</OrdersContainer>
|
|
59
|
+
) : null
|
|
109
60
|
)
|
|
110
61
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useSite,
|
|
4
|
+
useEvent,
|
|
5
|
+
PageBanner as PageBannerController
|
|
6
|
+
} from 'ordering-components-external'
|
|
3
7
|
import Skeleton from 'react-loading-skeleton'
|
|
4
8
|
import { Swiper, SwiperSlide } from 'swiper/react'
|
|
5
9
|
import SwiperCore, {
|
|
@@ -7,6 +11,7 @@ import SwiperCore, {
|
|
|
7
11
|
} from 'swiper'
|
|
8
12
|
import 'swiper/swiper-bundle.min.css'
|
|
9
13
|
import 'swiper/swiper.min.css'
|
|
14
|
+
import { checkSiteUrl } from '../../../../../utils'
|
|
10
15
|
|
|
11
16
|
import {
|
|
12
17
|
BannerContainer,
|
|
@@ -20,6 +25,89 @@ const PageBannerUI = (props) => {
|
|
|
20
25
|
pageBannerState
|
|
21
26
|
} = props
|
|
22
27
|
|
|
28
|
+
const [{ site }] = useSite()
|
|
29
|
+
const [events] = useEvent()
|
|
30
|
+
|
|
31
|
+
const businessUrlTemplate = checkSiteUrl(site?.business_url_template, '/store/:business_slug')
|
|
32
|
+
const productUrlTemplate = checkSiteUrl(site?.product_url_template, '/store/:business_slug?category=:category_id&product=:product_id')
|
|
33
|
+
|
|
34
|
+
const onProductRedirect = ({ slug, category, product }) => {
|
|
35
|
+
if (!category && !product) {
|
|
36
|
+
if (businessUrlTemplate === '/store/:business_slug' || businessUrlTemplate === '/:business_slug') {
|
|
37
|
+
return events.emit('go_to_page', { page: 'business', params: { business_slug: slug }, replace: true })
|
|
38
|
+
} else {
|
|
39
|
+
return events.emit('go_to_page', { page: 'business', search: `?${businessUrlTemplate.split('?')[1].replace(':business_slug', '')}${slug}`, replace: true })
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
events.emit('product_banner_clicked')
|
|
43
|
+
if (productUrlTemplate === '/store/:business_slug/:category_slug/:product_slug' || productUrlTemplate === '/:business_slug/:category_slug/:product_slug') {
|
|
44
|
+
return events.emit('go_to_page', {
|
|
45
|
+
page: 'product',
|
|
46
|
+
params: {
|
|
47
|
+
business_slug: slug,
|
|
48
|
+
category_slug: category,
|
|
49
|
+
product_slug: product
|
|
50
|
+
},
|
|
51
|
+
replace: true
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
if (productUrlTemplate.includes('/store/:category_slug/:product_slug')) {
|
|
55
|
+
const businessParameter = businessUrlTemplate.replace('/store?', '').replace('=:business_slug', '')
|
|
56
|
+
return events.emit('go_to_page', {
|
|
57
|
+
page: 'product',
|
|
58
|
+
params: {
|
|
59
|
+
category_slug: category,
|
|
60
|
+
product_slug: product
|
|
61
|
+
},
|
|
62
|
+
search: `?${businessParameter}=${slug}`,
|
|
63
|
+
replace: true
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
if (productUrlTemplate.includes('/store/:business_slug') && productUrlTemplate.includes('category_id')) {
|
|
67
|
+
const ids = productUrlTemplate.split('?')[1].split('&')
|
|
68
|
+
const categoryParameter = ids[0].replace('=:category_id', '')
|
|
69
|
+
const productParameter = ids[1].replace('=:product_id', '')
|
|
70
|
+
return events.emit('go_to_page', {
|
|
71
|
+
page: 'product',
|
|
72
|
+
params: {
|
|
73
|
+
business_slug: slug
|
|
74
|
+
},
|
|
75
|
+
search: `?${categoryParameter}=${category}&${productParameter}=${product}`,
|
|
76
|
+
replace: true
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
if (productUrlTemplate.includes('/:business_slug') && !productUrlTemplate.includes('store')) {
|
|
80
|
+
const ids = productUrlTemplate.split('?')[1].split('&')
|
|
81
|
+
const categoryParameter = ids[0].replace('=:category_id', '')
|
|
82
|
+
const productParameter = ids[1].replace('=:product_id', '')
|
|
83
|
+
return events.emit('go_to_page', {
|
|
84
|
+
page: 'product',
|
|
85
|
+
params: {
|
|
86
|
+
business_slug: slug
|
|
87
|
+
},
|
|
88
|
+
search: `?${categoryParameter}=${category}&${productParameter}=${product}`,
|
|
89
|
+
replace: true
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const handleGoToPage = (action) => {
|
|
95
|
+
if (!action?.url) return
|
|
96
|
+
let slug
|
|
97
|
+
if (action.type === 'business') {
|
|
98
|
+
slug = action.url.split('store/')[1]
|
|
99
|
+
onProductRedirect({ slug })
|
|
100
|
+
}
|
|
101
|
+
if (action.type === 'product') {
|
|
102
|
+
slug = action.url.split('store/')[1]?.split('?')[0]
|
|
103
|
+
const paramString = action.url.split('?')[1]
|
|
104
|
+
const urlParams = new URLSearchParams(paramString)
|
|
105
|
+
const product = urlParams.get('product')
|
|
106
|
+
const category = urlParams.get('category')
|
|
107
|
+
onProductRedirect({ slug, category, product })
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
23
111
|
return (
|
|
24
112
|
<>
|
|
25
113
|
{pageBannerState.loading ? (
|
|
@@ -27,7 +115,7 @@ const PageBannerUI = (props) => {
|
|
|
27
115
|
<Skeleton height={250} />
|
|
28
116
|
</BannerContainer>
|
|
29
117
|
) : (
|
|
30
|
-
pageBannerState.banner?.items && (
|
|
118
|
+
pageBannerState.banner?.items?.length > 0 && (
|
|
31
119
|
<BannerContainer>
|
|
32
120
|
<Swiper
|
|
33
121
|
navigation
|
|
@@ -35,8 +123,12 @@ const PageBannerUI = (props) => {
|
|
|
35
123
|
loop={pageBannerState.banner?.items.length > 1}
|
|
36
124
|
>
|
|
37
125
|
{pageBannerState.banner?.items.map((img, i) => (
|
|
38
|
-
<SwiperSlide
|
|
39
|
-
|
|
126
|
+
<SwiperSlide
|
|
127
|
+
key={i}
|
|
128
|
+
>
|
|
129
|
+
<ImageWrapper
|
|
130
|
+
onClick={() => handleGoToPage(img?.action)}
|
|
131
|
+
>
|
|
40
132
|
<img src={img.url} className='banner-img' alt='' />
|
|
41
133
|
</ImageWrapper>
|
|
42
134
|
</SwiperSlide>
|