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