From 7e1d876253a53b6d0d88b90a1c9977bac54334f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Sat, 7 Oct 2023 13:07:16 +0100 Subject: [PATCH] wip: More debugging --- editor.planx.uk/src/routes/index.tsx | 22 +++++++++------------- editor.planx.uk/src/routes/pay.tsx | 2 ++ editor.planx.uk/src/routes/utils.ts | 1 + 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/editor.planx.uk/src/routes/index.tsx b/editor.planx.uk/src/routes/index.tsx index cbcb28b0f5..8a7d8048fd 100644 --- a/editor.planx.uk/src/routes/index.tsx +++ b/editor.planx.uk/src/routes/index.tsx @@ -1,4 +1,3 @@ -import { logger } from "airbrake"; import { lazy, map, mount, redirect, route } from "navi"; import * as React from "react"; @@ -57,28 +56,25 @@ const editorRoutes = mount({ ), }); -const mountPayRoutes = () => - map(async () => { - try { - return lazy(() => import("./pay")); - } catch (error) { - console.log("ERROR MOUNTING PAY ROUTES"); - logger.notify(error); - throw Error(`error in pay mount: ${error}`); - } - }); +const tryImport = () => { + try { + return lazy(() => import("./pay")); + } catch (error) { + throw Error(`ERROR MOUNTING PAY ROUTES (LAZY): ${error}`); + } +}; export default isPreviewOnlyDomain ? mount({ "/:team/:flow/preview": lazy(() => import("./preview")), // XXX: keeps old URL working, but only for the team listed in the domain. "/:flow": lazy(() => import("./preview")), - "/:flow/pay": mountPayRoutes(), + "/:flow/pay": tryImport(), // XXX: We're not sure where to redirect `/` to so for now we'll just return the default 404 // "/": redirect("somewhere?"), }) : mount({ "/:team/:flow/preview": lazy(() => import("./preview")), // loads published flow if exists, or current flow "/:team/:flow/unpublished": lazy(() => import("./unpublished")), // loads current flow - "/:team/:flow/pay": mountPayRoutes(), + "/:team/:flow/pay": tryImport(), "*": editorRoutes, }); diff --git a/editor.planx.uk/src/routes/pay.tsx b/editor.planx.uk/src/routes/pay.tsx index d7e9fe3368..1b1cc5cdf9 100644 --- a/editor.planx.uk/src/routes/pay.tsx +++ b/editor.planx.uk/src/routes/pay.tsx @@ -21,6 +21,7 @@ import standaloneView from "./views/standalone"; const payRoutes = compose( withData(async (req) => { + console.log("inside pay withData"); try { const externalDomainTeam = await getTeamFromDomain( window.location.hostname, @@ -46,6 +47,7 @@ const payRoutes = compose( mount({ "/": route(async (req) => { + console.log("inside pay mount"); const paymentRequest = await getPaymentRequest(req); if (!paymentRequest) { return { diff --git a/editor.planx.uk/src/routes/utils.ts b/editor.planx.uk/src/routes/utils.ts index 9822188c8a..4e7541f12b 100644 --- a/editor.planx.uk/src/routes/utils.ts +++ b/editor.planx.uk/src/routes/utils.ts @@ -90,6 +90,7 @@ export const getTeamFromDomain = pMemoize(async (domain: string) => { * e.g. https://planningservices.southwark.gov.uk/lambeth/some-flow/preview */ export const validateTeamRoute = async (req: NaviRequest) => { + console.log("inside ValidateTeamRoute"); const externalTeamName = await getTeamFromDomain(window.location.hostname); if ( req.params.team &&