diff --git a/editor.planx.uk/src/components/Header.tsx b/editor.planx.uk/src/components/Header.tsx index 4a45b0425b..f61bcec605 100644 --- a/editor.planx.uk/src/components/Header.tsx +++ b/editor.planx.uk/src/components/Header.tsx @@ -42,6 +42,7 @@ import Reset from "ui/icons/Reset"; import { useStore } from "../pages/FlowEditor/lib/store"; import { rootFlowPath, rootTeamPath } from "../routes/utils"; import AnalyticsDisabledBanner from "./AnalyticsDisabledBanner"; +import { ConfirmationDialog } from "./ConfirmationDialog"; import FeatureFlagBanner from "./FeatureFlagBanner"; import TestEnvironmentBanner from "./TestEnvironmentBanner"; @@ -323,12 +324,12 @@ const PublicToolbar: React.FC<{ const { trackFlowDirectionChange } = useAnalyticsTracking(); - const handleRestart = async () => { - if ( - confirm( - "Are you sure you want to restart? This will delete your previous answers", - ) - ) { + const [isDialogOpen, setIsDialogOpen] = useState(false); + const openConfirmationDialog = () => setIsDialogOpen(true); + + const handleRestart = (isConfirmed: boolean) => { + setIsDialogOpen(false); + if (isConfirmed) { trackFlowDirectionChange("reset"); if (path === ApplicationPath.SingleSession) { clearLocalFlow(id); @@ -358,7 +359,7 @@ const PublicToolbar: React.FC<{ {showResetButton && ( @@ -378,6 +379,18 @@ const PublicToolbar: React.FC<{ + + + Are you sure you want to restart? This will delete your previous + answers + + ); }; @@ -415,14 +428,12 @@ const EditorToolbar: React.FC<{ setOpen(!open); }; - const isFlowSettingsVisible = - route.data.flow && canUserEditTeam(team.slug); + const isFlowSettingsVisible = route.data.flow && canUserEditTeam(team.slug); const isTeamSettingsVisible = route.data.team && !route.data.flow && canUserEditTeam(team.slug); - const isGlobalSettingsVisible = - !route.data.team && user?.isPlatformAdmin; + const isGlobalSettingsVisible = !route.data.team && user?.isPlatformAdmin; return ( <>