diff --git a/public/index.html b/public/index.html index 843206b..94b1d11 100644 --- a/public/index.html +++ b/public/index.html @@ -2,7 +2,7 @@ - Логистика + Logistics service diff --git a/src/components/DeliveryOrdersList.jsx b/src/components/DeliveryOrdersList.jsx index ee739fe..dd95560 100644 --- a/src/components/DeliveryOrdersList.jsx +++ b/src/components/DeliveryOrdersList.jsx @@ -4,6 +4,12 @@ import { useNavigate } from "react-router-dom"; import polyline from "@mapbox/polyline"; import "./DeliveryOrdersList.css"; +const DELIVERY_CITY = { + name: "Челябинск", + latitude: 55.159902, + longitude: 61.402554, +}; + const DeliveryOrdersList = ({ totalOrderId, onSubOrderClick, @@ -50,6 +56,66 @@ const DeliveryOrdersList = ({ await Promise.all( ordersToCalculate.map(async (order) => { try { + // const deliveryOrderDetails = await getDeliveryOrderDetails(order.id); + + // const coords = await Promise.all( + // accessories.map(async (accessory) => { + // if (accessory.latitude && accessory.longitude) { + // return { + // city: accessory.city_name, + // latitude: accessory.latitude, + // longitude: accessory.longitude, + // accessory_name: + // accessory.accessory_name + + // Math.round( + // (accessory.accessory_volume * accessory.count) / 100 + // ) + + // "шт.", + // }; + // } else { + // const coords = await getCoordinates(accessory.city_name); + // return { + // city: accessory.city_name, + // accessory_name: + // accessory.accessory_name + + // ": " + + // Math.round( + // (accessory.accessory_volume * accessory.count) / 100 + // ) + + // "шт.", + // ...coords, + // }; + // } + // }) + // ); + + // if (fullCoordinates.length > 1) { + // const waypoints = fullCoordinates + // .map(({ longitude, latitude }) => `${longitude},${latitude}`) + // .join(";"); + + // const routeUrl = `https://router.project-osrm.org/route/v1/driving/${waypoints}?overview=full`; + + // const response = await fetch(routeUrl); + // const data = await response.json(); + + // if (data.routes && data.routes.length > 0) { + // const geometry = data.routes[0].geometry; + // const decodedRoute = polyline.decode(geometry); + // setRoute(decodedRoute); + // const duration = data.routes[0].duration; + // setOrderDuration(duration); + + // await updateDeliveryOrderRoute( + // order.id, + // duration / 60, + // decodedRoute + // ); + // } + // } + + // const fullCoordinates = [...coords, DELIVERY_CITY]; + const routeUrl = `https://router.project-osrm.org/route/v1/driving/${order.start_longitude},${order.start_latitude};${order.end_longitude},${order.end_latitude}?overview=full`; const response = await fetch(routeUrl); const data = await response.json(); diff --git a/src/components/SelectionDialog.jsx b/src/components/SelectionDialog.jsx index 6fb27be..bc9b685 100644 --- a/src/components/SelectionDialog.jsx +++ b/src/components/SelectionDialog.jsx @@ -1,71 +1,78 @@ -import React, { useState, useEffect } from 'react'; -import './Dialog.css'; +import React, { useState, useEffect } from "react"; +import "./Dialog.css"; const SelectionDialog = ({ show, handleClose, items, columns, onSelect }) => { - const [searchTerm, setSearchTerm] = useState(''); - const [filteredItems, setFilteredItems] = useState(items); + const [searchTerm, setSearchTerm] = useState(""); + const [filteredItems, setFilteredItems] = useState(items); - useEffect(() => { - setFilteredItems( - items.filter(item => - columns.some(column => - item[column.key].toString().toLowerCase().includes(searchTerm.toLowerCase()) - ) - ) - ); - }, [searchTerm, items, columns]); - - if (!show) return null; - - return ( - <> -
-
-
-
-
-
Выбор
- -
-
- setSearchTerm(e.target.value)} - /> - - - - {columns.map(column => ( - - ))} - - - - {filteredItems.map(item => ( - onSelect(item)}> - {columns.map(column => ( - - ))} - - ))} - -
{column.label}
{item[column.key]}
-
-
- -
-
-
-
- + useEffect(() => { + setFilteredItems( + items.filter((item) => + columns.some((column) => + item[column.key] + .toString() + .toLowerCase() + .includes(searchTerm.toLowerCase()) + ) + ) ); + }, [searchTerm, items, columns]); + + if (!show) return null; + + return ( + <> +
+
+
+
+
+
Выбор
+ +
+
+ setSearchTerm(e.target.value)} + /> + + + + {columns.map((column) => ( + + ))} + + + + {filteredItems.map((item) => ( + onSelect(item)}> + {columns.map((column) => ( + + ))} + + ))} + +
{column.label}
{item[column.key]}
+
+
+ +
+
+
+
+ + ); }; export default SelectionDialog; diff --git a/src/pages/Accessories.jsx b/src/pages/Accessories.jsx index 172fa5d..6c983b9 100644 --- a/src/pages/Accessories.jsx +++ b/src/pages/Accessories.jsx @@ -83,7 +83,10 @@ const Accessories = () => { fetchAccessories(); resetForm(); } catch (error) { - console.error("Ошибка при добавлении или обновлении комплектующих:", error); + console.error( + "Ошибка при добавлении или обновлении комплектующих:", + error + ); } }; @@ -151,15 +154,16 @@ const Accessories = () => { />
- +
@@ -172,28 +176,30 @@ const Accessories = () => { placeholder="Введите объем" value={newAccessory.volume} onChange={handleInputChange} + min={1} />
- +
- + @@ -244,10 +250,10 @@ const Accessories = () => { Название - Количество + Количество роботов Объем - Вес - Период + Вес, кг + Период, дни Город Действия diff --git a/src/pages/Cities.jsx b/src/pages/Cities.jsx index 6777cae..1fc41eb 100644 --- a/src/pages/Cities.jsx +++ b/src/pages/Cities.jsx @@ -194,7 +194,7 @@ const Cities = () => { @@ -204,7 +204,7 @@ const Cities = () => { @@ -249,8 +249,8 @@ const Cities = () => { Название Федеральный округ - X координата - Y координата + X-координата + Y-координата Действия diff --git a/src/pages/DeliveryOrderDetails.jsx b/src/pages/DeliveryOrderDetails.jsx index a364d8c..28ddc19 100644 --- a/src/pages/DeliveryOrderDetails.jsx +++ b/src/pages/DeliveryOrderDetails.jsx @@ -190,8 +190,8 @@ const DeliveryOrderDetails = () => { Общая стоимость - Тип машины - Количество машин + Тип транспортного средства + Количество транспортных средств Прогнозируемое время этапа @@ -201,6 +201,7 @@ const DeliveryOrderDetails = () => { {truckName}
+
Грузоподъемность: {truckCapacity}кг {truckCount} @@ -228,9 +229,9 @@ const DeliveryOrderDetails = () => { Город - Комплектующее + Комплектующие Количество, шт. - Объем, м^3 + Объем, куб. м @@ -253,6 +254,8 @@ const DeliveryOrderDetails = () => { +

Схема маршрута

+ {coordinates.length > 0 && (
{ Название - Грузоподъемность - Объем + Грузоподъемность, кг + Объем, куб. м Действия