From fb6edfd609cbd22e90eee5b6336ce5eda24da259 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Mon, 6 Jan 2025 13:49:26 +0000 Subject: [PATCH] add handleSubmit to show logic for saveandresume --- .../src/@planx/components/shared/Preview/Card.tsx | 4 +--- .../components/shared/Preview/OrNavigationButton.tsx | 12 +++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/shared/Preview/Card.tsx b/editor.planx.uk/src/@planx/components/shared/Preview/Card.tsx index 3cf946e0cd..92b2505f37 100644 --- a/editor.planx.uk/src/@planx/components/shared/Preview/Card.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Preview/Card.tsx @@ -15,8 +15,6 @@ interface Props { handleSubmit?: (data?: any) => void; } -export type OrNavigationType = "save-resume" | "navigate-to-published"; - export const contentFlowSpacing = (theme: Theme): React.CSSProperties => ({ marginTop: theme.spacing(2), [theme.breakpoints.up("md")]: { @@ -88,7 +86,7 @@ const Card: React.FC = ({ Continue )} - + diff --git a/editor.planx.uk/src/@planx/components/shared/Preview/OrNavigationButton.tsx b/editor.planx.uk/src/@planx/components/shared/Preview/OrNavigationButton.tsx index 8ef36da09b..a367e4bb4a 100644 --- a/editor.planx.uk/src/@planx/components/shared/Preview/OrNavigationButton.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Preview/OrNavigationButton.tsx @@ -6,10 +6,12 @@ import { useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { ApplicationPath } from "types"; -import { contentFlowSpacing, OrNavigationType } from "./Card"; +import { contentFlowSpacing } from "./Card"; import NavigateToPublishedButton from "./NavigateToPublishedButton"; import SaveResumeButton from "./SaveResumeButton"; +type OrNavigationType = "save-resume" | "navigate-to-published"; + export const InnerContainer = styled(Box)(({ theme }) => ({ "& p": { ...contentFlowSpacing(theme), @@ -21,7 +23,11 @@ const BUTTON_COMPONENTS = { "navigate-to-published": NavigateToPublishedButton, } as const; -const OrNavigationButton = () => { +const OrNavigationButton = ({ + handleSubmit, +}: { + handleSubmit: ((data?: any) => void) | undefined; +}) => { const [path, breadcrumbs, flow] = useStore((state) => [ state.path, state.breadcrumbs, @@ -41,7 +47,7 @@ const OrNavigationButton = () => { ); const showSaveResumeButton = - path === ApplicationPath.SaveAndReturn && !hasSent; + path === ApplicationPath.SaveAndReturn && handleSubmit && !hasSent; if (showSaveResumeButton && !isTestEnvironment) { return "save-resume";