._.
This commit is contained in:
parent
09d0b03834
commit
2e926e7999
@ -34,6 +34,7 @@ const DeliveryOrderDetails = () => {
|
|||||||
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 [totalWeight, setTotalWeight] = useState(0);
|
||||||
|
const [accessoryPeriod, setAccessoryPeriod] = 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);
|
||||||
@ -65,6 +66,9 @@ const DeliveryOrderDetails = () => {
|
|||||||
fetchTotalOrder(order.total_order_id);
|
fetchTotalOrder(order.total_order_id);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.response && error.response.status === 401) {
|
||||||
|
navigate("/login");
|
||||||
|
}
|
||||||
console.error("Ошибка при загрузке deliveryOrder:", error);
|
console.error("Ошибка при загрузке deliveryOrder:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -111,6 +115,7 @@ const DeliveryOrderDetails = () => {
|
|||||||
|
|
||||||
const coords = await Promise.all(
|
const coords = await Promise.all(
|
||||||
accessories.map(async (accessory) => {
|
accessories.map(async (accessory) => {
|
||||||
|
setAccessoryPeriod(accessory.period);
|
||||||
if (accessory.latitude && accessory.longitude) {
|
if (accessory.latitude && accessory.longitude) {
|
||||||
return {
|
return {
|
||||||
city: accessory.city_name,
|
city: accessory.city_name,
|
||||||
@ -186,6 +191,19 @@ const DeliveryOrderDetails = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const calculateRecommendedDepartureTime = () => {
|
||||||
|
if (!totalOrder || !orderDuration || !accessoryPeriod) return null;
|
||||||
|
|
||||||
|
console.log(totalOrder, orderDuration, accessoryPeriod);
|
||||||
|
const periodInMilliseconds = accessoryPeriod * 24 * 60 * 60 * 1000;
|
||||||
|
const orderDurationInMilliseconds = orderDuration * 60 * 1000;
|
||||||
|
const deadlineDate = new Date(totalOrder.deadline);
|
||||||
|
const recommendedDepartureTime = new Date(
|
||||||
|
deadlineDate - periodInMilliseconds - orderDurationInMilliseconds
|
||||||
|
);
|
||||||
|
return recommendedDepartureTime.toLocaleString("ru-RU");
|
||||||
|
};
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
};
|
};
|
||||||
@ -210,6 +228,7 @@ const DeliveryOrderDetails = () => {
|
|||||||
<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>
|
||||||
@ -235,6 +254,7 @@ const DeliveryOrderDetails = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
|
<td>{calculateRecommendedDepartureTime()}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user