This commit is contained in:
Андрей Дувакин 2024-10-08 10:22:47 +05:00
parent 644653c08d
commit 047eb73f23
2 changed files with 15 additions and 9 deletions

View File

@ -6,7 +6,7 @@
} }
.content-container { .content-container {
max-width: 800px; max-width: 900px;
width: 100%; width: 100%;
text-align: left; text-align: left;
} }

View File

@ -43,7 +43,6 @@ const DeliveryOrderDetails = () => {
useEffect(() => { useEffect(() => {
fetchDeliveryOrder(); fetchDeliveryOrder();
fetchDeliveryAccessories(); fetchDeliveryAccessories();
fetchTotalOrder();
}, [deliveryOrderId]); }, [deliveryOrderId]);
const formatDuration = (minutes) => { const formatDuration = (minutes) => {
@ -62,14 +61,17 @@ const DeliveryOrderDetails = () => {
try { try {
const order = await getDeliveryOrder(deliveryOrderId); const order = await getDeliveryOrder(deliveryOrderId);
setDeliveryOrder(order); setDeliveryOrder(order);
if (order) {
fetchTotalOrder(order.total_order_id);
}
} catch (error) { } catch (error) {
console.error("Ошибка при загрузке deliveryOrder:", error); console.error("Ошибка при загрузке deliveryOrder:", error);
} }
}; };
const fetchTotalOrder = async () => { const fetchTotalOrder = async (orderId) => {
try { try {
const order = await getTotalOrder(deliveryOrder.id); const order = await getTotalOrder(orderId);
setTotalOrder(order); setTotalOrder(order);
} catch (error) { } catch (error) {
if (error.response && error.response.status === 401) { if (error.response && error.response.status === 401) {
@ -90,6 +92,7 @@ const DeliveryOrderDetails = () => {
setTruckCapacity(deliveryOrderDetails.truck_capacity); setTruckCapacity(deliveryOrderDetails.truck_capacity);
const accessories = await getDeliveryAccessories(deliveryOrderId); const accessories = await getDeliveryAccessories(deliveryOrderId);
console.log(accessories);
setDeliveryAccessories(accessories); setDeliveryAccessories(accessories);
const coords = await Promise.all( const coords = await Promise.all(
@ -201,7 +204,6 @@ const DeliveryOrderDetails = () => {
<td> <td>
{truckName} {truckName}
<br /> <br />
<br />
Грузоподъемность: {truckCapacity}кг Грузоподъемность: {truckCapacity}кг
</td> </td>
<td>{truckCount}</td> <td>{truckCount}</td>
@ -225,13 +227,13 @@ const DeliveryOrderDetails = () => {
<h2 style={{ textAlign: "center" }}>Маршрут</h2> <h2 style={{ textAlign: "center" }}>Маршрут</h2>
<table className="table table-bordered mb-5"> <table className="table table-bordered table-striped mb-5">
<thead> <thead>
<tr> <tr>
<th scope="col">Город</th> <th scope="col">Город</th>
<th scope="col">Комплектующие</th> <th scope="col">Комплектующие</th>
<th scope="col">Количество, шт.</th> <th scope="col">Объем, шт.</th>
<th scope="col">Объем, куб. м</th> <th scope="col">Вес, кг</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -239,12 +241,16 @@ const DeliveryOrderDetails = () => {
<tr key={accessory.id}> <tr key={accessory.id}>
<td>{accessory.city_name}</td> <td>{accessory.city_name}</td>
<td>{accessory.accessory_name}</td> <td>{accessory.accessory_name}</td>
<td>{accessory.count}</td>
<td> <td>
{Math.round( {Math.round(
(accessory.accessory_volume * accessory.count) / 100 (accessory.accessory_volume * accessory.count) / 100
)} )}
</td> </td>
<td>
{Math.round(
(accessory.accessory_weight * accessory.count) / 100
)}
</td>
</tr> </tr>
))} ))}
<tr> <tr>