ordering-components-external 13.2.8 → 13.2.9

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 (14) hide show
  1. package/_bundles/{7.ordering-component.f315afd771830efc8429.js → 7.ordering-component.1a6a3f1c214a7e7ab0a1.js} +1 -1
  2. package/_bundles/{ordering-component.f315afd771830efc8429.js → ordering-component.1a6a3f1c214a7e7ab0a1.js} +2 -2
  3. package/_modules/components/MapView/index.js +31 -18
  4. package/package.json +1 -1
  5. package/src/components/MapView/index.js +27 -21
  6. /package/_bundles/{0.ordering-component.f315afd771830efc8429.js → 0.ordering-component.1a6a3f1c214a7e7ab0a1.js} +0 -0
  7. /package/_bundles/{1.ordering-component.f315afd771830efc8429.js → 1.ordering-component.1a6a3f1c214a7e7ab0a1.js} +0 -0
  8. /package/_bundles/{2.ordering-component.f315afd771830efc8429.js → 2.ordering-component.1a6a3f1c214a7e7ab0a1.js} +0 -0
  9. /package/_bundles/{4.ordering-component.f315afd771830efc8429.js → 4.ordering-component.1a6a3f1c214a7e7ab0a1.js} +0 -0
  10. /package/_bundles/{5.ordering-component.f315afd771830efc8429.js → 5.ordering-component.1a6a3f1c214a7e7ab0a1.js} +0 -0
  11. /package/_bundles/{6.ordering-component.f315afd771830efc8429.js → 6.ordering-component.1a6a3f1c214a7e7ab0a1.js} +0 -0
  12. /package/_bundles/{7.ordering-component.f315afd771830efc8429.js.LICENSE.txt → 7.ordering-component.1a6a3f1c214a7e7ab0a1.js.LICENSE.txt} +0 -0
  13. /package/_bundles/{8.ordering-component.f315afd771830efc8429.js → 8.ordering-component.1a6a3f1c214a7e7ab0a1.js} +0 -0
  14. /package/_bundles/{ordering-component.f315afd771830efc8429.js.LICENSE.txt → ordering-component.1a6a3f1c214a7e7ab0a1.js.LICENSE.txt} +0 -0
@@ -62,12 +62,11 @@ var MapView = exports.MapView = function MapView(props) {
62
62
  setAlertState = _useState10[1];
63
63
  var getBusinessLocations = /*#__PURE__*/function () {
64
64
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
65
- var markerGroupsObject, customerMarkerGroupsObject, options, _yield$ordering$setAc, _yield$ordering$setAc2, result, error;
65
+ var options, _yield$ordering$setAc, _yield$ordering$setAc2, result, error, markerGroupsObject, customerMarkerGroupsObject;
66
66
  return _regeneratorRuntime().wrap(function _callee$(_context) {
67
67
  while (1) switch (_context.prev = _context.next) {
68
68
  case 0:
69
- markerGroupsObject = {};
70
- customerMarkerGroupsObject = {};
69
+ _context.prev = 0;
71
70
  setIsLoadingBusinessMakers(true);
72
71
  options = {
73
72
  query: {
@@ -77,31 +76,45 @@ var MapView = exports.MapView = function MapView(props) {
77
76
  }]
78
77
  }
79
78
  };
80
- _context.next = 6;
79
+ _context.next = 5;
81
80
  return ordering.setAccessToken(session.token).orders().asDashboard().get(options);
82
- case 6:
81
+ case 5:
83
82
  _yield$ordering$setAc = _context.sent;
84
83
  _yield$ordering$setAc2 = _yield$ordering$setAc.content;
85
84
  result = _yield$ordering$setAc2.result;
86
85
  error = _yield$ordering$setAc2.error;
87
- if (!error) {
88
- result.map(function (order) {
89
- markerGroupsObject[order === null || order === void 0 ? void 0 : order.business_id] = markerGroupsObject !== null && markerGroupsObject !== void 0 && markerGroupsObject[order === null || order === void 0 ? void 0 : order.business_id] ? [].concat(_toConsumableArray(markerGroupsObject[order === null || order === void 0 ? void 0 : order.business_id]), [order]) : [order];
90
- customerMarkerGroupsObject[order === null || order === void 0 ? void 0 : order.customer_id] = customerMarkerGroupsObject !== null && customerMarkerGroupsObject !== void 0 && customerMarkerGroupsObject[order === null || order === void 0 ? void 0 : order.customer_id] ? [].concat(_toConsumableArray(customerMarkerGroupsObject[order === null || order === void 0 ? void 0 : order.customer_id]), [order]) : [order];
91
- });
92
- setMarkerGroups(markerGroupsObject);
93
- setCustomerMarkerGroups(customerMarkerGroupsObject);
94
- setIsLoadingBusinessMakers(false);
95
- setBusinessMarkers(result);
96
- } else {
86
+ if (error) {
97
87
  setAlertState(result);
98
- setIsLoadingBusinessMakers(false);
99
88
  }
100
- case 11:
89
+ markerGroupsObject = result.reduce(function (acc, order) {
90
+ acc[order.business_id] = acc[order.business_id] ? [].concat(_toConsumableArray(acc[order.business_id]), [order]) : [order];
91
+ return acc;
92
+ }, {});
93
+ customerMarkerGroupsObject = result.reduce(function (acc, order) {
94
+ acc[order.customer_id] = acc[order.customer_id] ? [].concat(_toConsumableArray(acc[order.customer_id]), [order]) : [order];
95
+ return acc;
96
+ }, {});
97
+ setMarkerGroups(markerGroupsObject);
98
+ setCustomerMarkerGroups(customerMarkerGroupsObject);
99
+ setBusinessMarkers(result);
100
+ _context.next = 20;
101
+ break;
102
+ case 17:
103
+ _context.prev = 17;
104
+ _context.t0 = _context["catch"](0);
105
+ setAlertState({
106
+ open: true,
107
+ content: [_context.t0.message]
108
+ });
109
+ case 20:
110
+ _context.prev = 20;
111
+ setIsLoadingBusinessMakers(false);
112
+ return _context.finish(20);
113
+ case 23:
101
114
  case "end":
102
115
  return _context.stop();
103
116
  }
104
- }, _callee);
117
+ }, _callee, null, [[0, 17, 20, 23]]);
105
118
  }));
106
119
  return function getBusinessLocations() {
107
120
  return _ref.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-components-external",
3
- "version": "13.2.8",
3
+ "version": "13.2.9",
4
4
  "description": "Ordering Internal Dashboard",
5
5
  "main": "./_modules/index.js",
6
6
  "scripts": {
@@ -16,31 +16,37 @@ export const MapView = (props) => {
16
16
  const [alertState, setAlertState] = useState({ open: false, content: [], key: null })
17
17
 
18
18
  const getBusinessLocations = async () => {
19
- const markerGroupsObject = {}
20
- const customerMarkerGroupsObject = {}
21
- setIsLoadingBusinessMakers(true)
22
- const options = {
23
- query: {
24
- where: [
25
- {
26
- attribute: 'status',
27
- value: [0, 13, 7, 4, 3, 8, 9, 14, 18, 19, 20, 21, 23, 26]
28
- }
29
- ]
19
+ try {
20
+ setIsLoadingBusinessMakers(true)
21
+ const options = {
22
+ query: {
23
+ where: [
24
+ {
25
+ attribute: 'status',
26
+ value: [0, 13, 7, 4, 3, 8, 9, 14, 18, 19, 20, 21, 23, 26]
27
+ }
28
+ ]
29
+ }
30
30
  }
31
- }
32
- const { content: { result, error } } = await ordering.setAccessToken(session.token).orders().asDashboard().get(options)
33
- if (!error) {
34
- result.map(order => {
35
- markerGroupsObject[order?.business_id] = markerGroupsObject?.[order?.business_id] ? [...markerGroupsObject[order?.business_id], order] : [order]
36
- customerMarkerGroupsObject[order?.customer_id] = customerMarkerGroupsObject?.[order?.customer_id] ? [...customerMarkerGroupsObject[order?.customer_id], order] : [order]
37
- })
31
+ const { content: { result, error } } = await ordering.setAccessToken(session.token).orders().asDashboard().get(options)
32
+ if (error) {
33
+ setAlertState(result)
34
+ }
35
+ const markerGroupsObject = result.reduce((acc, order) => {
36
+ acc[order.business_id] = acc[order.business_id] ? [...acc[order.business_id], order] : [order]
37
+ return acc
38
+ }, {})
39
+ const customerMarkerGroupsObject = result.reduce((acc, order) => {
40
+ acc[order.customer_id] = acc[order.customer_id] ? [...acc[order.customer_id], order] : [order]
41
+ return acc
42
+ }, {})
43
+
38
44
  setMarkerGroups(markerGroupsObject)
39
45
  setCustomerMarkerGroups(customerMarkerGroupsObject)
40
- setIsLoadingBusinessMakers(false)
41
46
  setBusinessMarkers(result)
42
- } else {
43
- setAlertState(result)
47
+ } catch (error) {
48
+ setAlertState({ open: true, content: [error.message] })
49
+ } finally {
44
50
  setIsLoadingBusinessMakers(false)
45
51
  }
46
52
  }