diff --git a/src/components/orders/OrderDetailPanel.jsx b/src/components/orders/OrderDetailPanel.jsx index 87e43f9..32f9077 100644 --- a/src/components/orders/OrderDetailPanel.jsx +++ b/src/components/orders/OrderDetailPanel.jsx @@ -54,6 +54,23 @@ import { const DELIVERY_TIME_OPTIONS = ["Первая половина дня", "Вторая половина дня"]; const WEEK_DAY_LABELS = ["ПН", "ВТ", "СР", "ЧТ", "ПТ", "СБ", "ВС"]; +const STATUS_LABELS = { pending_confirmation: 'Ожидает согласования', agreed: 'Согласовано', driver_assigned: 'Назначен водитель', loaded: 'Загружено', on_route: 'В пути', delivered: 'Доставлено', pickup: 'Самовывоз', requires_address: 'Требуется адрес', problem: 'Проблема', cancelled: 'Отменено' }; + +const ConfirmModal = ({ open, title, message, onConfirm, onCancel }) => { + if (!open) return null; + return ( +
+
e.stopPropagation()}> + {title &&

{title}

} + {message &&

{message}

} +
+ + +
+
+
+ ); +}; const DELIVERY_TIME_ALIASES = { "До обеда": "Первая половина дня", "После обеда": "Вторая половина дня", @@ -558,6 +575,7 @@ export const OrderDetailPanel = ({ const [pickupDate, setPickupDate] = React.useState(order?.pickupDate || ""); const [pickupTimeSlot, setPickupTimeSlot] = React.useState(DELIVERY_TIME_OPTIONS[0]); const [deliveryAddress, setDeliveryAddress] = React.useState(order?.deliveryAddress || order?.customerAddress || ""); + const [confirmAction, setConfirmAction] = React.useState(null); const minSelectableDateKey = React.useMemo(() => getNextSelectableDateKey(), []); const [currentMonth, setCurrentMonth] = React.useState(() => { const existingDeliveryDate = fromDateKey(order?.deliveryDate); @@ -709,11 +727,10 @@ export const OrderDetailPanel = ({ : "Доставка"; const dateLabel = isPickup ? "Дата самовывоза" : "Дата доставки"; const timeLabel = isPickup ? "Время самовывоза" : "Время доставки"; - const addressLabel = isPickup ? "Адрес самовывоза" : "Адрес доставки"; - // For pickup orders, hide the delivery address if it's just a placeholder like "Самовывоз" + const addressLabel = isPickup ? "Адрес клиента" : "Адрес доставки"; const effectiveAddress = isPickup - ? (order.deliveryAddress && order.deliveryAddress !== "Самовывоз" && order.deliveryAddress !== "самовывоз" ? order.deliveryAddress : "") - : order.deliveryAddress; + ? (order.customerAddress || "") + : (order.deliveryAddress || ""); return (
@@ -809,10 +826,12 @@ export const OrderDetailPanel = ({

Готово

{order.readyCount ?? 0}

-
-

Не готово

-

{order.notReadyCount ?? 0}

-
+ {(order.notReadyCount ?? 0) > 0 ? ( +
+

Не готово

+

{order.notReadyCount}

+
+ ) : null}

Обновлена

{formatDateTime(order.updatedAt)}

@@ -908,7 +927,7 @@ export const OrderDetailPanel = ({
) : deliveryType === "delivery" ? (
-
+
{isCalendarOpen ? ( -
+

@@ -1039,6 +1058,7 @@ export const OrderDetailPanel = ({

) : (
+
{isCalendarOpen ? ( -
+

Календарь самовывоза

@@ -1084,6 +1104,7 @@ export const OrderDetailPanel = ({

Выходные отмечены пунктиром и недоступны.

) : null} +
{DELIVERY_TIME_OPTIONS.map((option) => (
) : null} + + { setConfirmAction(null); handleSaveDeliveryChoice(); }} + onCancel={() => setConfirmAction(null)} + /> + + d.id === selectedDriverId)?.name || 'выбранного водителя'} на эту группу?`} + onConfirm={() => { setConfirmAction(null); handleAssignDriver(); }} + onCancel={() => setConfirmAction(null)} + /> + + { + const status = confirmAction.status; + setConfirmAction(null); + onChangeDeliveryStatus({ orderGroupId: order.id, status }).then((response) => { + if (!response.success) setFormMessage(response.error || 'Не удалось обновить статус'); + else setFormMessage(''); + }); + }} + onCancel={() => setConfirmAction(null)} + />
); }; diff --git a/src/components/orders/OrdersTable.jsx b/src/components/orders/OrdersTable.jsx index eeb9e5b..7551d00 100644 --- a/src/components/orders/OrdersTable.jsx +++ b/src/components/orders/OrdersTable.jsx @@ -10,11 +10,18 @@ import { const MAX_VISIBLE_INVOICES = 2; +const fmtDate = (d) => { + if (!d) return ''; + const [y, m, day] = d.split('-'); + if (!y || !m || !day) return d; + return `${day}.${m}.${y}`; +}; + const buildGroupSummary = (group) => { const orderCountLabel = `${group.ordersCount || 0} ${group.ordersCount === 1 ? "заказ" : group.ordersCount < 5 ? "заказа" : "заказов"}`; const parts = [orderCountLabel]; if (group.deliveryDate) { - const datePart = group.deliveryTime ? `${group.deliveryDate} · ${group.deliveryTime}` : group.deliveryDate; + const datePart = group.deliveryTime ? `${fmtDate(group.deliveryDate)} · ${group.deliveryTime}` : fmtDate(group.deliveryDate); parts.push(datePart); } if (group.assignedDriverName) { @@ -165,7 +172,7 @@ export const OrdersTable = ({ {renderOrderNumbers(group)} - + {getOrderGroupDisplayStatusLabel(group)} @@ -173,7 +180,7 @@ export const OrdersTable = ({ {group.deliveryDate ? ( - {group.deliveryDate}{group.deliveryTime ? · {group.deliveryTime} : ""} + {fmtDate(group.deliveryDate)}{group.deliveryTime ? · {group.deliveryTime} : ""} ) : ( )}