Skip to content

Commit

Permalink
conditionally show/hide continue button on Confirmation component usi…
Browse files Browse the repository at this point in the history
…ng isFinalCard
  • Loading branch information
jessicamcinchak committed Dec 2, 2024
1 parent dc937a0 commit a5ce539
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ interface PresentationalProps extends Props {
}

export function Presentational(props: PresentationalProps) {
const isFinalCard = useStore().isFinalCard();
return (
<Box width="100%">
<Banner
Expand All @@ -99,7 +100,7 @@ export function Presentational(props: PresentationalProps) {
</Box>
)}
</Banner>
<Card>
<Card handleSubmit={isFinalCard ? undefined : props.handleSubmit}>
<SummaryListTable>
{Object.entries(props.applicableDetails).map(([k, v], i) => (
<React.Fragment key={`detail-${i}`}>
Expand Down
5 changes: 2 additions & 3 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,8 @@ export const previewStore: StateCreator<
},

isFinalCard: () => {
// Temporarily always returns false until upcomingCardIds is optimised
// OSL Slack explanation: https://bit.ly/3x38IRY
return false;
const { upcomingCardIds } = get();
return upcomingCardIds().length === 1;
},

restore: false,
Expand Down
17 changes: 7 additions & 10 deletions editor.planx.uk/src/pages/Preview/Node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,13 @@ interface Props {
}

const Node: React.FC<Props> = (props) => {
const [childNodesOf, isFinalCard, resetPreview, cachedBreadcrumbs] = useStore(
(state) => [
state.childNodesOf,
state.isFinalCard(),
state.resetPreview,
state.cachedBreadcrumbs,
],
);

const handleSubmit = isFinalCard ? undefined : props.handleSubmit;
const [childNodesOf, resetPreview, cachedBreadcrumbs] = useStore((state) => [
state.childNodesOf,
state.resetPreview,
state.cachedBreadcrumbs,
]);

const handleSubmit = props.handleSubmit;

const nodeId = props.node.id;
const previouslySubmittedData =
Expand Down

0 comments on commit a5ce539

Please sign in to comment.