._.
This commit is contained in:
parent
7dbf147cef
commit
09d0b03834
@ -43,7 +43,6 @@ const DeliveryOrderDetails = () => {
|
||||
|
||||
useEffect(() => {
|
||||
fetchDeliveryOrder();
|
||||
fetchDeliveryAccessories();
|
||||
}, [deliveryOrderId]);
|
||||
|
||||
const formatDuration = (minutes) => {
|
||||
@ -74,6 +73,9 @@ const DeliveryOrderDetails = () => {
|
||||
try {
|
||||
const order = await getTotalOrder(orderId);
|
||||
setTotalOrder(order);
|
||||
if (order) {
|
||||
fetchDeliveryAccessories(order);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.response && error.response.status === 401) {
|
||||
navigate("/login");
|
||||
@ -82,7 +84,7 @@ const DeliveryOrderDetails = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const fetchDeliveryAccessories = async () => {
|
||||
const fetchDeliveryAccessories = async (totalOrder) => {
|
||||
try {
|
||||
const deliveryOrderDetails = await getDeliveryOrderDetails(
|
||||
deliveryOrderId
|
||||
@ -95,12 +97,17 @@ const DeliveryOrderDetails = () => {
|
||||
const accessories = await getDeliveryAccessories(deliveryOrderId);
|
||||
setDeliveryAccessories(accessories);
|
||||
|
||||
const totalWeightCalculated = accessories.reduce((acc, accessory) => {
|
||||
return (
|
||||
acc + Math.round((accessory.accessory_weight * accessory.count) / 100)
|
||||
);
|
||||
}, 0);
|
||||
setTotalWeight(totalWeightCalculated);
|
||||
if (totalOrder) {
|
||||
const totalWeightCalculated = accessories.reduce((acc, accessory) => {
|
||||
return (
|
||||
acc +
|
||||
Math.round(
|
||||
(accessory.accessory_weight / 100) * totalOrder.count_robots
|
||||
)
|
||||
);
|
||||
}, 0);
|
||||
setTotalWeight(totalWeightCalculated);
|
||||
}
|
||||
|
||||
const coords = await Promise.all(
|
||||
accessories.map(async (accessory) => {
|
||||
@ -256,12 +263,8 @@ const DeliveryOrderDetails = () => {
|
||||
</td>
|
||||
<td>
|
||||
{Math.round(
|
||||
(Math.round(
|
||||
(accessory.accessory_volume / 100) *
|
||||
totalOrder.count_robots
|
||||
) /
|
||||
100) *
|
||||
accessory.accessory_weight
|
||||
(accessory.accessory_weight / 100) *
|
||||
totalOrder.count_robots
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user