This commit is contained in:
Андрей Дувакин 2024-10-08 10:25:53 +05:00
parent 047eb73f23
commit 4a3ff92504

View File

@ -33,6 +33,7 @@ const DeliveryOrderDetails = () => {
const [route, setRoute] = useState([]);
const [totalCost, setTotalCost] = useState(0);
const [truckCount, setTruckCount] = useState(0);
const [totalWeight, setTotalWeight] = useState(0);
const [truckName, setTruckName] = useState("");
const [truckCapacity, setTruckCapacity] = useState("");
const [totalOrder, setTotalOrder] = useState(null);
@ -92,9 +93,15 @@ const DeliveryOrderDetails = () => {
setTruckCapacity(deliveryOrderDetails.truck_capacity);
const accessories = await getDeliveryAccessories(deliveryOrderId);
console.log(accessories);
setDeliveryAccessories(accessories);
const totalWeightCalculated = accessories.reduce((acc, accessory) => {
return (
acc + Math.round((accessory.accessory_weight * accessory.count) / 100)
);
}, 0);
setTotalWeight(totalWeightCalculated);
const coords = await Promise.all(
accessories.map(async (accessory) => {
if (accessory.latitude && accessory.longitude) {
@ -255,7 +262,9 @@ const DeliveryOrderDetails = () => {
))}
<tr>
<td>{DELIVERY_CITY.name}</td>
<td colSpan="3">Конечный пункт</td>
<td>Конечный пункт</td>
<td>Итого:</td>
<td>{totalWeight}</td>
</tr>
</tbody>
</table>