Skip to content

Commit

Permalink
hide SaveAndReturnButton if breadcrumbs have Send
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Dec 3, 2024
1 parent 62bcbc6 commit 6f4fcf1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions editor.planx.uk/src/@planx/components/shared/Preview/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,23 @@ const Card: React.FC<Props> = ({
...props
}) => {
const theme = useTheme();
const [path, visibleNode] = useStore((state) => [
const [path, visibleNode, breadcrumbs, flow] = useStore((state) => [
state.path,
state.currentCard,
state.breadcrumbs,
state.flow,
]);

// Check if we have a Send node in our breadcrumbs
// In the frontend this is a better/more immediate proxy for "Submitted" because actual send events that populate lowcal_sessions.submitted_at are async
const hasSent = Object.keys(breadcrumbs)
.reverse()
.some(
(breadcrumbNodeId: string) => flow[breadcrumbNodeId]?.type === TYPES.Send,
);

const showSaveResumeButton =
path === ApplicationPath.SaveAndReturn &&
handleSubmit &&
visibleNode?.type !== TYPES.Confirmation;
path === ApplicationPath.SaveAndReturn && handleSubmit && !hasSent;
const { track } = useAnalyticsTracking();

useEffect(() => {
Expand Down

0 comments on commit 6f4fcf1

Please sign in to comment.