diff --git a/src/components/client/DeliveryChoiceFlow.jsx b/src/components/client/DeliveryChoiceFlow.jsx index 809483e..0d4ce58 100644 --- a/src/components/client/DeliveryChoiceFlow.jsx +++ b/src/components/client/DeliveryChoiceFlow.jsx @@ -50,6 +50,7 @@ const splitOrderItem = (item) => { export const DeliveryChoiceFlow = ({ invitation = {}, selectedSlot = null, + isChoiceSaved = false, onConfirmChoice = () => {}, onRequestNewLink = () => {}, }) => { @@ -61,13 +62,16 @@ export const DeliveryChoiceFlow = ({ .map(splitOrderItem) .filter(Boolean); const slotSummary = selectedSlot ? formatDeliverySlotLabel(selectedSlot) : ""; + const isLocked = isChoiceSaved || !isActive; const selectionCard = (
-

Выбранный слот

+

+ {isChoiceSaved ? "Сохранённый выбор" : "Выбранный слот"} +

{slotSummary ? (

- Выбрано: {slotSummary} + {isChoiceSaved ? "Сохранено:" : "Выбрано:"} {slotSummary}

) : (

@@ -119,17 +123,21 @@ export const DeliveryChoiceFlow = ({ {selectionCard}

- + {!isLocked ? ( + + ) : null}
+ + {isChoiceSaved ? : null} ); }; diff --git a/src/components/client/DeliveryChoiceFlow.test.jsx b/src/components/client/DeliveryChoiceFlow.test.jsx index c9f2bf2..85b3d73 100644 --- a/src/components/client/DeliveryChoiceFlow.test.jsx +++ b/src/components/client/DeliveryChoiceFlow.test.jsx @@ -46,6 +46,30 @@ describe("DeliveryChoiceFlow", () => { expect(markup).toContain("disabled"); }); + it("renders a saved selection in read-only mode", () => { + const markup = renderToStaticMarkup( + {}} + onRequestNewLink={() => {}} + />, + ); + + expect(markup).toContain("Сохранённый выбор"); + expect(markup).toContain("14.04.2026"); + expect(markup).toContain("До обеда"); + expect(markup).not.toContain("Сохранить"); + }); + it("renders order items with quantities when they are provided", () => { const markup = renderToStaticMarkup( { const [actionMessage, setActionMessage] = React.useState(""); const [selectedSlotId, setSelectedSlotId] = React.useState(null); const [selectedSlot, setSelectedSlot] = React.useState(null); + const [choiceSaved, setChoiceSaved] = React.useState(false); React.useEffect(() => { let cancelled = false; @@ -98,6 +99,10 @@ export const ClientDeliveryPage = () => { setLoading(true); setError(""); + setActionMessage(""); + setSelectedSlotId(null); + setSelectedSlot(null); + setChoiceSaved(false); try { const loadedInvitation = await fetchDeliveryInvitation(token); @@ -137,6 +142,7 @@ export const ClientDeliveryPage = () => { ); const effectiveSelectedSlot = selectedSlot || invitationSelectedSlot; + const isChoiceSaved = choiceSaved || (!isActiveState && Boolean(invitationSelectedSlot)); const handleSaveChoice = React.useCallback( async () => { @@ -150,6 +156,7 @@ export const ClientDeliveryPage = () => { } setActionMessage("Сохраняем выбор..."); + setChoiceSaved(false); setError(""); try { @@ -161,6 +168,7 @@ export const ClientDeliveryPage = () => { const loadedInvitation = await fetchDeliveryInvitation(token); setInvitation(loadedInvitation); setSelectedSlot(buildSelectedSlotFromInvitation(loadedInvitation, groupSlotsFromInvitation(loadedInvitation)) || effectiveSelectedSlot); + setChoiceSaved(true); setActionMessage("Выбор сохранен, спасибо."); } catch (confirmError) { setActionMessage(""); @@ -174,6 +182,7 @@ export const ClientDeliveryPage = () => { (slot) => { setSelectedSlotId(slot.id); setSelectedSlot(slot); + setChoiceSaved(false); setActionMessage( `Выбрано: ${slot.date ? `${formatDeliveryDate(slot.date)} / ${slot.time}` : slot.time}`, ); @@ -227,7 +236,7 @@ export const ClientDeliveryPage = () => {

- {isActiveState && slots.length ? ( + {isActiveState && !isChoiceSaved && slots.length ? ( {