From 76c03c37aba28d04912f2b18a96d0daad3b8c389 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Fri, 12 Jan 2024 15:16:22 +0000 Subject: [PATCH] fix: use email as default destination for new Send components and add warnings when selecting BOPS or Uniform (#2659) --- .../src/@planx/components/Send/Editor.tsx | 25 ++++++++++++++++--- .../src/@planx/components/Send/model.ts | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/Send/Editor.tsx b/editor.planx.uk/src/@planx/components/Send/Editor.tsx index d9e52a1662..58dfee02ff 100644 --- a/editor.planx.uk/src/@planx/components/Send/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Send/Editor.tsx @@ -73,6 +73,25 @@ const SendComponent: React.FC = (props) => { return originalValues.indexOf(a) - originalValues.indexOf(b); }), ); + + // Show warnings on selection of BOPS or Uniform for likely unsupported services + // Don't actually restrict selection because flowSlug matching is imperfect for some valid test cases + const flowSlug = window.location.pathname?.split("/")?.[1]; + if ( + value === Destination.BOPS && + newCheckedValues.includes(value) && + !["apply-for-a-lawful-development-certificate", "apply-for-prior-approval", "apply-for-planning-permission"].includes(flowSlug) + ) { + alert("BOPS only accepts Lawful Development Certificate, Prior Approval, and Planning Permission submissions. Please do not select if you're building another type of submission service!"); + } + + if ( + value === Destination.Uniform && + newCheckedValues.includes(value) && + flowSlug !== "apply-for-a-lawful-development-certificate" + ) { + alert("Uniform only accepts Lawful Development Certificate submissions. Please do not select if you're building another type of submission service!"); + } }; return ( @@ -109,10 +128,8 @@ const SendComponent: React.FC = (props) => { - API tokens are required to submit successfully to the selected - destinations. Check in with PlanX developers before launching your - service to make sure that tokens are available and configured for - your environment. + API tokens may be required to submit successfully. Check in with PlanX developers before launching your + service to make sure that submissions are configured for your environment. diff --git a/editor.planx.uk/src/@planx/components/Send/model.ts b/editor.planx.uk/src/@planx/components/Send/model.ts index 6debd0f5ca..a296c3dee7 100644 --- a/editor.planx.uk/src/@planx/components/Send/model.ts +++ b/editor.planx.uk/src/@planx/components/Send/model.ts @@ -13,7 +13,7 @@ export interface Send extends MoreInformation { } export const DEFAULT_TITLE = "Send"; -export const DEFAULT_DESTINATION = Destination.BOPS; +export const DEFAULT_DESTINATION = Destination.Email; export const parseContent = (data: Record | undefined): Send => ({ ...parseMoreInformation(data),