This commit is contained in:
Андрей Дувакин 2024-10-08 08:42:47 +05:00
parent e7c0164313
commit 2380c63f6a

View File

@ -46,6 +46,18 @@ const DeliveryOrderDetails = () => {
fetchTotalOrder();
}, [deliveryOrderId]);
const formatDuration = (minutes) => {
const days = Math.floor(minutes / (24 * 60));
const hours = Math.floor((minutes % (24 * 60)) / 60);
const remainingMinutes = Math.floor(minutes % 60);
return {
days,
hours,
minutes: remainingMinutes,
};
};
const fetchDeliveryOrder = async () => {
try {
const order = await getDeliveryOrder(deliveryOrderId);
@ -177,8 +189,16 @@ const DeliveryOrderDetails = () => {
</td>
<td>{truckCount}</td>
<td>
{Math.round(deliveryOrder?.estimated_route_time_in_minutes)}{" "}
мин.
{deliveryOrder?.estimated_route_time_in_minutes && (
<>
{(() => {
const { days, hours, minutes } = formatDuration(
deliveryOrder?.estimated_route_time_in_minutes
);
return `${days} дн. ${hours} ч.`;
})()}
</>
)}
</td>
</tr>
</tbody>