diff --git a/api.planx.uk/lib/hasura/metadata/index.ts b/api.planx.uk/lib/hasura/metadata/index.ts index e9a7b7eac5..dcc8d11ffc 100644 --- a/api.planx.uk/lib/hasura/metadata/index.ts +++ b/api.planx.uk/lib/hasura/metadata/index.ts @@ -11,7 +11,6 @@ interface ScheduledEvent { export interface CombinedResponse { bops?: ScheduledEventResponse; - bops_v2?: ScheduledEventResponse; uniform?: ScheduledEventResponse; email?: ScheduledEventResponse; } diff --git a/api.planx.uk/modules/admin/routes.ts b/api.planx.uk/modules/admin/routes.ts index b1deaf4051..f64f23dd5d 100644 --- a/api.planx.uk/modules/admin/routes.ts +++ b/api.planx.uk/modules/admin/routes.ts @@ -1,7 +1,6 @@ import { Router } from "express"; import { usePlatformAdminAuth } from "../auth/middleware"; import { getOneAppXML } from "./session/oneAppXML"; -import { getBOPSPayload } from "./session/bops"; import { getCSVData, getRedactedCSVData } from "./session/csv"; import { getHTMLExport, getRedactedHTMLExport } from "./session/html"; import { generateZip } from "./session/zip"; @@ -14,7 +13,6 @@ router.use("/admin/", usePlatformAdminAuth); // TODO: Split the routes below into controller and service components router.get("/admin/session/:sessionId/xml", getOneAppXML); -router.get("/admin/session/:sessionId/bops", getBOPSPayload); router.get("/admin/session/:sessionId/csv", getCSVData); router.get("/admin/session/:sessionId/csv-redacted", getRedactedCSVData); router.get("/admin/session/:sessionId/html", getHTMLExport); diff --git a/api.planx.uk/modules/admin/session/bops.test.ts b/api.planx.uk/modules/admin/session/bops.test.ts deleted file mode 100644 index 245ae59063..0000000000 --- a/api.planx.uk/modules/admin/session/bops.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -import supertest from "supertest"; -import app from "../../../server"; -import { authHeader } from "../../../tests/mockJWT"; -import { expectedPayload } from "../../../tests/mocks/bopsMocks"; - -const endpoint = (strings: TemplateStringsArray) => - `/admin/session/${strings[0]}/bops`; - -const mockGenerateBOPSPayload = jest.fn().mockResolvedValue(expectedPayload); - -jest.mock("@opensystemslab/planx-core", () => { - return { - CoreDomainClient: jest.fn().mockImplementation(() => ({ - export: { - bopsPayload: () => mockGenerateBOPSPayload(), - }, - })), - }; -}); - -describe("BOPS payload admin endpoint", () => { - it("requires a user to be logged in", async () => { - await supertest(app) - .get(endpoint`123`) - .expect(401) - .then((res) => - expect(res.body).toEqual({ - error: "No authorization token was found", - }), - ); - }); - - it("requires a user to have the 'platformAdmin' role", async () => { - await supertest(app) - .get(endpoint`123`) - .set(authHeader({ role: "teamEditor" })) - .expect(403); - }); - - it("returns an error if the BOPS payload generation fails", async () => { - mockGenerateBOPSPayload.mockRejectedValueOnce("Error!"); - - await supertest(app) - .get(endpoint`123`) - .set(authHeader({ role: "platformAdmin" })) - .expect(500) - .then((res) => { - expect(res.body.error).toMatch(/Failed to get BOPS payload/); - }); - }); - - it("returns a JSON payload", async () => { - await supertest(app) - .get(endpoint`123`) - .set(authHeader({ role: "platformAdmin" })) - .expect(200) - .expect("content-type", "application/json; charset=utf-8") - .then((res) => expect(res.body).toEqual(expectedPayload)); - }); -}); diff --git a/api.planx.uk/modules/admin/session/bops.ts b/api.planx.uk/modules/admin/session/bops.ts deleted file mode 100644 index bba3a61432..0000000000 --- a/api.planx.uk/modules/admin/session/bops.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { NextFunction, Request, Response } from "express"; -import { $api } from "../../../client"; - -/** - * @swagger - * /admin/session/{sessionId}/bops: - * get: - * summary: Generates a Back Office Planning System (BOPS) payload - * description: Generates a BOPS payload - * tags: - * - admin - * parameters: - * - $ref: '#/components/parameters/sessionId' - * security: - * - bearerAuth: [] - */ -export const getBOPSPayload = async ( - req: Request, - res: Response, - next: NextFunction, -) => { - try { - const exportData = await $api.export.bopsPayload(req.params.sessionId); - res.set("content-type", "application/json"); - return res.send(exportData); - } catch (error) { - return next({ - message: "Failed to get BOPS payload: " + (error as Error).message, - }); - } -}; diff --git a/api.planx.uk/modules/pay/service/inviteToPay/createPaymentSendEvents.ts b/api.planx.uk/modules/pay/service/inviteToPay/createPaymentSendEvents.ts index be9b803d32..55b550cee6 100644 --- a/api.planx.uk/modules/pay/service/inviteToPay/createPaymentSendEvents.ts +++ b/api.planx.uk/modules/pay/service/inviteToPay/createPaymentSendEvents.ts @@ -66,17 +66,6 @@ const createPaymentSendEvents = async ( comment: `bops_submission_${payload.sessionId}`, }); combinedResponse[Destination.BOPS] = bopsEvent; - - const isProduction = process.env.APP_ENVIRONMENT === "production"; - if (!isProduction) { - const bopsV2Event = await createScheduledEvent({ - webhook: `{{HASURA_PLANX_API_URL}}/bops-v2/${teamSlug}`, - schedule_at: new Date(now.getTime() + 30 * 1000), - payload: eventPayload, - comment: `bops_v2_submission_${payload.sessionId}`, - }); - combinedResponse["bops_v2"] = bopsV2Event; - } } if (destinations.includes(Destination.Email)) { diff --git a/api.planx.uk/modules/send/bops/bops.test.ts b/api.planx.uk/modules/send/bops/bops.test.ts index 92f676e2ca..b18d6ea8db 100644 --- a/api.planx.uk/modules/send/bops/bops.test.ts +++ b/api.planx.uk/modules/send/bops/bops.test.ts @@ -2,7 +2,6 @@ import nock from "nock"; import supertest from "supertest"; import { queryMock } from "../../../tests/graphqlQueryMock"; import app from "../../../server"; -import { expectedPayload } from "../../../tests/mocks/bopsMocks"; import { expectedPlanningPermissionPayload } from "../../../tests/mocks/digitalPlanningDataMocks"; jest.mock("../../saveAndReturn/service/utils", () => ({ @@ -18,11 +17,6 @@ jest.mock("@opensystemslab/planx-core", () => { CoreDomainClient: class extends actualCoreDomainClient { constructor() { super(); - this.export.bopsPayload = () => - jest.fn().mockResolvedValue({ - exportData: expectedPayload, - redactedExportData: expectedPayload, - }); this.export.digitalPlanningDataPayload = () => jest.fn().mockResolvedValue({ exportData: expectedPlanningPermissionPayload, @@ -32,135 +26,7 @@ jest.mock("@opensystemslab/planx-core", () => { }; }); -describe(`sending an application to BOPS`, () => { - const submissionURL = "https://test.bops-test.com"; - - beforeEach(() => { - queryMock.mockQuery({ - name: "FindApplication", - data: { - bopsApplications: [], - }, - variables: { - session_id: "123", - search_string: "%/api/v1/planning_applications", - }, - }); - - queryMock.mockQuery({ - name: "CreateBopsApplication", - matchOnVariables: false, - data: { - insertBopsApplication: { id: 22 }, - }, - }); - - queryMock.mockQuery({ - name: "GetStagingIntegrations", - data: { - teams: [ - { - integrations: { - bopsSubmissionURL: submissionURL, - bopsSecret: null, - }, - }, - ], - }, - variables: { - slug: "southwark", - }, - }); - - queryMock.mockQuery({ - name: "GetStagingIntegrations", - data: { - teams: [], - }, - variables: { - slug: "unsupported-team", - }, - }); - }); - - it("proxies request and returns hasura id", async () => { - nock(`${submissionURL}/api/v1/planning_applications`).post("").reply(200, { - application: "0000123", - }); - - await supertest(app) - .post("/bops/southwark") - .set({ Authorization: process.env.HASURA_PLANX_API_KEY! }) - .send({ payload: { sessionId: "123" } }) - .expect(200) - .then((res) => { - expect(res.body).toEqual({ - application: { id: 22, bopsResponse: { application: "0000123" } }, - }); - }); - }); - - it("requires auth", async () => { - await supertest(app) - .post("/bops/southwark") - .send({ payload: { sessionId: "123" } }) - .expect(401); - }); - - it("throws an error if payload is missing", async () => { - await supertest(app) - .post("/bops/southwark") - .set({ Authorization: process.env.HASURA_PLANX_API_KEY! }) - .send({ payload: null }) - .expect(400) - .then((res) => { - expect(res.body.error).toMatch(/Missing application/); - }); - }); - - it("throws an error if team is unsupported", async () => { - await supertest(app) - .post("/bops/unsupported-team") - .set({ Authorization: process.env.HASURA_PLANX_API_KEY! }) - .send({ payload: { sessionId: "123" } }) - .expect(500) - .then((res) => { - expect(res.body.error).toMatch( - /No team matching "unsupported-team" found/, - ); - }); - }); - - it("does not re-send an application which has already been submitted", async () => { - queryMock.mockQuery({ - name: "FindApplication", - data: { - bopsApplications: [ - { response: { message: "Application created", id: "bops_app_id" } }, - ], - }, - variables: { - session_id: "previously_submitted_app", - search_string: "%/api/v1/planning_applications", - }, - }); - - await supertest(app) - .post("/bops/southwark") - .set({ Authorization: process.env.HASURA_PLANX_API_KEY! }) - .send({ payload: { sessionId: "previously_submitted_app" } }) - .expect(200) - .then((res) => { - expect(res.body).toEqual({ - sessionId: "previously_submitted_app", - bopsId: "bops_app_id", - message: "Skipping send, already successfully submitted", - }); - }); - }); -}); - -describe(`sending an application to BOPS v2`, () => { +describe(`sending an application to BOPS (v2)`, () => { const submissionURL = "https://test.bops-test.com"; beforeEach(() => { @@ -224,7 +90,7 @@ describe(`sending an application to BOPS v2`, () => { }); await supertest(app) - .post("/bops-v2/southwark") + .post("/bops/southwark") .set({ Authorization: process.env.HASURA_PLANX_API_KEY! }) .send({ payload: { sessionId: "123" } }) .expect(200) @@ -240,14 +106,14 @@ describe(`sending an application to BOPS v2`, () => { it("requires auth", async () => { await supertest(app) - .post("/bops-v2/southwark") + .post("/bops/southwark") .send({ payload: { sessionId: "123" } }) .expect(401); }); it("throws an error if payload is missing", async () => { await supertest(app) - .post("/bops-v2/southwark") + .post("/bops/southwark") .set({ Authorization: process.env.HASURA_PLANX_API_KEY! }) .send({ payload: null }) .expect(400) @@ -258,7 +124,7 @@ describe(`sending an application to BOPS v2`, () => { it("throws an error if team is unsupported", async () => { await supertest(app) - .post("/bops-v2/unsupported-team") + .post("/bops/unsupported-team") .set({ Authorization: process.env.HASURA_PLANX_API_KEY! }) .send({ payload: { sessionId: "123" } }) .expect(500) @@ -284,7 +150,7 @@ describe(`sending an application to BOPS v2`, () => { }); await supertest(app) - .post("/bops-v2/southwark") + .post("/bops/southwark") .set({ Authorization: process.env.HASURA_PLANX_API_KEY! }) .send({ payload: { sessionId: "previously_submitted_app" } }) .expect(200) diff --git a/api.planx.uk/modules/send/bops/bops.ts b/api.planx.uk/modules/send/bops/bops.ts index 7cd7036a64..76f7539a05 100644 --- a/api.planx.uk/modules/send/bops/bops.ts +++ b/api.planx.uk/modules/send/bops/bops.ts @@ -30,134 +30,6 @@ const sendToBOPS = async (req: Request, res: Response, next: NextFunction) => { ); } - // confirm that this session has not already been successfully submitted before proceeding - const submittedApp = await checkBOPSAuditTable(payload?.sessionId, "v1"); - if (submittedApp?.message === "Application created") { - return res.status(200).send({ - sessionId: payload?.sessionId, - bopsId: submittedApp?.id, - message: `Skipping send, already successfully submitted`, - }); - } - - // confirm this local authority (aka team) is supported by BOPS before creating the proxy - // a local or staging API instance should send to the BOPS staging endpoint - // production should send to the BOPS production endpoint - const localAuthority = req.params.localAuthority; - const env = - process.env.APP_ENVIRONMENT === "production" ? "production" : "staging"; - - try { - const { bopsSubmissionURL, bopsToken } = await $api.team.getIntegrations({ - slug: localAuthority, - encryptionKey: process.env.ENCRYPTION_KEY!, - env, - }); - const target = `${bopsSubmissionURL}/api/v1/planning_applications`; - const exportData = await $api.export.bopsPayload(payload?.sessionId); - - const bopsResponse = await axios({ - method: "POST", - url: target, - adapter: "http", - headers: { - "Content-Type": "application/json", - Authorization: `Bearer ${bopsToken || process.env.BOPS_API_TOKEN}`, - }, - data: exportData, - }) - .then(async (res: AxiosResponse<{ id: string }>) => { - // Mark session as submitted so that reminder and expiry emails are not triggered - markSessionAsSubmitted(payload?.sessionId); - - const applicationId = await $api.client.request( - gql` - mutation CreateBopsApplication( - $bops_id: String = "" - $destination_url: String! - $request: jsonb! - $req_headers: jsonb = {} - $response: jsonb = {} - $response_headers: jsonb = {} - $session_id: String! - ) { - insertBopsApplication: insert_bops_applications_one( - object: { - bops_id: $bops_id - destination_url: $destination_url - request: $request - req_headers: $req_headers - response: $response - response_headers: $response_headers - session_id: $session_id - } - ) { - id - bopsId: bops_id - } - } - `, - { - bops_id: res.data.id, - destination_url: target, - request: exportData, - response: res.data, - response_headers: res.headers, - session_id: payload?.sessionId, - }, - ); - - return { - application: { - ...applicationId.insertBopsApplication, - bopsResponse: res.data, - }, - }; - }) - .catch((error) => { - if (error.response) { - throw new Error( - `Sending to BOPS failed (${localAuthority}):\n${JSON.stringify( - error.response.data, - null, - 2, - )}. Error: ${error}`, - ); - } else { - // re-throw other errors - throw new Error( - `Sending to BOPS failed (${localAuthority}):\n${error}`, - ); - } - }); - res.send(bopsResponse); - } catch (err) { - next( - new ServerError({ - status: 500, - message: `Sending to BOPS failed (${localAuthority}). Error ${err}`, - cause: err, - }), - ); - } -}; - -const sendToBOPSV2 = async ( - req: Request, - res: Response, - next: NextFunction, -) => { - // `/bops/:localAuthority` is only called via Hasura's scheduled event webhook now, so body is wrapped in a "payload" key - const { payload }: SendToBOPSRequest = req.body; - if (!payload) { - return next( - new ServerError({ - status: 400, - message: `Missing application payload data to send to BOPS`, - }), - ); - } - // confirm that this session has not already been successfully submitted before proceeding const submittedApp = await checkBOPSAuditTable(payload?.sessionId, "v2"); if (submittedApp?.message === "Application created") { @@ -270,7 +142,7 @@ const sendToBOPSV2 = async ( payload?.sessionId, ] .filter(Boolean) - .join(" - ")}). Error: ${err}`, + .join(" - ")}):\n${err}`, cause: err, }), ); @@ -314,4 +186,4 @@ async function checkBOPSAuditTable( return application?.bopsApplications[0]?.response; } -export { sendToBOPS, sendToBOPSV2 }; +export { sendToBOPS }; diff --git a/api.planx.uk/modules/send/createSendEvents/controller.ts b/api.planx.uk/modules/send/createSendEvents/controller.ts index 684bbbcfaa..1d1994da29 100644 --- a/api.planx.uk/modules/send/createSendEvents/controller.ts +++ b/api.planx.uk/modules/send/createSendEvents/controller.ts @@ -30,25 +30,17 @@ const createSendEvents: CreateSendEventsController = async ( if (bops) { const bopsEvent = await createScheduledEvent({ webhook: `{{HASURA_PLANX_API_URL}}/bops/${bops.localAuthority}`, - schedule_at: new Date(now.getTime() + 25 * 1000), + schedule_at: new Date(now.getTime() + 20 * 1000), payload: bops.body, comment: `bops_submission_${sessionId}`, }); combinedResponse["bops"] = bopsEvent; - - const bopsV2Event = await createScheduledEvent({ - webhook: `{{HASURA_PLANX_API_URL}}/bops-v2/${bops.localAuthority}`, - schedule_at: new Date(now.getTime() + 50 * 1000), - payload: bops.body, - comment: `bops_v2_submission_${sessionId}`, - }); - combinedResponse["bops_v2"] = bopsV2Event; } if (uniform) { const uniformEvent = await createScheduledEvent({ webhook: `{{HASURA_PLANX_API_URL}}/uniform/${uniform.localAuthority}`, - schedule_at: new Date(now.getTime() + 75 * 1000), + schedule_at: new Date(now.getTime() + 40 * 1000), payload: uniform.body, comment: `uniform_submission_${sessionId}`, }); diff --git a/api.planx.uk/modules/send/docs.yaml b/api.planx.uk/modules/send/docs.yaml index 67f3007e35..62e93dee30 100644 --- a/api.planx.uk/modules/send/docs.yaml +++ b/api.planx.uk/modules/send/docs.yaml @@ -22,24 +22,7 @@ components: paths: /bops/{localAuthority}: post: - summary: Submits an application to the Back Office Planning System (BOPS) - description: Submits an application to the Back Office Planning System (BOPS) - tags: - - send - parameters: - - $ref: "#/components/parameters/localAuthority" - security: - - hasuraAuth: [] - requestBody: - description: This endpoint is only called via Hasura's scheduled event webhook, so body is wrapped in a `payload` key - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/SessionPayload" - /bops-v2/{localAuthority}: - post: - summary: Submits an application to the Back Office Planning System (BOPS) v2 + summary: Submits an application to the Back Office Planning System (BOPS) (v2) description: Submits an application to the Back Office Planning System (BOPS) using the ODP Schema payload (v2) tags: - send diff --git a/api.planx.uk/modules/send/routes.ts b/api.planx.uk/modules/send/routes.ts index f17462070c..73f5974263 100644 --- a/api.planx.uk/modules/send/routes.ts +++ b/api.planx.uk/modules/send/routes.ts @@ -1,7 +1,7 @@ import { Router } from "express"; import { createSendEvents } from "./createSendEvents/controller"; import { useHasuraAuth } from "../auth/middleware"; -import { sendToBOPS, sendToBOPSV2 } from "./bops/bops"; +import { sendToBOPS } from "./bops/bops"; import { sendToUniform } from "./uniform/uniform"; import { sendToEmail } from "./email"; import { validate } from "../../shared/middleware/validate"; @@ -16,7 +16,6 @@ router.post( createSendEvents, ); router.post("/bops/:localAuthority", useHasuraAuth, sendToBOPS); -router.post("/bops-v2/:localAuthority", useHasuraAuth, sendToBOPSV2); router.post("/uniform/:localAuthority", useHasuraAuth, sendToUniform); router.post("/email-submission/:localAuthority", useHasuraAuth, sendToEmail); router.get("/download-application-files/:sessionId", downloadApplicationFiles); diff --git a/api.planx.uk/tests/mocks/bopsMocks.ts b/api.planx.uk/tests/mocks/bopsMocks.ts deleted file mode 100644 index 069fa0c3c0..0000000000 --- a/api.planx.uk/tests/mocks/bopsMocks.ts +++ /dev/null @@ -1,435 +0,0 @@ -export const expectedPayload = { - application_type: "lawfulness_certificate", - site: { - uprn: "200000797602", - address_1: "BUCKINGHAMSHIRE COUNCIL, COUNCIL OFFICES, QUEEN VICTORIA ROAD", - town: "HIGH WYCOMBE", - postcode: "HP11 1BB", - latitude: 51.6274191, - longitude: -0.7489513, - x: 486694, - y: 192808, - source: "os", - }, - files: [ - { - filename: - "http://localhost:7002/file/private/9n1yemif/Screenshot%20from%202023-04-27%2018-23-10.png", - tags: ["Proposed", "Elevation"], - }, - ], - proposal_details: [ - { - question: "What's your role", - responses: [ - { - value: "Applicant", - }, - ], - metadata: { - portal_name: "_root", - }, - }, - { - question: "Your contact details", - responses: [ - { - value: "jessica@opensystemslab.io Test Test 0123456789", - }, - ], - metadata: { - portal_name: "_root", - }, - }, - ], - result: { - flag: "Planning permission / No result", - heading: "No result", - description: "", - }, - user_role: "applicant", - applicant_first_name: "Test", - applicant_last_name: "Test", - applicant_phone: "0123456789", - applicant_email: "jessica@opensystemslab.io", - planx_debug_data: { - session_id: "123", - breadcrumbs: { - ENrGIt0No8: { - auto: false, - data: { - "proposal.elevation": [ - { - url: "http://localhost:7002/file/private/9n1yemif/Screenshot%20from%202023-04-27%2018-23-10.png", - filename: "Screenshot from 2023-04-27 18-23-10.png", - cachedSlot: { - id: "Yakp2kl_qAABEfO6ajSfm", - url: "http://localhost:7002/file/private/9n1yemif/Screenshot%20from%202023-04-27%2018-23-10.png", - file: { - path: "Screenshot from 2023-04-27 18-23-10.png", - size: 123336, - type: "image/png", - }, - status: "success", - progress: 1, - }, - }, - ], - }, - }, - LwaXZEGsoH: { - auto: false, - data: { - _address: { - x: 486694, - y: 192808, - pao: "", - town: "HIGH WYCOMBE", - uprn: "200000797602", - usrn: "45501554", - title: - "BUCKINGHAMSHIRE COUNCIL, COUNCIL OFFICES, QUEEN VICTORIA ROAD, HIGH WYCOMBE", - source: "os", - street: "QUEEN VICTORIA ROAD", - latitude: 51.6274191, - postcode: "HP11 1BB", - blpu_code: "2", - longitude: -0.7489513, - planx_value: "commercial.community.services", - organisation: "BUCKINGHAMSHIRE COUNCIL", - planx_description: "Community Service Centre / Office", - single_line_address: - "BUCKINGHAMSHIRE COUNCIL, COUNCIL OFFICES, QUEEN VICTORIA ROAD, HIGH WYCOMBE, BUCKINGHAMSHIRE, HP11 1BB", - }, - "property.type": ["commercial.community.services"], - "property.region": ["South East"], - "property.localAuthorityDistrict": ["Wycombe", "Buckinghamshire"], - }, - }, - Mz4ApW4Rtr: { - auto: false, - }, - VWvssepRJE: { - auto: false, - answers: ["3vnKtiiveY"], - }, - ZJEFlrhvLB: { - auto: false, - }, - nhucmh2x42: { - auto: false, - data: { - "applicant.email": "jessica@opensystemslab.io", - "_contact.applicant": { - applicant: { - email: "jessica@opensystemslab.io", - phone: "0123456789", - title: "", - lastName: "Test", - firstName: "Test", - organisation: "", - }, - }, - "applicant.name.last": "Test", - "applicant.name.first": "Test", - "applicant.phone.primary": "0123456789", - }, - }, - }, - passport: { - data: { - _address: { - x: 486694, - y: 192808, - pao: "", - town: "HIGH WYCOMBE", - uprn: "200000797602", - usrn: "45501554", - title: - "BUCKINGHAMSHIRE COUNCIL, COUNCIL OFFICES, QUEEN VICTORIA ROAD, HIGH WYCOMBE", - source: "os", - street: "QUEEN VICTORIA ROAD", - latitude: 51.6274191, - postcode: "HP11 1BB", - blpu_code: "2", - longitude: -0.7489513, - planx_value: "commercial.community.services", - organisation: "BUCKINGHAMSHIRE COUNCIL", - planx_description: "Community Service Centre / Office", - single_line_address: - "BUCKINGHAMSHIRE COUNCIL, COUNCIL OFFICES, QUEEN VICTORIA ROAD, HIGH WYCOMBE, BUCKINGHAMSHIRE, HP11 1BB", - }, - "user.role": ["applicant"], - "property.type": ["commercial.community.services"], - "applicant.email": "jessica@opensystemslab.io", - "property.region": ["South East"], - "_contact.applicant": { - applicant: { - email: "jessica@opensystemslab.io", - phone: "0123456789", - title: "", - lastName: "Test", - firstName: "Test", - organisation: "", - }, - }, - "proposal.elevation": [ - { - url: "http://localhost:7002/file/private/9n1yemif/Screenshot%20from%202023-04-27%2018-23-10.png", - filename: "Screenshot from 2023-04-27 18-23-10.png", - cachedSlot: { - id: "Yakp2kl_qAABEfO6ajSfm", - url: "http://localhost:7002/file/private/9n1yemif/Screenshot%20from%202023-04-27%2018-23-10.png", - file: { - path: "Screenshot from 2023-04-27 18-23-10.png", - size: 123336, - type: "image/png", - }, - status: "success", - progress: 1, - }, - }, - ], - "applicant.name.last": "Test", - "applicant.name.first": "Test", - "applicant.phone.primary": "0123456789", - "property.localAuthorityDistrict": ["Wycombe", "Buckinghamshire"], - }, - }, - }, -}; - -export const mockSession = { - id: "123", - flowId: "456", - data: { - id: "456", - passport: { - data: { - _address: { - x: 486694, - y: 192808, - pao: "", - town: "HIGH WYCOMBE", - uprn: "200000797602", - usrn: "45501554", - title: - "BUCKINGHAMSHIRE COUNCIL, COUNCIL OFFICES, QUEEN VICTORIA ROAD, HIGH WYCOMBE", - source: "os", - street: "QUEEN VICTORIA ROAD", - latitude: 51.6274191, - postcode: "HP11 1BB", - blpu_code: "2", - longitude: -0.7489513, - planx_value: "commercial.community.services", - organisation: "BUCKINGHAMSHIRE COUNCIL", - planx_description: "Community Service Centre / Office", - single_line_address: - "BUCKINGHAMSHIRE COUNCIL, COUNCIL OFFICES, QUEEN VICTORIA ROAD, HIGH WYCOMBE, BUCKINGHAMSHIRE, HP11 1BB", - }, - "user.role": ["applicant"], - "property.type": ["commercial.community.services"], - "applicant.email": "jessica@opensystemslab.io", - "property.region": ["South East"], - "_contact.applicant": { - applicant: { - email: "jessica@opensystemslab.io", - phone: "0123456789", - title: "", - lastName: "Test", - firstName: "Test", - organisation: "", - }, - }, - "proposal.elevation": [ - { - url: "http://localhost:7002/file/private/9n1yemif/Screenshot%20from%202023-04-27%2018-23-10.png", - filename: "Screenshot from 2023-04-27 18-23-10.png", - cachedSlot: { - id: "Yakp2kl_qAABEfO6ajSfm", - url: "http://localhost:7002/file/private/9n1yemif/Screenshot%20from%202023-04-27%2018-23-10.png", - file: { - path: "Screenshot from 2023-04-27 18-23-10.png", - size: 123336, - type: "image/png", - }, - status: "success", - progress: 1, - }, - }, - ], - "applicant.name.last": "Test", - "applicant.name.first": "Test", - "applicant.phone.primary": "0123456789", - "property.localAuthorityDistrict": ["Wycombe", "Buckinghamshire"], - }, - }, - breadcrumbs: { - ENrGIt0No8: { - auto: false, - data: { - "proposal.elevation": [ - { - url: "http://localhost:7002/file/private/9n1yemif/Screenshot%20from%202023-04-27%2018-23-10.png", - filename: "Screenshot from 2023-04-27 18-23-10.png", - cachedSlot: { - id: "Yakp2kl_qAABEfO6ajSfm", - url: "http://localhost:7002/file/private/9n1yemif/Screenshot%20from%202023-04-27%2018-23-10.png", - file: { - path: "Screenshot from 2023-04-27 18-23-10.png", - size: 123336, - type: "image/png", - }, - status: "success", - progress: 1, - }, - }, - ], - }, - }, - LwaXZEGsoH: { - auto: false, - data: { - _address: { - x: 486694, - y: 192808, - pao: "", - town: "HIGH WYCOMBE", - uprn: "200000797602", - usrn: "45501554", - title: - "BUCKINGHAMSHIRE COUNCIL, COUNCIL OFFICES, QUEEN VICTORIA ROAD, HIGH WYCOMBE", - source: "os", - street: "QUEEN VICTORIA ROAD", - latitude: 51.6274191, - postcode: "HP11 1BB", - blpu_code: "2", - longitude: -0.7489513, - planx_value: "commercial.community.services", - organisation: "BUCKINGHAMSHIRE COUNCIL", - planx_description: "Community Service Centre / Office", - single_line_address: - "BUCKINGHAMSHIRE COUNCIL, COUNCIL OFFICES, QUEEN VICTORIA ROAD, HIGH WYCOMBE, BUCKINGHAMSHIRE, HP11 1BB", - }, - "property.type": ["commercial.community.services"], - "property.region": ["South East"], - "property.localAuthorityDistrict": ["Wycombe", "Buckinghamshire"], - }, - }, - Mz4ApW4Rtr: { - auto: false, - }, - VWvssepRJE: { - auto: false, - answers: ["3vnKtiiveY"], - }, - ZJEFlrhvLB: { - auto: false, - }, - nhucmh2x42: { - auto: false, - data: { - "applicant.email": "jessica@opensystemslab.io", - "_contact.applicant": { - applicant: { - email: "jessica@opensystemslab.io", - phone: "0123456789", - title: "", - lastName: "Test", - firstName: "Test", - organisation: "", - }, - }, - "applicant.name.last": "Test", - "applicant.name.first": "Test", - "applicant.phone.primary": "0123456789", - }, - }, - }, - }, -}; - -export const mockFlow = { - _root: { - edges: [ - "LwaXZEGsoH", - "VWvssepRJE", - "ENrGIt0No8", - "ZJEFlrhvLB", - "Mz4ApW4Rtr", - ], - }, - "3vnKtiiveY": { - data: { - val: "applicant", - text: "Applicant", - }, - type: 200, - edges: ["nhucmh2x42"], - }, - ENrGIt0No8: { - data: { - fn: "proposal.elevation", - color: "#EFEFEF", - title: "Upload an elevation plan", - }, - type: 140, - }, - LwaXZEGsoH: { - data: { - allowNewAddresses: false, - }, - type: 9, - }, - Mz4ApW4Rtr: { - data: { - title: "Send", - destinations: ["bops"], - }, - type: 650, - }, - VWvssepRJE: { - data: { - fn: "user.role", - text: "What's your role", - }, - type: 100, - edges: ["3vnKtiiveY", "lPPqaETNmy", "jpAC5U7fBO"], - }, - ZJEFlrhvLB: { - data: { - title: "Check your answers before sending your application", - }, - type: 600, - }, - jpAC5U7fBO: { - data: { - val: "proxy", - text: "Proxy", - }, - type: 200, - edges: ["q8OLQUU6Mw"], - }, - lPPqaETNmy: { - data: { - val: "agent", - text: "Agent", - }, - type: 200, - edges: ["q8OLQUU6Mw"], - }, - nhucmh2x42: { - data: { - fn: "applicant", - title: "Your contact details", - }, - type: 135, - }, - q8OLQUU6Mw: { - data: { - fn: "agent", - title: "Your contact details", - }, - type: 135, - }, -}; diff --git a/editor.planx.uk/src/@planx/components/Send/Public.tsx b/editor.planx.uk/src/@planx/components/Send/Public.tsx index 992cc16fbd..a61699f0a8 100644 --- a/editor.planx.uk/src/@planx/components/Send/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Send/Public.tsx @@ -47,17 +47,9 @@ const SendComponent: React.FC = ({ isReady && props.handleSubmit ) { - const v1 = makeData( - props, - request.value.bops?.event_id, - "bopsSendEventId", - ); - const v2 = makeData( - props, - request.value.bops_v2?.event_id, - "bopsV2SendEventId", + props.handleSubmit( + makeData(props, request.value.bops?.event_id, "bopsSendEventId"), ); - props.handleSubmit({ ...v1, ...v2 }); } if (