._.
This commit is contained in:
parent
047eb73f23
commit
4a3ff92504
@ -33,6 +33,7 @@ const DeliveryOrderDetails = () => {
|
|||||||
const [route, setRoute] = useState([]);
|
const [route, setRoute] = useState([]);
|
||||||
const [totalCost, setTotalCost] = useState(0);
|
const [totalCost, setTotalCost] = useState(0);
|
||||||
const [truckCount, setTruckCount] = useState(0);
|
const [truckCount, setTruckCount] = useState(0);
|
||||||
|
const [totalWeight, setTotalWeight] = useState(0);
|
||||||
const [truckName, setTruckName] = useState("");
|
const [truckName, setTruckName] = useState("");
|
||||||
const [truckCapacity, setTruckCapacity] = useState("");
|
const [truckCapacity, setTruckCapacity] = useState("");
|
||||||
const [totalOrder, setTotalOrder] = useState(null);
|
const [totalOrder, setTotalOrder] = useState(null);
|
||||||
@ -92,9 +93,15 @@ 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 totalWeightCalculated = accessories.reduce((acc, accessory) => {
|
||||||
|
return (
|
||||||
|
acc + Math.round((accessory.accessory_weight * accessory.count) / 100)
|
||||||
|
);
|
||||||
|
}, 0);
|
||||||
|
setTotalWeight(totalWeightCalculated);
|
||||||
|
|
||||||
const coords = await Promise.all(
|
const coords = await Promise.all(
|
||||||
accessories.map(async (accessory) => {
|
accessories.map(async (accessory) => {
|
||||||
if (accessory.latitude && accessory.longitude) {
|
if (accessory.latitude && accessory.longitude) {
|
||||||
@ -249,13 +256,15 @@ const DeliveryOrderDetails = () => {
|
|||||||
<td>
|
<td>
|
||||||
{Math.round(
|
{Math.round(
|
||||||
(accessory.accessory_weight * accessory.count) / 100
|
(accessory.accessory_weight * accessory.count) / 100
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{DELIVERY_CITY.name}</td>
|
<td>{DELIVERY_CITY.name}</td>
|
||||||
<td colSpan="3">Конечный пункт</td>
|
<td>Конечный пункт</td>
|
||||||
|
<td>Итого:</td>
|
||||||
|
<td>{totalWeight}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user