fix: merge saved delivery status into choice block
This commit is contained in:
parent
a867bf5464
commit
b3b8657b43
|
|
@ -50,7 +50,6 @@ const splitOrderItem = (item) => {
|
||||||
export const DeliveryChoiceFlow = ({
|
export const DeliveryChoiceFlow = ({
|
||||||
invitation = {},
|
invitation = {},
|
||||||
selectedSlot = null,
|
selectedSlot = null,
|
||||||
isChoiceSaved = false,
|
|
||||||
onConfirmChoice = () => {},
|
onConfirmChoice = () => {},
|
||||||
onRequestNewLink = () => {},
|
onRequestNewLink = () => {},
|
||||||
}) => {
|
}) => {
|
||||||
|
|
@ -62,24 +61,6 @@ export const DeliveryChoiceFlow = ({
|
||||||
.map(splitOrderItem)
|
.map(splitOrderItem)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
const slotSummary = selectedSlot ? formatDeliverySlotLabel(selectedSlot) : "";
|
const slotSummary = selectedSlot ? formatDeliverySlotLabel(selectedSlot) : "";
|
||||||
const isLocked = isChoiceSaved || !isActive;
|
|
||||||
|
|
||||||
const selectionCard = (
|
|
||||||
<div className="space-y-3 rounded-[22px] border border-[var(--color-border)] bg-[var(--color-surface-strong)] p-4">
|
|
||||||
<p className="text-sm uppercase tracking-[0.18em] text-[var(--color-text-muted)]">
|
|
||||||
Выбранный слот
|
|
||||||
</p>
|
|
||||||
{slotSummary && !isChoiceSaved ? (
|
|
||||||
<p className="text-sm leading-6">
|
|
||||||
<span className="font-medium">Выбрано:</span> {slotSummary}
|
|
||||||
</p>
|
|
||||||
) : (
|
|
||||||
<p className="text-sm leading-6 text-[var(--color-text-muted)]">
|
|
||||||
Выберите дату и половину дня выше, затем нажмите «Сохранить».
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!isActive) {
|
if (!isActive) {
|
||||||
return (
|
return (
|
||||||
|
|
@ -119,24 +100,18 @@ export const DeliveryChoiceFlow = ({
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{selectionCard}
|
|
||||||
|
|
||||||
<div className="flex flex-col gap-3 sm:flex-row">
|
<div className="flex flex-col gap-3 sm:flex-row">
|
||||||
{!isLocked ? (
|
<Button
|
||||||
<Button
|
className="w-full sm:w-auto"
|
||||||
className="w-full sm:w-auto"
|
disabled={!slotSummary}
|
||||||
disabled={!slotSummary}
|
onClick={() => onConfirmChoice(selectedSlot)}
|
||||||
onClick={() => onConfirmChoice(selectedSlot)}
|
>
|
||||||
>
|
Сохранить
|
||||||
Сохранить
|
</Button>
|
||||||
</Button>
|
|
||||||
) : null}
|
|
||||||
<Button variant="secondary" className="w-full sm:w-auto" onClick={onRequestNewLink}>
|
<Button variant="secondary" className="w-full sm:w-auto" onClick={onRequestNewLink}>
|
||||||
Запросить новую ссылку
|
Запросить новую ссылку
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isChoiceSaved ? <DeliveryStateNotice state="agreed" /> : null}
|
|
||||||
</Panel>
|
</Panel>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -12,19 +12,12 @@ describe("DeliveryChoiceFlow", () => {
|
||||||
orderNumber: "CD-240031",
|
orderNumber: "CD-240031",
|
||||||
customerName: "Мария Волкова",
|
customerName: "Мария Волкова",
|
||||||
}}
|
}}
|
||||||
selectedSlot={{
|
|
||||||
date: "2026-04-14",
|
|
||||||
time: "До обеда",
|
|
||||||
}}
|
|
||||||
onConfirmChoice={() => {}}
|
onConfirmChoice={() => {}}
|
||||||
onRequestNewLink={() => {}}
|
onRequestNewLink={() => {}}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(markup).toContain("Выберите время доставки");
|
expect(markup).toContain("Выберите время доставки");
|
||||||
expect(markup).toContain("Выбрано");
|
|
||||||
expect(markup).toContain("14.04.2026");
|
|
||||||
expect(markup).toContain("До обеда");
|
|
||||||
expect(markup).toContain("Сохранить");
|
expect(markup).toContain("Сохранить");
|
||||||
expect(markup).toContain("Ожидает ответа клиента");
|
expect(markup).toContain("Ожидает ответа клиента");
|
||||||
});
|
});
|
||||||
|
|
@ -42,29 +35,10 @@ describe("DeliveryChoiceFlow", () => {
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(markup).toContain("Выберите дату и половину дня");
|
expect(markup).toContain("Сохранить");
|
||||||
expect(markup).toContain("disabled");
|
expect(markup).toContain("disabled");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders a saved selection in read-only mode", () => {
|
|
||||||
const markup = renderToStaticMarkup(
|
|
||||||
<DeliveryChoiceFlow
|
|
||||||
invitation={{
|
|
||||||
state: "agreed",
|
|
||||||
orderNumber: "CD-240031",
|
|
||||||
customerName: "Мария Волкова",
|
|
||||||
}}
|
|
||||||
isChoiceSaved
|
|
||||||
onConfirmChoice={() => {}}
|
|
||||||
onRequestNewLink={() => {}}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(markup).toContain("Доставка уже согласована");
|
|
||||||
expect(markup).not.toContain("Выбранный слот");
|
|
||||||
expect(markup).not.toContain("Сохранить");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders order items with quantities when they are provided", () => {
|
it("renders order items with quantities when they are provided", () => {
|
||||||
const markup = renderToStaticMarkup(
|
const markup = renderToStaticMarkup(
|
||||||
<DeliveryChoiceFlow
|
<DeliveryChoiceFlow
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ export const ClientDeliveryPage = () => {
|
||||||
<p className="text-sm uppercase tracking-[0.24em] text-[var(--color-text-muted)]">Ваш выбор</p>
|
<p className="text-sm uppercase tracking-[0.24em] text-[var(--color-text-muted)]">Ваш выбор</p>
|
||||||
<h2 className="text-xl font-semibold leading-tight">Сохранено: {savedChoiceLabel}</h2>
|
<h2 className="text-xl font-semibold leading-tight">Сохранено: {savedChoiceLabel}</h2>
|
||||||
<p className="text-sm leading-6 text-[var(--color-text-muted)]">
|
<p className="text-sm leading-6 text-[var(--color-text-muted)]">
|
||||||
При повторном открытии этой ссылки будет показан тот же выбор.
|
Статус: доставка уже согласована. При повторном открытии этой ссылки будет показан тот же выбор.
|
||||||
</p>
|
</p>
|
||||||
</Panel>
|
</Panel>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
@ -257,17 +257,16 @@ export const ClientDeliveryPage = () => {
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{isActiveState ? (
|
{isActiveState && !isChoiceSaved ? (
|
||||||
<DeliveryChoiceFlow
|
<DeliveryChoiceFlow
|
||||||
invitation={invitation}
|
invitation={invitation}
|
||||||
selectedSlot={effectiveSelectedSlot}
|
selectedSlot={effectiveSelectedSlot}
|
||||||
isChoiceSaved={isChoiceSaved}
|
|
||||||
onConfirmChoice={handleSaveChoice}
|
onConfirmChoice={handleSaveChoice}
|
||||||
onRequestNewLink={handleRequestNewLink}
|
onRequestNewLink={handleRequestNewLink}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : !isChoiceSaved ? (
|
||||||
<DeliveryStateNotice state={invitationState} />
|
<DeliveryStateNotice state={invitationState} />
|
||||||
)}
|
) : null}
|
||||||
|
|
||||||
{actionMessage ? (
|
{actionMessage ? (
|
||||||
<Panel className="p-5 text-sm leading-6 text-[var(--color-text-muted)] sm:p-6">{actionMessage}</Panel>
|
<Panel className="p-5 text-sm leading-6 text-[var(--color-text-muted)] sm:p-6">{actionMessage}</Panel>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue