diff --git a/editor.planx.uk/src/@planx/components/Send/Editor.tsx b/editor.planx.uk/src/@planx/components/Send/Editor.tsx index b9e26605f1..5935e66fb0 100644 --- a/editor.planx.uk/src/@planx/components/Send/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Send/Editor.tsx @@ -57,6 +57,14 @@ const SendComponent: React.FC = (props) => { }, ]; + // Show S3 option on staging only + if (process.env.REACT_APP_ENV !== "production") { + options.push({ + value: Destination.S3, + label: "Upload to AWS S3 bucket", + }); + } + const changeCheckbox = (value: Destination) => (_checked: any) => { let newCheckedValues: Destination[]; @@ -76,7 +84,8 @@ const SendComponent: React.FC = (props) => { // 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]; + const teamSlug = window.location.pathname?.split("/")?.[1]; + const flowSlug = window.location.pathname?.split("/")?.[2]; if ( value === Destination.BOPS && newCheckedValues.includes(value) && @@ -94,10 +103,21 @@ const SendComponent: React.FC = (props) => { if ( value === Destination.Uniform && newCheckedValues.includes(value) && - flowSlug !== "apply-for-a-lawful-development-certificate" + flowSlug !== "apply-for-a-lawful-development-certificate" && + !["buckinghamshire", "lambeth", "southwark"].includes(teamSlug) + ) { + alert( + "Uniform is only enabled for Bucks, Lambeth and Southwark to accept Lawful Development Certificate submissions. Please do not select if you're building another type of submission service!", + ); + } + + if ( + value === Destination.S3 && + newCheckedValues.includes(value) && + teamSlug !== "barnet" ) { alert( - "Uniform only accepts Lawful Development Certificate submissions. Please do not select if you're building another type of submission service!", + "AWS S3 uploads are currently being prototyped with Barnet only. Please do not select this option for other councils yet.", ); } }; diff --git a/editor.planx.uk/src/@planx/components/Send/Public.tsx b/editor.planx.uk/src/@planx/components/Send/Public.tsx index a61699f0a8..265b9b2697 100644 --- a/editor.planx.uk/src/@planx/components/Send/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Send/Public.tsx @@ -71,6 +71,16 @@ const SendComponent: React.FC = ({ makeData(props, request.value.email?.event_id, "emailSendEventId"), ); } + + if ( + destinations.includes(Destination.S3) && + isReady && + props.handleSubmit + ) { + props.handleSubmit( + makeData(props, request.value.s3?.event_id, "s3SendEventId"), + ); + } }, [request.loading, request.error, request.value]); if (request.loading) { diff --git a/editor.planx.uk/src/@planx/components/Send/model.ts b/editor.planx.uk/src/@planx/components/Send/model.ts index 5c126e9021..31350e3dc5 100644 --- a/editor.planx.uk/src/@planx/components/Send/model.ts +++ b/editor.planx.uk/src/@planx/components/Send/model.ts @@ -5,6 +5,7 @@ export enum Destination { BOPS = "bops", Uniform = "uniform", Email = "email", + S3 = "s3", } export interface Send extends MoreInformation { @@ -71,5 +72,12 @@ export function getCombinedEventsPayload({ }; } + if (destinations.includes(Destination.S3)) { + combinedEventsPayload[Destination.S3] = { + localAuthority: teamSlug, + body: { sessionId }, + }; + } + return combinedEventsPayload; }