ordering-ui-external 1.9.5 → 1.9.6
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/BusinessesListing/layouts/OriginalBusinessesListing/OrdersSection/index.js +60 -0
- package/_modules/themes/five/src/components/OrdersOption/index.js +26 -97
- package/package.json +1 -1
- package/src/themes/five/src/components/BusinessesListing/layouts/OriginalBusinessesListing/OrdersSection/index.js +52 -0
- package/src/themes/five/src/components/OrdersOption/index.js +14 -48
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OrdersSection = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _OrdersOption = require("../../../../OrdersOption");
|
|
9
|
+
var _orderingComponentsExternal = require("ordering-components-external");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
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."); }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
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; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
var OrdersSection = function OrdersSection(props) {
|
|
18
|
+
var _getCustomArray;
|
|
19
|
+
var titleContent = props.titleContent,
|
|
20
|
+
onRedirectPage = props.onRedirectPage,
|
|
21
|
+
businessesIds = props.businessesIds,
|
|
22
|
+
getCustomArray = props.getCustomArray,
|
|
23
|
+
businessesList = props.businessesList,
|
|
24
|
+
isCustomerMode = props.isCustomerMode,
|
|
25
|
+
userCustomer = props.userCustomer;
|
|
26
|
+
var _useOrder = (0, _orderingComponentsExternal.useOrder)(),
|
|
27
|
+
_useOrder2 = _slicedToArray(_useOrder, 1),
|
|
28
|
+
orderState = _useOrder2[0];
|
|
29
|
+
var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
|
|
30
|
+
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
31
|
+
t = _useLanguage2[1];
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, onRedirectPage && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_OrdersOption.OrdersOption, {
|
|
33
|
+
horizontal: true,
|
|
34
|
+
isBusinessesPage: true,
|
|
35
|
+
onRedirectPage: onRedirectPage,
|
|
36
|
+
titleContent: t('CARTS', 'Carts'),
|
|
37
|
+
businessesIds: businessesIds,
|
|
38
|
+
customArray: (_getCustomArray = getCustomArray(orderState.carts)) === null || _getCustomArray === void 0 ? void 0 : _getCustomArray.filter(function (cart) {
|
|
39
|
+
return cart.products.length > 0;
|
|
40
|
+
}),
|
|
41
|
+
isCustomLayout: true,
|
|
42
|
+
isBusinessesLoading: businessesList.loading,
|
|
43
|
+
isCustomerMode: isCustomerMode,
|
|
44
|
+
franchiseId: props.franchiseId
|
|
45
|
+
}), /*#__PURE__*/_react.default.createElement(_OrdersOption.OrdersOption, {
|
|
46
|
+
pastOrders: true,
|
|
47
|
+
horizontal: true,
|
|
48
|
+
asDashboard: true,
|
|
49
|
+
isBusinessesPage: true,
|
|
50
|
+
businessesIds: businessesIds,
|
|
51
|
+
onRedirectPage: onRedirectPage,
|
|
52
|
+
userCustomerId: userCustomer === null || userCustomer === void 0 ? void 0 : userCustomer.id,
|
|
53
|
+
isCustomLayout: true,
|
|
54
|
+
titleContent: titleContent,
|
|
55
|
+
isBusinessesLoading: businessesList.loading,
|
|
56
|
+
isCustomerMode: isCustomerMode,
|
|
57
|
+
franchiseId: props.franchiseId
|
|
58
|
+
})));
|
|
59
|
+
};
|
|
60
|
+
exports.OrdersSection = OrdersSection;
|
|
@@ -11,7 +11,6 @@ var _moment3 = _interopRequireDefault(require("moment"));
|
|
|
11
11
|
var _orderingComponentsExternal = require("ordering-components-external");
|
|
12
12
|
var _HorizontalOrdersLayout = require("../HorizontalOrdersLayout");
|
|
13
13
|
var _VerticalOrdersLayout = require("../../../../../components/VerticalOrdersLayout");
|
|
14
|
-
var _styledComponents = require("styled-components");
|
|
15
14
|
var _styles = require("./styles");
|
|
16
15
|
var _PreviousBusinessOrdered = require("./PreviousBusinessOrdered");
|
|
17
16
|
var _PreviousProductsOrdered = require("./PreviousProductsOrdered");
|
|
@@ -20,6 +19,7 @@ var _SingleProductCard = require("../SingleProductCard");
|
|
|
20
19
|
var _useWindowSize2 = require("../../../../../hooks/useWindowSize");
|
|
21
20
|
var _Confirm = require("../Confirm");
|
|
22
21
|
var _PreviousProfessionalOrdered = require("./PreviousProfessionalOrdered");
|
|
22
|
+
var _utils = require("../../../../../utils");
|
|
23
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
24
|
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); }
|
|
25
25
|
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; }
|
|
@@ -81,7 +81,6 @@ var OrdersOptionUI = function OrdersOptionUI(props) {
|
|
|
81
81
|
var _useLanguage = (0, _orderingComponentsExternal.useLanguage)(),
|
|
82
82
|
_useLanguage2 = _slicedToArray(_useLanguage, 2),
|
|
83
83
|
t = _useLanguage2[1];
|
|
84
|
-
var theme = (0, _styledComponents.useTheme)();
|
|
85
84
|
var _useOrder = (0, _orderingComponentsExternal.useOrder)(),
|
|
86
85
|
_useOrder2 = _slicedToArray(_useOrder, 1),
|
|
87
86
|
carts = _useOrder2[0].carts;
|
|
@@ -96,20 +95,31 @@ var OrdersOptionUI = function OrdersOptionUI(props) {
|
|
|
96
95
|
var _orders = customArray || values || [];
|
|
97
96
|
var uniqueOrders = [];
|
|
98
97
|
var ordersReduced = _orders.map(function (order) {
|
|
99
|
-
|
|
100
|
-
return order !== null && order !== void 0 && order.cart_group_id ? (_orders$filter = _orders.filter(function (_order) {
|
|
98
|
+
return order !== null && order !== void 0 && order.cart_group_id ? _orders.filter(function (_order) {
|
|
101
99
|
return (_order === null || _order === void 0 ? void 0 : _order.cart_group_id) === (order === null || order === void 0 ? void 0 : order.cart_group_id);
|
|
102
|
-
})
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
}).map(function (_o, _, _ordersList) {
|
|
101
|
+
var obj = _objectSpread(_objectSpread({}, _o), {}, {
|
|
102
|
+
id: _ordersList.map(function (o) {
|
|
103
|
+
return o.id;
|
|
104
|
+
}),
|
|
105
|
+
review: _o.review,
|
|
106
|
+
user_review: _o.user_review,
|
|
107
|
+
total: _ordersList.reduce(function (acc, o) {
|
|
108
|
+
return acc + o.summary.total;
|
|
109
|
+
}, 0),
|
|
110
|
+
business: _ordersList.map(function (o) {
|
|
111
|
+
return o.business;
|
|
112
|
+
}),
|
|
113
|
+
business_id: _ordersList.map(function (o) {
|
|
114
|
+
return o.business_id;
|
|
115
|
+
}),
|
|
116
|
+
products: _ordersList.map(function (o) {
|
|
117
|
+
return o.products;
|
|
118
|
+
})
|
|
112
119
|
});
|
|
120
|
+
return obj;
|
|
121
|
+
}).find(function (o) {
|
|
122
|
+
return o;
|
|
113
123
|
}) : order;
|
|
114
124
|
});
|
|
115
125
|
var orders = ordersReduced === null || ordersReduced === void 0 ? void 0 : ordersReduced.filter(function (order) {
|
|
@@ -155,87 +165,6 @@ var OrdersOptionUI = function OrdersOptionUI(props) {
|
|
|
155
165
|
getPage(page);
|
|
156
166
|
};
|
|
157
167
|
var showSkeletons = !isBusiness && !isProducts && loading || (businesses === null || businesses === void 0 ? void 0 : businesses.loading) && isBusiness || (products === null || products === void 0 ? void 0 : products.length) === 0 && isProducts && (!businessesSearchList && loading || (businessesSearchList === null || businessesSearchList === void 0 ? void 0 : businessesSearchList.loading));
|
|
158
|
-
var getOrderStatus = function getOrderStatus(s) {
|
|
159
|
-
var _theme$defaultLanguag, _theme$defaultLanguag2, _theme$defaultLanguag3, _theme$defaultLanguag4, _theme$defaultLanguag5, _theme$defaultLanguag6, _theme$defaultLanguag7, _theme$defaultLanguag8, _theme$defaultLanguag9, _theme$defaultLanguag10, _theme$defaultLanguag11, _theme$defaultLanguag12, _theme$defaultLanguag13, _theme$defaultLanguag14, _theme$defaultLanguag15, _theme$defaultLanguag16, _theme$defaultLanguag17, _theme$defaultLanguag18, _theme$defaultLanguag19, _theme$defaultLanguag20, _theme$defaultLanguag21, _theme$defaultLanguag22, _theme$defaultLanguag23, _theme$defaultLanguag24;
|
|
160
|
-
var status = parseInt(s);
|
|
161
|
-
var orderStatus = [{
|
|
162
|
-
key: 0,
|
|
163
|
-
value: t('PENDING', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag = theme.defaultLanguages) === null || _theme$defaultLanguag === void 0 ? void 0 : _theme$defaultLanguag.PENDING) || 'Pending')
|
|
164
|
-
}, {
|
|
165
|
-
key: 1,
|
|
166
|
-
value: t('COMPLETED', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag2 = theme.defaultLanguages) === null || _theme$defaultLanguag2 === void 0 ? void 0 : _theme$defaultLanguag2.COMPLETED) || 'Completed')
|
|
167
|
-
}, {
|
|
168
|
-
key: 2,
|
|
169
|
-
value: t('REJECTED', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag3 = theme.defaultLanguages) === null || _theme$defaultLanguag3 === void 0 ? void 0 : _theme$defaultLanguag3.REJECTED) || 'Rejected')
|
|
170
|
-
}, {
|
|
171
|
-
key: 3,
|
|
172
|
-
value: t('DRIVER_IN_BUSINESS', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag4 = theme.defaultLanguages) === null || _theme$defaultLanguag4 === void 0 ? void 0 : _theme$defaultLanguag4.DRIVER_IN_BUSINESS) || 'Driver in business')
|
|
173
|
-
}, {
|
|
174
|
-
key: 4,
|
|
175
|
-
value: t('PREPARATION_COMPLETED', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag5 = theme.defaultLanguages) === null || _theme$defaultLanguag5 === void 0 ? void 0 : _theme$defaultLanguag5.PREPARATION_COMPLETED) || 'Preparation Completed')
|
|
176
|
-
}, {
|
|
177
|
-
key: 5,
|
|
178
|
-
value: t('REJECTED_BY_BUSINESS', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag6 = theme.defaultLanguages) === null || _theme$defaultLanguag6 === void 0 ? void 0 : _theme$defaultLanguag6.REJECTED_BY_BUSINESS) || 'Rejected by business')
|
|
179
|
-
}, {
|
|
180
|
-
key: 6,
|
|
181
|
-
value: t('REJECTED_BY_DRIVER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag7 = theme.defaultLanguages) === null || _theme$defaultLanguag7 === void 0 ? void 0 : _theme$defaultLanguag7.REJECTED_BY_DRIVER) || 'Rejected by Driver')
|
|
182
|
-
}, {
|
|
183
|
-
key: 7,
|
|
184
|
-
value: t('ACCEPTED_BY_BUSINESS', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag8 = theme.defaultLanguages) === null || _theme$defaultLanguag8 === void 0 ? void 0 : _theme$defaultLanguag8.ACCEPTED_BY_BUSINESS) || 'Accepted by business')
|
|
185
|
-
}, {
|
|
186
|
-
key: 8,
|
|
187
|
-
value: t('ACCEPTED_BY_DRIVER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag9 = theme.defaultLanguages) === null || _theme$defaultLanguag9 === void 0 ? void 0 : _theme$defaultLanguag9.ACCEPTED_BY_DRIVER) || 'Accepted by driver')
|
|
188
|
-
}, {
|
|
189
|
-
key: 9,
|
|
190
|
-
value: t('PICK_UP_COMPLETED_BY_DRIVER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag10 = theme.defaultLanguages) === null || _theme$defaultLanguag10 === void 0 ? void 0 : _theme$defaultLanguag10.PICK_UP_COMPLETED_BY_DRIVER) || 'Pick up completed by driver')
|
|
191
|
-
}, {
|
|
192
|
-
key: 10,
|
|
193
|
-
value: t('PICK_UP_FAILED_BY_DRIVER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag11 = theme.defaultLanguages) === null || _theme$defaultLanguag11 === void 0 ? void 0 : _theme$defaultLanguag11.PICK_UP_FAILED_BY_DRIVER) || 'Pick up Failed by driver')
|
|
194
|
-
}, {
|
|
195
|
-
key: 11,
|
|
196
|
-
value: t('DELIVERY_COMPLETED_BY_DRIVER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag12 = theme.defaultLanguages) === null || _theme$defaultLanguag12 === void 0 ? void 0 : _theme$defaultLanguag12.DELIVERY_COMPLETED_BY_DRIVER) || 'Delivery completed by driver')
|
|
197
|
-
}, {
|
|
198
|
-
key: 12,
|
|
199
|
-
value: t('DELIVERY_FAILED_BY_DRIVER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag13 = theme.defaultLanguages) === null || _theme$defaultLanguag13 === void 0 ? void 0 : _theme$defaultLanguag13.DELIVERY_FAILED_BY_DRIVER) || 'Delivery Failed by driver')
|
|
200
|
-
}, {
|
|
201
|
-
key: 13,
|
|
202
|
-
value: t('PREORDER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag14 = theme.defaultLanguages) === null || _theme$defaultLanguag14 === void 0 ? void 0 : _theme$defaultLanguag14.PREORDER) || 'PreOrder')
|
|
203
|
-
}, {
|
|
204
|
-
key: 14,
|
|
205
|
-
value: t('ORDER_NOT_READY', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag15 = theme.defaultLanguages) === null || _theme$defaultLanguag15 === void 0 ? void 0 : _theme$defaultLanguag15.ORDER_NOT_READY) || 'Order not ready')
|
|
206
|
-
}, {
|
|
207
|
-
key: 15,
|
|
208
|
-
value: t('ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag16 = theme.defaultLanguages) === null || _theme$defaultLanguag16 === void 0 ? void 0 : _theme$defaultLanguag16.ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER) || 'Order picked up completed by customer')
|
|
209
|
-
}, {
|
|
210
|
-
key: 16,
|
|
211
|
-
value: t('ORDER_STATUS_CANCELLED_BY_CUSTOMER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag17 = theme.defaultLanguages) === null || _theme$defaultLanguag17 === void 0 ? void 0 : _theme$defaultLanguag17.ORDER_STATUS_CANCELLED_BY_CUSTOMER) || 'Order cancelled by customer')
|
|
212
|
-
}, {
|
|
213
|
-
key: 17,
|
|
214
|
-
value: t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag18 = theme.defaultLanguages) === null || _theme$defaultLanguag18 === void 0 ? void 0 : _theme$defaultLanguag18.ORDER_NOT_PICKEDUP_BY_CUSTOMER) || 'Order not picked up by customer')
|
|
215
|
-
}, {
|
|
216
|
-
key: 18,
|
|
217
|
-
value: t('ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag19 = theme.defaultLanguages) === null || _theme$defaultLanguag19 === void 0 ? void 0 : _theme$defaultLanguag19.ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS) || 'Driver almost arrived to business')
|
|
218
|
-
}, {
|
|
219
|
-
key: 19,
|
|
220
|
-
value: t('ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag20 = theme.defaultLanguages) === null || _theme$defaultLanguag20 === void 0 ? void 0 : _theme$defaultLanguag20.ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER) || 'Driver almost arrived to customer')
|
|
221
|
-
}, {
|
|
222
|
-
key: 20,
|
|
223
|
-
value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag21 = theme.defaultLanguages) === null || _theme$defaultLanguag21 === void 0 ? void 0 : _theme$defaultLanguag21.ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS) || 'Customer almost arrived to business')
|
|
224
|
-
}, {
|
|
225
|
-
key: 21,
|
|
226
|
-
value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag22 = theme.defaultLanguages) === null || _theme$defaultLanguag22 === void 0 ? void 0 : _theme$defaultLanguag22.ORDER_CUSTOMER_ARRIVED_BUSINESS) || 'Customer arrived to business')
|
|
227
|
-
}, {
|
|
228
|
-
key: 22,
|
|
229
|
-
value: t('ORDER_LOOKING_FOR_DRIVER', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag23 = theme.defaultLanguages) === null || _theme$defaultLanguag23 === void 0 ? void 0 : _theme$defaultLanguag23.ORDER_LOOKING_FOR_DRIVER) || 'Looking for driver')
|
|
230
|
-
}, {
|
|
231
|
-
key: 23,
|
|
232
|
-
value: t('ORDER_DRIVER_ON_WAY', (theme === null || theme === void 0 ? void 0 : (_theme$defaultLanguag24 = theme.defaultLanguages) === null || _theme$defaultLanguag24 === void 0 ? void 0 : _theme$defaultLanguag24.ORDER_DRIVER_ON_WAY) || 'Driver on way')
|
|
233
|
-
}];
|
|
234
|
-
var objectStatus = orderStatus.find(function (o) {
|
|
235
|
-
return o.key === status;
|
|
236
|
-
});
|
|
237
|
-
return objectStatus && objectStatus;
|
|
238
|
-
};
|
|
239
168
|
var onProductClick = function onProductClick(product, slug) {
|
|
240
169
|
if (slug) {
|
|
241
170
|
onProductRedirect({
|
|
@@ -394,7 +323,7 @@ var OrdersOptionUI = function OrdersOptionUI(props) {
|
|
|
394
323
|
isBusinessesPage: isBusinessesPage,
|
|
395
324
|
reorderLoading: reorderState === null || reorderState === void 0 ? void 0 : reorderState.loading,
|
|
396
325
|
customArray: customArray,
|
|
397
|
-
getOrderStatus: getOrderStatus,
|
|
326
|
+
getOrderStatus: _utils.getOrderStatus,
|
|
398
327
|
handleReorder: handleReorder,
|
|
399
328
|
activeOrders: activeOrders,
|
|
400
329
|
handleUpdateOrderList: handleUpdateOrderList,
|
|
@@ -414,7 +343,7 @@ var OrdersOptionUI = function OrdersOptionUI(props) {
|
|
|
414
343
|
customArray: customArray,
|
|
415
344
|
loadMoreOrders: loadMoreOrders,
|
|
416
345
|
onRedirectPage: onRedirectPage,
|
|
417
|
-
getOrderStatus: getOrderStatus,
|
|
346
|
+
getOrderStatus: _utils.getOrderStatus,
|
|
418
347
|
handleReorder: handleReorder,
|
|
419
348
|
handleUpdateOrderList: handleUpdateOrderList
|
|
420
349
|
})), /*#__PURE__*/_react.default.createElement(_Confirm.Alert, {
|
package/package.json
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { OrdersOption } from '../../../../OrdersOption'
|
|
3
|
+
import { useLanguage, useOrder } from 'ordering-components-external'
|
|
4
|
+
export const OrdersSection = (props) => {
|
|
5
|
+
const {
|
|
6
|
+
titleContent,
|
|
7
|
+
onRedirectPage,
|
|
8
|
+
businessesIds,
|
|
9
|
+
getCustomArray,
|
|
10
|
+
businessesList,
|
|
11
|
+
isCustomerMode,
|
|
12
|
+
userCustomer
|
|
13
|
+
} = props
|
|
14
|
+
const [orderState] = useOrder()
|
|
15
|
+
const [, t] = useLanguage()
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
{onRedirectPage && (
|
|
19
|
+
<>
|
|
20
|
+
<OrdersOption
|
|
21
|
+
horizontal
|
|
22
|
+
isBusinessesPage
|
|
23
|
+
onRedirectPage={onRedirectPage}
|
|
24
|
+
titleContent={t('CARTS', 'Carts')}
|
|
25
|
+
businessesIds={businessesIds}
|
|
26
|
+
customArray={
|
|
27
|
+
getCustomArray(orderState.carts)?.filter(cart => cart.products.length > 0)
|
|
28
|
+
}
|
|
29
|
+
isCustomLayout
|
|
30
|
+
isBusinessesLoading={businessesList.loading}
|
|
31
|
+
isCustomerMode={isCustomerMode}
|
|
32
|
+
franchiseId={props.franchiseId}
|
|
33
|
+
/>
|
|
34
|
+
<OrdersOption
|
|
35
|
+
pastOrders
|
|
36
|
+
horizontal
|
|
37
|
+
asDashboard
|
|
38
|
+
isBusinessesPage
|
|
39
|
+
businessesIds={businessesIds}
|
|
40
|
+
onRedirectPage={onRedirectPage}
|
|
41
|
+
userCustomerId={userCustomer?.id}
|
|
42
|
+
isCustomLayout
|
|
43
|
+
titleContent={titleContent}
|
|
44
|
+
isBusinessesLoading={businessesList.loading}
|
|
45
|
+
isCustomerMode={isCustomerMode}
|
|
46
|
+
franchiseId={props.franchiseId}
|
|
47
|
+
/>
|
|
48
|
+
</>
|
|
49
|
+
)}
|
|
50
|
+
</>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
@@ -5,8 +5,6 @@ import { useLanguage, useOrder, useEvent, OrderList } from 'ordering-components-
|
|
|
5
5
|
import { HorizontalOrdersLayout } from '../HorizontalOrdersLayout'
|
|
6
6
|
import { VerticalOrdersLayout } from '../../../../../components/VerticalOrdersLayout'
|
|
7
7
|
|
|
8
|
-
import { useTheme } from 'styled-components'
|
|
9
|
-
|
|
10
8
|
import {
|
|
11
9
|
OptionTitle,
|
|
12
10
|
OrdersContainer,
|
|
@@ -27,6 +25,7 @@ import { SingleProductCard } from '../SingleProductCard'
|
|
|
27
25
|
import { useWindowSize } from '../../../../../hooks/useWindowSize'
|
|
28
26
|
import { Alert } from '../Confirm'
|
|
29
27
|
import { PreviousProfessionalOrdered } from './PreviousProfessionalOrdered'
|
|
28
|
+
import { getOrderStatus } from '../../../../../utils'
|
|
30
29
|
|
|
31
30
|
const OrdersOptionUI = (props) => {
|
|
32
31
|
const {
|
|
@@ -70,7 +69,6 @@ const OrdersOptionUI = (props) => {
|
|
|
70
69
|
} = props
|
|
71
70
|
|
|
72
71
|
const [, t] = useLanguage()
|
|
73
|
-
const theme = useTheme()
|
|
74
72
|
const [{ carts }] = useOrder()
|
|
75
73
|
const [events] = useEvent()
|
|
76
74
|
const { width } = useWindowSize()
|
|
@@ -81,16 +79,19 @@ const OrdersOptionUI = (props) => {
|
|
|
81
79
|
const ordersReduced = _orders.map(order => order?.cart_group_id
|
|
82
80
|
? _orders
|
|
83
81
|
.filter(_order => _order?.cart_group_id === order?.cart_group_id)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
.map((_o, _, _ordersList) => {
|
|
83
|
+
const obj = {
|
|
84
|
+
..._o,
|
|
85
|
+
id: _ordersList.map(o => o.id),
|
|
86
|
+
review: _o.review,
|
|
87
|
+
user_review: _o.user_review,
|
|
88
|
+
total: _ordersList.reduce((acc, o) => acc + o.summary.total, 0),
|
|
89
|
+
business: _ordersList.map(o => o.business),
|
|
90
|
+
business_id: _ordersList.map(o => o.business_id),
|
|
91
|
+
products: _ordersList.map(o => o.products)
|
|
92
|
+
}
|
|
93
|
+
return obj
|
|
94
|
+
}).find(o => o)
|
|
94
95
|
: order)
|
|
95
96
|
const orders = ordersReduced?.filter(order => {
|
|
96
97
|
if (!order?.cart_group_id) return true
|
|
@@ -123,41 +124,6 @@ const OrdersOptionUI = (props) => {
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
const showSkeletons = (!isBusiness && !isProducts && loading) || (businesses?.loading && isBusiness) || (products?.length === 0 && isProducts && ((!businessesSearchList && loading) || businessesSearchList?.loading))
|
|
126
|
-
|
|
127
|
-
const getOrderStatus = (s) => {
|
|
128
|
-
const status = parseInt(s)
|
|
129
|
-
const orderStatus = [
|
|
130
|
-
{ key: 0, value: t('PENDING', theme?.defaultLanguages?.PENDING || 'Pending') },
|
|
131
|
-
{ key: 1, value: t('COMPLETED', theme?.defaultLanguages?.COMPLETED || 'Completed') },
|
|
132
|
-
{ key: 2, value: t('REJECTED', theme?.defaultLanguages?.REJECTED || 'Rejected') },
|
|
133
|
-
{ key: 3, value: t('DRIVER_IN_BUSINESS', theme?.defaultLanguages?.DRIVER_IN_BUSINESS || 'Driver in business') },
|
|
134
|
-
{ key: 4, value: t('PREPARATION_COMPLETED', theme?.defaultLanguages?.PREPARATION_COMPLETED || 'Preparation Completed') },
|
|
135
|
-
{ key: 5, value: t('REJECTED_BY_BUSINESS', theme?.defaultLanguages?.REJECTED_BY_BUSINESS || 'Rejected by business') },
|
|
136
|
-
{ key: 6, value: t('REJECTED_BY_DRIVER', theme?.defaultLanguages?.REJECTED_BY_DRIVER || 'Rejected by Driver') },
|
|
137
|
-
{ key: 7, value: t('ACCEPTED_BY_BUSINESS', theme?.defaultLanguages?.ACCEPTED_BY_BUSINESS || 'Accepted by business') },
|
|
138
|
-
{ key: 8, value: t('ACCEPTED_BY_DRIVER', theme?.defaultLanguages?.ACCEPTED_BY_DRIVER || 'Accepted by driver') },
|
|
139
|
-
{ key: 9, value: t('PICK_UP_COMPLETED_BY_DRIVER', theme?.defaultLanguages?.PICK_UP_COMPLETED_BY_DRIVER || 'Pick up completed by driver') },
|
|
140
|
-
{ key: 10, value: t('PICK_UP_FAILED_BY_DRIVER', theme?.defaultLanguages?.PICK_UP_FAILED_BY_DRIVER || 'Pick up Failed by driver') },
|
|
141
|
-
{ key: 11, value: t('DELIVERY_COMPLETED_BY_DRIVER', theme?.defaultLanguages?.DELIVERY_COMPLETED_BY_DRIVER || 'Delivery completed by driver') },
|
|
142
|
-
{ key: 12, value: t('DELIVERY_FAILED_BY_DRIVER', theme?.defaultLanguages?.DELIVERY_FAILED_BY_DRIVER || 'Delivery Failed by driver') },
|
|
143
|
-
{ key: 13, value: t('PREORDER', theme?.defaultLanguages?.PREORDER || 'PreOrder') },
|
|
144
|
-
{ key: 14, value: t('ORDER_NOT_READY', theme?.defaultLanguages?.ORDER_NOT_READY || 'Order not ready') },
|
|
145
|
-
{ key: 15, value: t('ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_PICKEDUP_COMPLETED_BY_CUSTOMER || 'Order picked up completed by customer') },
|
|
146
|
-
{ key: 16, value: t('ORDER_STATUS_CANCELLED_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_STATUS_CANCELLED_BY_CUSTOMER || 'Order cancelled by customer') },
|
|
147
|
-
{ key: 17, value: t('ORDER_NOT_PICKEDUP_BY_CUSTOMER', theme?.defaultLanguages?.ORDER_NOT_PICKEDUP_BY_CUSTOMER || 'Order not picked up by customer') },
|
|
148
|
-
{ key: 18, value: t('ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_DRIVER_ALMOST_ARRIVED_BUSINESS || 'Driver almost arrived to business') },
|
|
149
|
-
{ key: 19, value: t('ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER', theme?.defaultLanguages?.ORDER_DRIVER_ALMOST_ARRIVED_CUSTOMER || 'Driver almost arrived to customer') },
|
|
150
|
-
{ key: 20, value: t('ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ALMOST_ARRIVED_BUSINESS || 'Customer almost arrived to business') },
|
|
151
|
-
{ key: 21, value: t('ORDER_CUSTOMER_ARRIVED_BUSINESS', theme?.defaultLanguages?.ORDER_CUSTOMER_ARRIVED_BUSINESS || 'Customer arrived to business') },
|
|
152
|
-
{ key: 22, value: t('ORDER_LOOKING_FOR_DRIVER', theme?.defaultLanguages?.ORDER_LOOKING_FOR_DRIVER || 'Looking for driver') },
|
|
153
|
-
{ key: 23, value: t('ORDER_DRIVER_ON_WAY', theme?.defaultLanguages?.ORDER_DRIVER_ON_WAY || 'Driver on way') }
|
|
154
|
-
]
|
|
155
|
-
|
|
156
|
-
const objectStatus = orderStatus.find((o) => o.key === status)
|
|
157
|
-
|
|
158
|
-
return objectStatus && objectStatus
|
|
159
|
-
}
|
|
160
|
-
|
|
161
127
|
const onProductClick = (product, slug) => {
|
|
162
128
|
if (slug) {
|
|
163
129
|
onProductRedirect({
|