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 = ({
|
||||
invitation = {},
|
||||
selectedSlot = null,
|
||||
isChoiceSaved = false,
|
||||
onConfirmChoice = () => {},
|
||||
onRequestNewLink = () => {},
|
||||
}) => {
|
||||
|
|
@ -62,24 +61,6 @@ export const DeliveryChoiceFlow = ({
|
|||
.map(splitOrderItem)
|
||||
.filter(Boolean);
|
||||
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) {
|
||||
return (
|
||||
|
|
@ -119,10 +100,7 @@ export const DeliveryChoiceFlow = ({
|
|||
</div>
|
||||
) : null}
|
||||
|
||||
{selectionCard}
|
||||
|
||||
<div className="flex flex-col gap-3 sm:flex-row">
|
||||
{!isLocked ? (
|
||||
<Button
|
||||
className="w-full sm:w-auto"
|
||||
disabled={!slotSummary}
|
||||
|
|
@ -130,13 +108,10 @@ export const DeliveryChoiceFlow = ({
|
|||
>
|
||||
Сохранить
|
||||
</Button>
|
||||
) : null}
|
||||
<Button variant="secondary" className="w-full sm:w-auto" onClick={onRequestNewLink}>
|
||||
Запросить новую ссылку
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{isChoiceSaved ? <DeliveryStateNotice state="agreed" /> : null}
|
||||
</Panel>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,19 +12,12 @@ describe("DeliveryChoiceFlow", () => {
|
|||
orderNumber: "CD-240031",
|
||||
customerName: "Мария Волкова",
|
||||
}}
|
||||
selectedSlot={{
|
||||
date: "2026-04-14",
|
||||
time: "До обеда",
|
||||
}}
|
||||
onConfirmChoice={() => {}}
|
||||
onRequestNewLink={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("Выберите время доставки");
|
||||
expect(markup).toContain("Выбрано");
|
||||
expect(markup).toContain("14.04.2026");
|
||||
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");
|
||||
});
|
||||
|
||||
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", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<DeliveryChoiceFlow
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ export const ClientDeliveryPage = () => {
|
|||
<p className="text-sm uppercase tracking-[0.24em] text-[var(--color-text-muted)]">Ваш выбор</p>
|
||||
<h2 className="text-xl font-semibold leading-tight">Сохранено: {savedChoiceLabel}</h2>
|
||||
<p className="text-sm leading-6 text-[var(--color-text-muted)]">
|
||||
При повторном открытии этой ссылки будет показан тот же выбор.
|
||||
Статус: доставка уже согласована. При повторном открытии этой ссылки будет показан тот же выбор.
|
||||
</p>
|
||||
</Panel>
|
||||
) : null}
|
||||
|
|
@ -257,17 +257,16 @@ export const ClientDeliveryPage = () => {
|
|||
/>
|
||||
) : null}
|
||||
|
||||
{isActiveState ? (
|
||||
{isActiveState && !isChoiceSaved ? (
|
||||
<DeliveryChoiceFlow
|
||||
invitation={invitation}
|
||||
selectedSlot={effectiveSelectedSlot}
|
||||
isChoiceSaved={isChoiceSaved}
|
||||
onConfirmChoice={handleSaveChoice}
|
||||
onRequestNewLink={handleRequestNewLink}
|
||||
/>
|
||||
) : (
|
||||
) : !isChoiceSaved ? (
|
||||
<DeliveryStateNotice state={invitationState} />
|
||||
)}
|
||||
) : null}
|
||||
|
||||
{actionMessage ? (
|
||||
<Panel className="p-5 text-sm leading-6 text-[var(--color-text-muted)] sm:p-6">{actionMessage}</Panel>
|
||||
|
|
|
|||
Loading…
Reference in New Issue