._.
This commit is contained in:
parent
68468ee72e
commit
7dbf147cef
@ -31,6 +31,13 @@ const DeliveryOrdersList = ({
|
|||||||
fetchDeliveryOrders();
|
fetchDeliveryOrders();
|
||||||
}, [totalOrderId]);
|
}, [totalOrderId]);
|
||||||
|
|
||||||
|
const formatPrice = (price) => {
|
||||||
|
if (!price) {
|
||||||
|
return "не указана";
|
||||||
|
}
|
||||||
|
return `${Math.round(price)} ₽`;
|
||||||
|
};
|
||||||
|
|
||||||
const fetchDeliveryOrders = async () => {
|
const fetchDeliveryOrders = async () => {
|
||||||
try {
|
try {
|
||||||
const orders = await getDeliveryOrders(totalOrderId);
|
const orders = await getDeliveryOrders(totalOrderId);
|
||||||
@ -167,6 +174,7 @@ const DeliveryOrdersList = ({
|
|||||||
Прогнозируемое время этапа:{" "}
|
Прогнозируемое время этапа:{" "}
|
||||||
{formatTimeInHours(order.estimated_route_time_in_minutes)}
|
{formatTimeInHours(order.estimated_route_time_in_minutes)}
|
||||||
</p>
|
</p>
|
||||||
|
<p>Стоимость: {formatPrice(order.price)}</p>
|
||||||
{calculatingRoutes.includes(order.id) && (
|
{calculatingRoutes.includes(order.id) && (
|
||||||
<div className="spinner-border" role="status">
|
<div className="spinner-border" role="status">
|
||||||
<span className="visually-hidden"></span>
|
<span className="visually-hidden"></span>
|
||||||
|
|||||||
@ -250,12 +250,18 @@ const DeliveryOrderDetails = () => {
|
|||||||
<td>{accessory.accessory_name}</td>
|
<td>{accessory.accessory_name}</td>
|
||||||
<td>
|
<td>
|
||||||
{Math.round(
|
{Math.round(
|
||||||
(accessory.accessory_volume * accessory.count) / 100
|
(accessory.accessory_volume / 100) *
|
||||||
|
totalOrder.count_robots
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{Math.round(
|
{Math.round(
|
||||||
(accessory.accessory_weight * accessory.count) / 100
|
(Math.round(
|
||||||
|
(accessory.accessory_volume / 100) *
|
||||||
|
totalOrder.count_robots
|
||||||
|
) /
|
||||||
|
100) *
|
||||||
|
accessory.accessory_weight
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -52,11 +52,16 @@ const Home = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatTimeInHours = (minutes) => {
|
const formatDuration = (minutes) => {
|
||||||
if (!minutes || minutes === 0) {
|
const days = Math.floor(minutes / (24 * 60));
|
||||||
return "ещё не рассчитывалось";
|
const hours = Math.floor((minutes % (24 * 60)) / 60);
|
||||||
}
|
const remainingMinutes = Math.floor(minutes % 60);
|
||||||
return (minutes / 60).toFixed(2) + " час.";
|
|
||||||
|
return {
|
||||||
|
days,
|
||||||
|
hours,
|
||||||
|
minutes: remainingMinutes,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCreateOrder = async ({ deadline, robotsCount }) => {
|
const handleCreateOrder = async ({ deadline, robotsCount }) => {
|
||||||
@ -133,6 +138,7 @@ const Home = () => {
|
|||||||
<th>Количество роботов</th>
|
<th>Количество роботов</th>
|
||||||
<th>Количество этапов</th>
|
<th>Количество этапов</th>
|
||||||
<th>Итоговая цена</th>
|
<th>Итоговая цена</th>
|
||||||
|
<th>Общее время подзаказов</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -141,6 +147,15 @@ const Home = () => {
|
|||||||
<td>{order.count_robots}</td>
|
<td>{order.count_robots}</td>
|
||||||
<td>{deliveryOrdersCount || 0}</td>
|
<td>{deliveryOrdersCount || 0}</td>
|
||||||
<td>{order.price || 0} ₽</td>
|
<td>{order.price || 0} ₽</td>
|
||||||
|
<td>
|
||||||
|
{(() => {
|
||||||
|
const { days, hours, minutes } =
|
||||||
|
formatDuration(totalEstimatedTime);
|
||||||
|
return days > 0
|
||||||
|
? `${days} дн. ${hours} ч.`
|
||||||
|
: `${hours} ч.`;
|
||||||
|
})()}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user