+
{value}
-
{hint}
+ {hint &&
{hint}
}
);
diff --git a/src/components/driver/DriverDeliveryDetail.jsx b/src/components/driver/DriverDeliveryDetail.jsx
index cfd5907..4ac9276 100644
--- a/src/components/driver/DriverDeliveryDetail.jsx
+++ b/src/components/driver/DriverDeliveryDetail.jsx
@@ -1,10 +1,42 @@
-import React from "react";
+import React, { useState } from "react";
import { getAvailableTransitionsByRole, getOrderStatusComment, getStatusTone } from "../../constants/deliveryWorkflow";
import { getDeliveryCity, getDeliveryDay, getDeliveryHalfDay } from "../../services/driverDeliveries";
import { Badge } from "../UI/Badge";
import { Button } from "../UI/Button";
import { Panel } from "../UI/Panel";
+const PROBLEM_REASONS = [
+ { value: "client_absent", label: "Клиент не принял", description: "Клиент отказался или не вышел на связь" },
+ { value: "damage", label: "Повреждение заказа", description: "Товар повреждён при транспортировке" },
+ { value: "wrong_address", label: "Неверный адрес", description: "Адрес доставки указан неверно" },
+ { value: "other", label: "Другое", description: "Иная причина проблемы доставки" },
+];
+
+const ProblemReasonModal = ({ onSelect, onCancel }) => (
+
+
e.stopPropagation()}>
+ Причина проблемы
+ Укажите причину возникшей проблемы с доставкой.
+
+ {PROBLEM_REASONS.map((reason) => (
+
+ ))}
+
+
+
+
+
+
+);
+
const splitItem = (item) => {
if (!item) {
return { name: "Позиция", quantity: "" };
@@ -29,6 +61,8 @@ const splitItem = (item) => {
};
export const DriverDeliveryDetail = ({ order, onStatusChange }) => {
+ const [showProblemModal, setShowProblemModal] = useState(false);
+
if (!order) {
return null;
}
@@ -39,8 +73,42 @@ export const DriverDeliveryDetail = ({ order, onStatusChange }) => {
});
const orderItems = Array.isArray(order.items) ? order.items.map(splitItem) : [];
+ const currentStatus = order.status;
+ const IN_TRANSIT_STATUSES = ["Загружен", "В пути"];
+ const isOnRoute = IN_TRANSIT_STATUSES.includes(currentStatus);
+
+ let actionButtons = [];
+ if (currentStatus === "Назначен водитель") {
+ actionButtons = [
+ { value: "Загружен", label: "Загружено" },
+ { value: "Проблема доставки", label: "Проблема" },
+ ];
+ } else if (isOnRoute) {
+ actionButtons = [
+ { value: "Доставлен", label: "Доставлено" },
+ { value: "Проблема доставки", label: "Проблема" },
+ ];
+ } else if (currentStatus === "Доставлен" || currentStatus === "Проблема доставки" || currentStatus === "Закрыт" || currentStatus === "Отменён") {
+ actionButtons = [];
+ } else {
+ actionButtons = availableTransitions.map((status) => ({
+ value: status,
+ label: status === "Проблема доставки" ? "Проблема" : status,
+ }));
+ }
+
return (
+ {showProblemModal && (
+
{
+ setShowProblemModal(false);
+ onStatusChange?.("Проблема доставки", { reason: reasonValue, reasonLabel });
+ }}
+ onCancel={() => setShowProblemModal(false)}
+ />
+ )}
+
@@ -110,22 +178,28 @@ export const DriverDeliveryDetail = ({ order, onStatusChange }) => {
- {availableTransitions.length ? (
+ {actionButtons.length > 0 && (
Быстрые действия
- {availableTransitions.map((status) => (
+ {actionButtons.map((btn) => (
))}
- ) : null}
+ )}
);
-};
+};
\ No newline at end of file
diff --git a/src/components/orders/OrderDetailPanel.jsx b/src/components/orders/OrderDetailPanel.jsx
index d4d7602..e1d3e9c 100644
--- a/src/components/orders/OrderDetailPanel.jsx
+++ b/src/components/orders/OrderDetailPanel.jsx
@@ -398,6 +398,39 @@ const PaidStoragePanel = ({ order, onChangeDeliveryStatus, isSavingDeliveryChoic
);
};
+
+const PROBLEM_REASONS = [
+ { value: "client_absent", label: "Клиент не принял", description: "Клиент отказался или не вышел на связь" },
+ { value: "damage", label: "Повреждение заказа", description: "Товар повреждён при транспортировке" },
+ { value: "wrong_address", label: "Неверный адрес", description: "Адрес доставки указан неверно" },
+ { value: "other", label: "Другое", description: "Иная причина проблемы доставки" },
+];
+
+const ProblemReasonModal = ({ onSelect, onCancel }) => (
+
+
e.stopPropagation()}>
+ Причина проблемы
+ Укажите причину возникшей проблемы с доставкой.
+
+ {PROBLEM_REASONS.map((reason) => (
+
+ ))}
+
+
+
+
+
+
+);
+
export const OrderDetailPanel = ({
order,
canManageDelivery = false,
@@ -408,6 +441,7 @@ export const OrderDetailPanel = ({
onChangeDeliveryStatus,
userRole,
}) => {
+ const [problemReason, setProblemReason] = React.useState(null);
const [deliveryDate, setDeliveryDate] = React.useState("");
const [deliveryTime, setDeliveryTime] = React.useState(DELIVERY_TIME_OPTIONS[0]);
const [formMessage, setFormMessage] = React.useState("");
@@ -804,9 +838,15 @@ export const OrderDetailPanel = ({
Назначение водителя
- {order.assignedDriverId
- ? `Назначен водитель: ${order.assignedDriverName || "Неизвестно"}. Вы можете изменить назначение.`
- : "Выберите водителя для доставки."}
+ {(() => {
+ const ds = order.deliveryStatus || order.delivery_status;
+ if (["loaded", "on_route", "delivered"].includes(ds)) {
+ return "Доставка в процессе — сменить водителя нельзя.";
+ }
+ return order.assignedDriverId
+ ? "Назначен водитель. Вы можете изменить назначение."
+ : "Выберите водителя для доставки.";
+ })()}
{order.assignedDriverId ? (
@@ -824,29 +864,35 @@ export const OrderDetailPanel = ({
) : null}
-
Статус доставки
@@ -932,38 +978,78 @@ export const OrderDetailPanel = ({
Обновите статус по мере выполнения доставки.
-
- {[
- { value: "loaded", label: "Загружено" },
- { value: "on_route", label: "В пути" },
- { value: "delivered", label: "Доставлено" },
- { value: "problem", label: "Проблема" },
- ].map((statusOption) => (
-