ordering-components-external 13.2.14 → 13.2.15
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/_bundles/{7.ordering-component.71fcc1b93f7c954870c3.js → 7.ordering-component.e9db5c24b106074faad6.js} +1 -1
- package/_bundles/{ordering-component.71fcc1b93f7c954870c3.js → ordering-component.e9db5c24b106074faad6.js} +2 -2
- package/_modules/components/OrderListGroups/index.js +60 -54
- package/package.json +1 -1
- package/src/components/OrderListGroups/index.js +63 -52
- /package/_bundles/{0.ordering-component.71fcc1b93f7c954870c3.js → 0.ordering-component.e9db5c24b106074faad6.js} +0 -0
- /package/_bundles/{1.ordering-component.71fcc1b93f7c954870c3.js → 1.ordering-component.e9db5c24b106074faad6.js} +0 -0
- /package/_bundles/{2.ordering-component.71fcc1b93f7c954870c3.js → 2.ordering-component.e9db5c24b106074faad6.js} +0 -0
- /package/_bundles/{4.ordering-component.71fcc1b93f7c954870c3.js → 4.ordering-component.e9db5c24b106074faad6.js} +0 -0
- /package/_bundles/{5.ordering-component.71fcc1b93f7c954870c3.js → 5.ordering-component.e9db5c24b106074faad6.js} +0 -0
- /package/_bundles/{6.ordering-component.71fcc1b93f7c954870c3.js → 6.ordering-component.e9db5c24b106074faad6.js} +0 -0
- /package/_bundles/{7.ordering-component.71fcc1b93f7c954870c3.js.LICENSE.txt → 7.ordering-component.e9db5c24b106074faad6.js.LICENSE.txt} +0 -0
- /package/_bundles/{8.ordering-component.71fcc1b93f7c954870c3.js → 8.ordering-component.e9db5c24b106074faad6.js} +0 -0
- /package/_bundles/{ordering-component.71fcc1b93f7c954870c3.js.LICENSE.txt → ordering-component.e9db5c24b106074faad6.js.LICENSE.txt} +0 -0
|
@@ -40,7 +40,6 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
40
40
|
var UIComponent = props.UIComponent,
|
|
41
41
|
orderBy = props.orderBy,
|
|
42
42
|
isIos = props.isIos,
|
|
43
|
-
useDefualtSessionManager = props.useDefualtSessionManager,
|
|
44
43
|
paginationSettings = props.paginationSettings,
|
|
45
44
|
asDashboard = props.asDashboard,
|
|
46
45
|
orderGroupStatusCustom = props.orderGroupStatusCustom,
|
|
@@ -199,8 +198,20 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
199
198
|
_useState28 = _slicedToArray(_useState27, 2),
|
|
200
199
|
ordersFiltered = _useState28[0],
|
|
201
200
|
setOrdersFiltered = _useState28[1];
|
|
202
|
-
var accessToken = useDefualtSessionManager ? session.token : props.accessToken;
|
|
203
201
|
var requestsState = {};
|
|
202
|
+
var handleSelectCurrentTab = function handleSelectCurrentTab(value) {
|
|
203
|
+
if (!isDriverApp) {
|
|
204
|
+
setOrdersGroup(_objectSpread(_objectSpread({}, ordersGroup), {}, _defineProperty({}, value, _objectSpread(_objectSpread({}, ordersGroup[value]), {}, {
|
|
205
|
+
loading: true
|
|
206
|
+
}))));
|
|
207
|
+
}
|
|
208
|
+
if (value === 'logisticOrders') {
|
|
209
|
+
setlogisticOrders(_objectSpread(_objectSpread({}, logisticOrders), {}, {
|
|
210
|
+
loading: true
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
setCurrentTabSelected(value);
|
|
214
|
+
};
|
|
204
215
|
var getOrders = /*#__PURE__*/function () {
|
|
205
216
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
206
217
|
var _filtered$customer, _filtered$customer2, _filtered$date, _filtered$date3;
|
|
@@ -375,7 +386,7 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
375
386
|
source = {};
|
|
376
387
|
requestsState.orders = source;
|
|
377
388
|
options.cancelToken = source;
|
|
378
|
-
functionFetch = asDashboard ? ordering.setAccessToken(
|
|
389
|
+
functionFetch = asDashboard ? ordering.setAccessToken(session.token).orders().asDashboard() : ordering.setAccessToken(session.token).orders();
|
|
379
390
|
_context.next = 29;
|
|
380
391
|
return functionFetch.get(options);
|
|
381
392
|
case 29:
|
|
@@ -401,7 +412,7 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
401
412
|
loading: true
|
|
402
413
|
}));
|
|
403
414
|
_context2.next = 4;
|
|
404
|
-
return ordering.setAccessToken(
|
|
415
|
+
return ordering.setAccessToken(session.token).controls().get();
|
|
405
416
|
case 4:
|
|
406
417
|
_yield$ordering$setAc = _context2.sent;
|
|
407
418
|
_yield$ordering$setAc2 = _yield$ordering$setAc.content;
|
|
@@ -680,7 +691,7 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
680
691
|
method: 'GET',
|
|
681
692
|
headers: {
|
|
682
693
|
'Content-Type': 'application/json',
|
|
683
|
-
Authorization: "Bearer ".concat(
|
|
694
|
+
Authorization: "Bearer ".concat(session.token),
|
|
684
695
|
'X-App-X': ordering.appId,
|
|
685
696
|
'X-Socket-Id-X': socket === null || socket === void 0 ? void 0 : socket.getId()
|
|
686
697
|
}
|
|
@@ -740,7 +751,7 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
740
751
|
break;
|
|
741
752
|
}
|
|
742
753
|
_context6.next = 6;
|
|
743
|
-
return ordering.setAccessToken(
|
|
754
|
+
return ordering.setAccessToken(session.token).orders(orderIds[0]).delete();
|
|
744
755
|
case 6:
|
|
745
756
|
_yield$ordering$setAc3 = _context6.sent;
|
|
746
757
|
error = _yield$ordering$setAc3.content.error;
|
|
@@ -765,7 +776,7 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
765
776
|
}
|
|
766
777
|
id = _step.value;
|
|
767
778
|
_context6.next = 19;
|
|
768
|
-
return ordering.setAccessToken(
|
|
779
|
+
return ordering.setAccessToken(session.token).orders(id).delete();
|
|
769
780
|
case 19:
|
|
770
781
|
_yield$ordering$setAc4 = _context6.sent;
|
|
771
782
|
multiError = _yield$ordering$setAc4.content.error;
|
|
@@ -843,7 +854,7 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
843
854
|
method: 'GET',
|
|
844
855
|
headers: {
|
|
845
856
|
'Content-Type': 'application/json',
|
|
846
|
-
Authorization: "Bearer ".concat(
|
|
857
|
+
Authorization: "Bearer ".concat(session.token),
|
|
847
858
|
'X-App-X': ordering.appId,
|
|
848
859
|
'X-Socket-Id-X': socket === null || socket === void 0 ? void 0 : socket.getId()
|
|
849
860
|
}
|
|
@@ -965,40 +976,40 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
965
976
|
return combineTabs ? combinedStatus : status;
|
|
966
977
|
};
|
|
967
978
|
var actionOrderToTab = function actionOrderToTab(orderAux, status, type) {
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
if (type === 'update') {
|
|
975
|
-
var indexToUpdate = orderList.findIndex(function (o) {
|
|
976
|
-
return o.id === order.id;
|
|
977
|
-
});
|
|
978
|
-
orderList[indexToUpdate] = _objectSpread(_objectSpread({}, order), {}, {
|
|
979
|
-
action: type + (order === null || order === void 0 ? void 0 : order.status)
|
|
980
|
-
});
|
|
981
|
-
orders = orderList;
|
|
982
|
-
} else {
|
|
983
|
-
orders = type === 'add' ? [_objectSpread(_objectSpread({}, order), {}, {
|
|
984
|
-
action: type + (order === null || order === void 0 ? void 0 : order.status)
|
|
985
|
-
})].concat(_toConsumableArray(orderList)) : orderList.filter(function (_order) {
|
|
986
|
-
return _order.id !== order.id;
|
|
979
|
+
setOrdersGroup(function (prevState) {
|
|
980
|
+
var _prevState$status, _prevState$status2;
|
|
981
|
+
if (!((_prevState$status = prevState[status]) !== null && _prevState$status !== void 0 && _prevState$status.orders)) return;
|
|
982
|
+
var orderList = (_prevState$status2 = prevState[status]) === null || _prevState$status2 === void 0 ? void 0 : _prevState$status2.orders;
|
|
983
|
+
var order = _objectSpread(_objectSpread({}, orderAux), {}, {
|
|
984
|
+
showNotification: false
|
|
987
985
|
});
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
986
|
+
var updatedOrders;
|
|
987
|
+
switch (type) {
|
|
988
|
+
case 'update':
|
|
989
|
+
updatedOrders = orderList.map(function (o) {
|
|
990
|
+
return o.id === order.id ? _objectSpread(_objectSpread({}, order), {}, {
|
|
991
|
+
action: "".concat(type).concat(order === null || order === void 0 ? void 0 : order.status)
|
|
992
|
+
}) : o;
|
|
993
|
+
});
|
|
994
|
+
break;
|
|
995
|
+
case 'add':
|
|
996
|
+
updatedOrders = [_objectSpread(_objectSpread({}, order), {}, {
|
|
997
|
+
action: "".concat(type).concat(order === null || order === void 0 ? void 0 : order.status)
|
|
998
|
+
})].concat(_toConsumableArray(orderList));
|
|
999
|
+
break;
|
|
1000
|
+
case 'remove':
|
|
1001
|
+
updatedOrders = orderList.filter(function (o) {
|
|
1002
|
+
return o.id !== order.id;
|
|
1003
|
+
});
|
|
1004
|
+
break;
|
|
1005
|
+
}
|
|
1006
|
+
var updatedPagination = _objectSpread(_objectSpread({}, prevState[status].pagination), {}, {
|
|
1007
|
+
total: prevState[status].pagination.total + (type === 'add' ? 1 : type === 'remove' ? -1 : 0)
|
|
993
1008
|
});
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
}, status, _objectSpread(_objectSpread({}, prevState[status]), {}, {
|
|
999
|
-
orders: sortOrders(orders),
|
|
1000
|
-
pagination: _pagination
|
|
1001
|
-
})), "pagination", _pagination));
|
|
1009
|
+
return _objectSpread(_objectSpread({}, prevState), {}, _defineProperty({}, status, _objectSpread(_objectSpread({}, prevState[status]), {}, {
|
|
1010
|
+
orders: filterByIdUnique(sortOrders(updatedOrders), status),
|
|
1011
|
+
pagination: updatedPagination
|
|
1012
|
+
})));
|
|
1002
1013
|
});
|
|
1003
1014
|
};
|
|
1004
1015
|
var handleClickOrder = function handleClickOrder(orderAux) {
|
|
@@ -1008,9 +1019,9 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
1008
1019
|
});
|
|
1009
1020
|
var ordersGroups = order === null || order === void 0 || (_order$order_group2 = order.order_group) === null || _order$order_group2 === void 0 ? void 0 : _order$order_group2.orders;
|
|
1010
1021
|
if (!ordersGroups) {
|
|
1011
|
-
var _ordersGroup$
|
|
1022
|
+
var _ordersGroup$status;
|
|
1012
1023
|
var status = getStatusById(order === null || order === void 0 ? void 0 : order.status);
|
|
1013
|
-
var orderList = (_ordersGroup$
|
|
1024
|
+
var orderList = (_ordersGroup$status = ordersGroup[status]) === null || _ordersGroup$status === void 0 ? void 0 : _ordersGroup$status.orders;
|
|
1014
1025
|
var indexToUpdate = orderList === null || orderList === void 0 ? void 0 : orderList.findIndex(function (o) {
|
|
1015
1026
|
return (o === null || o === void 0 ? void 0 : o.id) === (order === null || order === void 0 ? void 0 : order.id);
|
|
1016
1027
|
});
|
|
@@ -1047,7 +1058,7 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
1047
1058
|
method: 'PUT',
|
|
1048
1059
|
headers: {
|
|
1049
1060
|
'Content-Type': 'application/json',
|
|
1050
|
-
Authorization: "Bearer ".concat(
|
|
1061
|
+
Authorization: "Bearer ".concat(session.token)
|
|
1051
1062
|
},
|
|
1052
1063
|
body: JSON.stringify({
|
|
1053
1064
|
status: status,
|
|
@@ -1365,8 +1376,8 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
1365
1376
|
for (var i = 0; i < ordersStatusArray.length; i++) {
|
|
1366
1377
|
var status = ordersStatusArray[i];
|
|
1367
1378
|
if (order !== null && order !== void 0 && order.products) {
|
|
1368
|
-
var _ordersGroup$
|
|
1369
|
-
orderFound = (_ordersGroup$
|
|
1379
|
+
var _ordersGroup$status2;
|
|
1380
|
+
orderFound = (_ordersGroup$status2 = ordersGroup[status]) === null || _ordersGroup$status2 === void 0 || (_ordersGroup$status2 = _ordersGroup$status2.orders) === null || _ordersGroup$status2 === void 0 ? void 0 : _ordersGroup$status2.find(function (_order) {
|
|
1370
1381
|
return _order.id === order.id;
|
|
1371
1382
|
});
|
|
1372
1383
|
}
|
|
@@ -1520,12 +1531,7 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
1520
1531
|
if (!session.user) return;
|
|
1521
1532
|
var userId = session.user.id;
|
|
1522
1533
|
var userLevel = session.user.level;
|
|
1523
|
-
var ordersRoom =
|
|
1524
|
-
project: ordering.project,
|
|
1525
|
-
room: 'orders',
|
|
1526
|
-
user_id: userId,
|
|
1527
|
-
role: 'manager'
|
|
1528
|
-
} : userLevel === 0 ? 'orders' : "orders_".concat(userId);
|
|
1534
|
+
var ordersRoom = userLevel === 0 ? 'orders' : "orders_".concat(userId);
|
|
1529
1535
|
var requestsRoom = "requests_".concat(userId);
|
|
1530
1536
|
var groupsRoom = "ordergroups_".concat(userId);
|
|
1531
1537
|
var messagesOrdersRoom = userLevel === 0 ? 'messages_orders' : "messages_orders_".concat(userId);
|
|
@@ -1558,9 +1564,9 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
1558
1564
|
var handleCustomerReviewed = function handleCustomerReviewed(review) {
|
|
1559
1565
|
var orderFound = null;
|
|
1560
1566
|
for (var i = 0; i < ordersStatusArray.length; i++) {
|
|
1561
|
-
var _ordersGroup$
|
|
1567
|
+
var _ordersGroup$status3;
|
|
1562
1568
|
var status = ordersStatusArray[i];
|
|
1563
|
-
orderFound = (_ordersGroup$
|
|
1569
|
+
orderFound = (_ordersGroup$status3 = ordersGroup[status]) === null || _ordersGroup$status3 === void 0 || (_ordersGroup$status3 = _ordersGroup$status3.orders) === null || _ordersGroup$status3 === void 0 ? void 0 : _ordersGroup$status3.find(function (_order) {
|
|
1564
1570
|
return _order.id === review.order_id;
|
|
1565
1571
|
});
|
|
1566
1572
|
if (orderFound) break;
|
|
@@ -1584,7 +1590,7 @@ var OrderListGroups = exports.OrderListGroups = function OrderListGroups(props)
|
|
|
1584
1590
|
currentFilters: currentFilters,
|
|
1585
1591
|
setCurrentFilters: setCurrentFilters,
|
|
1586
1592
|
currentTabSelected: currentTabSelected,
|
|
1587
|
-
setCurrentTabSelected:
|
|
1593
|
+
setCurrentTabSelected: handleSelectCurrentTab,
|
|
1588
1594
|
ordersGroup: ordersGroup,
|
|
1589
1595
|
setOrdersGroup: setOrdersGroup,
|
|
1590
1596
|
logisticOrders: logisticOrders,
|
package/package.json
CHANGED
|
@@ -12,7 +12,6 @@ export const OrderListGroups = (props) => {
|
|
|
12
12
|
UIComponent,
|
|
13
13
|
orderBy,
|
|
14
14
|
isIos,
|
|
15
|
-
useDefualtSessionManager,
|
|
16
15
|
paginationSettings,
|
|
17
16
|
asDashboard,
|
|
18
17
|
orderGroupStatusCustom,
|
|
@@ -102,6 +101,7 @@ export const OrderListGroups = (props) => {
|
|
|
102
101
|
const [orderLogisticAdded, setOrderLogisticAdded] = useState(null)
|
|
103
102
|
const [orderLogisticUpdated, setOrderLogisticUpdated] = useState(null)
|
|
104
103
|
const [recentlyReceivedMessage, setRecentlyReceivedMessage] = useState(null)
|
|
104
|
+
|
|
105
105
|
const [ordersFiltered, setOrdersFiltered] = useState({
|
|
106
106
|
orders: [],
|
|
107
107
|
loading: false,
|
|
@@ -115,9 +115,27 @@ export const OrderListGroups = (props) => {
|
|
|
115
115
|
}
|
|
116
116
|
})
|
|
117
117
|
|
|
118
|
-
const accessToken = useDefualtSessionManager ? session.token : props.accessToken
|
|
119
118
|
const requestsState = {}
|
|
120
119
|
|
|
120
|
+
const handleSelectCurrentTab = (value) => {
|
|
121
|
+
if (!isDriverApp) {
|
|
122
|
+
setOrdersGroup({
|
|
123
|
+
...ordersGroup,
|
|
124
|
+
[value]: {
|
|
125
|
+
...ordersGroup[value],
|
|
126
|
+
loading: true
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
if (value === 'logisticOrders') {
|
|
131
|
+
setlogisticOrders({
|
|
132
|
+
...logisticOrders,
|
|
133
|
+
loading: true
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
setCurrentTabSelected(value)
|
|
137
|
+
}
|
|
138
|
+
|
|
121
139
|
const getOrders = async ({
|
|
122
140
|
page,
|
|
123
141
|
pageSize = paginationSettings.pageSize,
|
|
@@ -285,8 +303,8 @@ export const OrderListGroups = (props) => {
|
|
|
285
303
|
options.cancelToken = source
|
|
286
304
|
|
|
287
305
|
const functionFetch = asDashboard
|
|
288
|
-
? ordering.setAccessToken(
|
|
289
|
-
: ordering.setAccessToken(
|
|
306
|
+
? ordering.setAccessToken(session.token).orders().asDashboard()
|
|
307
|
+
: ordering.setAccessToken(session.token).orders()
|
|
290
308
|
return await functionFetch.get(options)
|
|
291
309
|
}
|
|
292
310
|
|
|
@@ -294,7 +312,7 @@ export const OrderListGroups = (props) => {
|
|
|
294
312
|
try {
|
|
295
313
|
setControlsState({ ...controlsState, loading: true })
|
|
296
314
|
const { content: { error, result } } = await ordering
|
|
297
|
-
.setAccessToken(
|
|
315
|
+
.setAccessToken(session.token)
|
|
298
316
|
.controls()
|
|
299
317
|
.get()
|
|
300
318
|
const obj = {
|
|
@@ -527,7 +545,7 @@ export const OrderListGroups = (props) => {
|
|
|
527
545
|
method: 'GET',
|
|
528
546
|
headers: {
|
|
529
547
|
'Content-Type': 'application/json',
|
|
530
|
-
Authorization: `Bearer ${
|
|
548
|
+
Authorization: `Bearer ${session.token}`,
|
|
531
549
|
'X-App-X': ordering.appId,
|
|
532
550
|
'X-Socket-Id-X': socket?.getId()
|
|
533
551
|
}
|
|
@@ -557,11 +575,11 @@ export const OrderListGroups = (props) => {
|
|
|
557
575
|
const errorState = []
|
|
558
576
|
|
|
559
577
|
if (orderIds.length === 1) {
|
|
560
|
-
const { content: { error } } = await ordering.setAccessToken(
|
|
578
|
+
const { content: { error } } = await ordering.setAccessToken(session.token).orders(orderIds[0]).delete()
|
|
561
579
|
errorState.push({ error, id: orderIds[0] })
|
|
562
580
|
} else if (orderIds.length > 1) {
|
|
563
581
|
for (const id of orderIds) {
|
|
564
|
-
const { content: { error: multiError } } = await ordering.setAccessToken(
|
|
582
|
+
const { content: { error: multiError } } = await ordering.setAccessToken(session.token).orders(id).delete()
|
|
565
583
|
errorState.push({ error: multiError, id })
|
|
566
584
|
}
|
|
567
585
|
}
|
|
@@ -602,7 +620,7 @@ export const OrderListGroups = (props) => {
|
|
|
602
620
|
method: 'GET',
|
|
603
621
|
headers: {
|
|
604
622
|
'Content-Type': 'application/json',
|
|
605
|
-
Authorization: `Bearer ${
|
|
623
|
+
Authorization: `Bearer ${session.token}`,
|
|
606
624
|
'X-App-X': ordering.appId,
|
|
607
625
|
'X-Socket-Id-X': socket?.getId()
|
|
608
626
|
}
|
|
@@ -699,38 +717,38 @@ export const OrderListGroups = (props) => {
|
|
|
699
717
|
}
|
|
700
718
|
|
|
701
719
|
const actionOrderToTab = (orderAux, status, type) => {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
...orderAux,
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
:
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
if (type !== 'update') {
|
|
719
|
-
_pagination = {
|
|
720
|
-
...ordersGroup[status].pagination,
|
|
721
|
-
total: ordersGroup[status].pagination.total + (type === 'add' ? 1 : -1)
|
|
720
|
+
setOrdersGroup(prevState => {
|
|
721
|
+
if (!prevState[status]?.orders) return
|
|
722
|
+
const orderList = prevState[status]?.orders
|
|
723
|
+
const order = { ...orderAux, showNotification: false }
|
|
724
|
+
let updatedOrders
|
|
725
|
+
|
|
726
|
+
switch (type) {
|
|
727
|
+
case 'update':
|
|
728
|
+
updatedOrders = orderList.map(o => o.id === order.id ? { ...order, action: `${type}${order?.status}` } : o)
|
|
729
|
+
break
|
|
730
|
+
case 'add':
|
|
731
|
+
updatedOrders = [{ ...order, action: `${type}${order?.status}` }, ...orderList]
|
|
732
|
+
break
|
|
733
|
+
case 'remove':
|
|
734
|
+
updatedOrders = orderList.filter(o => o.id !== order.id)
|
|
735
|
+
break
|
|
722
736
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
737
|
+
|
|
738
|
+
const updatedPagination = {
|
|
739
|
+
...prevState[status].pagination,
|
|
740
|
+
total: prevState[status].pagination.total + (type === 'add' ? 1 : type === 'remove' ? -1 : 0)
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
return {
|
|
744
|
+
...prevState,
|
|
745
|
+
[status]: {
|
|
746
|
+
...prevState[status],
|
|
747
|
+
orders: filterByIdUnique(sortOrders(updatedOrders), status),
|
|
748
|
+
pagination: updatedPagination
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
})
|
|
734
752
|
}
|
|
735
753
|
|
|
736
754
|
const handleClickOrder = (orderAux) => {
|
|
@@ -773,7 +791,7 @@ export const OrderListGroups = (props) => {
|
|
|
773
791
|
try {
|
|
774
792
|
const response = await fetch(`${ordering.root}/drivers/${session.user?.id}/assign_requests/${orderId}`, {
|
|
775
793
|
method: 'PUT',
|
|
776
|
-
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${
|
|
794
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${session.token}` },
|
|
777
795
|
body: JSON.stringify({
|
|
778
796
|
status,
|
|
779
797
|
user_id: session.user?.id
|
|
@@ -1127,16 +1145,9 @@ export const OrderListGroups = (props) => {
|
|
|
1127
1145
|
const userId = session.user.id
|
|
1128
1146
|
const userLevel = session.user.level
|
|
1129
1147
|
|
|
1130
|
-
const ordersRoom =
|
|
1131
|
-
?
|
|
1132
|
-
|
|
1133
|
-
room: 'orders',
|
|
1134
|
-
user_id: userId,
|
|
1135
|
-
role: 'manager'
|
|
1136
|
-
}
|
|
1137
|
-
: userLevel === 0
|
|
1138
|
-
? 'orders'
|
|
1139
|
-
: `orders_${userId}`
|
|
1148
|
+
const ordersRoom = userLevel === 0
|
|
1149
|
+
? 'orders'
|
|
1150
|
+
: `orders_${userId}`
|
|
1140
1151
|
|
|
1141
1152
|
const requestsRoom = `requests_${userId}`
|
|
1142
1153
|
const groupsRoom = `ordergroups_${userId}`
|
|
@@ -1204,7 +1215,7 @@ export const OrderListGroups = (props) => {
|
|
|
1204
1215
|
currentFilters={currentFilters}
|
|
1205
1216
|
setCurrentFilters={setCurrentFilters}
|
|
1206
1217
|
currentTabSelected={currentTabSelected}
|
|
1207
|
-
setCurrentTabSelected={
|
|
1218
|
+
setCurrentTabSelected={handleSelectCurrentTab}
|
|
1208
1219
|
ordersGroup={ordersGroup}
|
|
1209
1220
|
setOrdersGroup={setOrdersGroup}
|
|
1210
1221
|
logisticOrders={logisticOrders}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|