From 755385cf0e91930965ca9c91019410e5e596e3c8 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 13 Jul 2026 13:16:48 +0000 Subject: [PATCH] fix: StatusActionPanel smart hints + driver name lookup + logistician can edit shipment + completed label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. StatusActionPanel: all buttons clickable (no more manual:false blocking) - Click on current status shows actual state: "Водитель уже назначен: Иван" - "Назначен водитель" clickable even if already assigned - "Согласовано" clickable even if already agreed 2. Status indicators: green badges ✓ Дата согласована / ✓ Водитель: имя + warning badges if missing 3. DriverAssignmentPanel: look up driver name from drivers list if assignedDriverName is empty (Supabase join failed) 4. DriverShipmentPanel: now visible to logistician/admin too — can edit shipment data (fix wrong driver checkboxes) 5. SmsStatusCard: add completed label ("Завершено") --- .../orders/DriverAssignmentPanel.jsx | 2 +- src/components/orders/OrderDetailPanel.jsx | 2 +- src/components/orders/SmsStatusCard.jsx | 2 + src/components/orders/StatusActionPanel.jsx | 123 +++++++++++------- 4 files changed, 79 insertions(+), 50 deletions(-) diff --git a/src/components/orders/DriverAssignmentPanel.jsx b/src/components/orders/DriverAssignmentPanel.jsx index b1761ef..fb40dd7 100644 --- a/src/components/orders/DriverAssignmentPanel.jsx +++ b/src/components/orders/DriverAssignmentPanel.jsx @@ -122,7 +122,7 @@ const DriverAssignmentPanel = ({ Водитель назначен

- {order.assignedDriverName || "Водитель назначен"} + {order.assignedDriverName || drivers.find((d) => d.id === order.assignedDriverId)?.name || "Водитель назначен"}

Назначен diff --git a/src/components/orders/OrderDetailPanel.jsx b/src/components/orders/OrderDetailPanel.jsx index 68d5827..2696461 100644 --- a/src/components/orders/OrderDetailPanel.jsx +++ b/src/components/orders/OrderDetailPanel.jsx @@ -1110,7 +1110,7 @@ export const OrderDetailPanel = ({ /> ) : null} - {userRole === "driver" && order ? ( + {["driver", "logistician", "admin", "mega_admin"].includes(userRole) && order ? ( { + if (statusValue === "agreed") { + if (hasDeliverySchedule) return "Дата доставки уже согласована"; + return "Согласуйте дату доставки выше"; + } + if (statusValue === "driver_assigned") { + if (hasDriver) return `Водитель уже назначен: ${order.assignedDriverName || ""}`.trim(); + return "Назначьте водителя из списка выше"; + } + return ""; + }; - // Build status options — no "Загружено", "Доставлено"/"Вывезено" require date+half-day const allStatuses = isPickup ? [ - { value: "pending_confirmation", label: "Ожидает согласования", manual: true }, - { value: "agreed", label: "Согласовано", manual: false, hint: "Согласуйте дату доставки выше" }, - { value: "driver_assigned", label: "Назначен водитель", manual: false, hint: "Назначьте водителя из списка" }, - { value: "picked_up", label: "Вывезено", manual: true, primary: true, requiresSchedule: true }, - { value: "delivered", label: "Доставлено", manual: true, mismatch: true, requiresSchedule: true }, - { value: "requires_address", label: "Требуется адрес", manual: true }, - { value: "problem", label: "Проблема", manual: true }, - { value: "cancelled", label: "Отменено", manual: true }, + { value: "pending_confirmation", label: "Ожидает согласования" }, + { value: "agreed", label: "Согласовано" }, + { value: "driver_assigned", label: "Назначен водитель" }, + { value: "picked_up", label: "Вывезено", primary: true, requiresSchedule: true }, + { value: "delivered", label: "Доставлено", mismatch: true, requiresSchedule: true }, + { value: "requires_address", label: "Требуется адрес" }, + { value: "problem", label: "Проблема" }, + { value: "cancelled", label: "Отменено" }, ] : [ - { value: "pending_confirmation", label: "Ожидает согласования", manual: true }, - { value: "agreed", label: "Согласовано", manual: false, hint: "Согласуйте дату доставки выше" }, - { value: "driver_assigned", label: "Назначен водитель", manual: false, hint: "Назначьте водителя из списка" }, - { value: "delivered", label: "Доставлено", manual: true, primary: true, requiresSchedule: true }, - { value: "picked_up", label: "Вывезено", manual: true, mismatch: true, requiresSchedule: true }, - { value: "requires_address", label: "Требуется адрес", manual: true }, - { value: "problem", label: "Проблема", manual: true }, - { value: "cancelled", label: "Отменено", manual: true }, + { value: "pending_confirmation", label: "Ожидает согласования" }, + { value: "agreed", label: "Согласовано" }, + { value: "driver_assigned", label: "Назначен водитель" }, + { value: "delivered", label: "Доставлено", primary: true, requiresSchedule: true }, + { value: "picked_up", label: "Вывезено", mismatch: true, requiresSchedule: true }, + { value: "requires_address", label: "Требуется адрес" }, + { value: "problem", label: "Проблема" }, + { value: "cancelled", label: "Отменено" }, ]; return ( @@ -56,41 +67,57 @@ const StatusActionPanel = ({ Измените статус, если водитель забыл обновить или нужна корректировка.

+ + {/* Status indicators: show current state clearly */} +
+ {hasDeliverySchedule && ( + ✓ Дата согласована + )} + {hasDriver && ( + ✓ Водитель: {order.assignedDriverName || "назначен"} + )} + {!hasDeliverySchedule && ( + ⚠ Дата не указана + )} + {!hasDriver && ( + ⚠ Водитель не назначен + )} +
+
{allStatuses.map((statusOption) => { const isCurrent = currentStatus === statusOption.value; - const isClickable = (statusOption.manual !== false || currentStatus === 'problem') && !isCurrent; const blockedBySchedule = statusOption.requiresSchedule && !hasDeliverySchedule; + const hint = getHint(statusOption.value); return ( -
- -
+ return; + } + if (isCurrent && hint) { + onConfirmStatus?.({ type: "hint", hint }); + return; + } + onConfirmStatus?.({ + type: "status", + status: statusOption.value, + label: statusOption.label, + mismatch: !!statusOption.mismatch, + deliveryType: isPickup ? "pickup" : "delivery", + }); + }} + disabled={isSavingStatusChange} + className={blockedBySchedule ? "opacity-40 cursor-not-allowed" : ""} + > + {statusOption.label} + ); })}