From c28c8266013fea9f4a42e371b420688693c7ca3c Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 16 Apr 2026 12:42:41 +0300 Subject: [PATCH] feat: show client order items in delivery flow --- src/components/client/DeliveryChoiceFlow.jsx | 54 ++++++++++++++++++- .../client/DeliveryChoiceFlow.test.jsx | 27 ++++++++++ src/components/client/DeliveryStateNotice.jsx | 4 +- src/pages/ClientDeliveryPage.jsx | 12 ++--- src/services/deliveryInvitationApi.js | 5 ++ src/services/deliveryInvitationApi.test.js | 10 ++++ .../get-delivery-invitation/index.ts | 45 ++++++++++++++++ 7 files changed, 147 insertions(+), 10 deletions(-) diff --git a/src/components/client/DeliveryChoiceFlow.jsx b/src/components/client/DeliveryChoiceFlow.jsx index f1b97c4..b32af58 100644 --- a/src/components/client/DeliveryChoiceFlow.jsx +++ b/src/components/client/DeliveryChoiceFlow.jsx @@ -18,6 +18,36 @@ const STATE_LABELS = { const DEFAULT_SLOTS = ["Первая половина дня", "Вторая половина дня"]; +const splitOrderItem = (item) => { + if (!item) { + return null; + } + + if (typeof item === "string") { + const [name, quantity] = item.split("|").map((part) => part.trim()); + return { + name: name || item.trim(), + quantity: quantity || "", + }; + } + + if (typeof item === "object") { + const name = typeof item.name === "string" ? item.name.trim() : typeof item.label === "string" ? item.label.trim() : ""; + const quantity = typeof item.quantity === "string" + ? item.quantity.trim() + : typeof item.quantity === "number" + ? String(item.quantity) + : ""; + + return { + name: name || "Позиция", + quantity, + }; + } + + return null; +}; + export const DeliveryChoiceFlow = ({ invitation = {}, onConfirmChoice = () => {}, @@ -28,6 +58,9 @@ export const DeliveryChoiceFlow = ({ const slots = invitation.availableSlots?.length ? invitation.availableSlots : DEFAULT_SLOTS; const orderNumber = invitation.orderNumber || "—"; const customerName = invitation.customerName || "Клиент"; + const orderItems = (invitation.orderItems || invitation.items || []) + .map(splitOrderItem) + .filter(Boolean); if (!isActive) { return ; @@ -36,16 +69,33 @@ export const DeliveryChoiceFlow = ({ return (
-

Клиентская ссылка

+

Согласование доставки

Выберите время доставки

{STATE_LABELS[state]}

- Заказ {orderNumber} для {customerName}. Выберите подходящую половину дня и подтвердите выбор. + Заказ {orderNumber} для {customerName}. Проверьте состав заказа и выберите удобную половину дня.

+ {orderItems.length ? ( +
+

Состав заказа

+
+ {orderItems.map((item) => ( +
+ {item.name} + {item.quantity ? {item.quantity} : null} +
+ ))} +
+
+ ) : null} +
{slots.map((slot) => (