Skip to content

Commit

Permalink
wip: More debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 7, 2023
1 parent f7dde37 commit 7e1d876
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
22 changes: 9 additions & 13 deletions editor.planx.uk/src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { logger } from "airbrake";
import { lazy, map, mount, redirect, route } from "navi";
import * as React from "react";

Expand Down Expand Up @@ -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,
});
2 changes: 2 additions & 0 deletions editor.planx.uk/src/routes/pay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -46,6 +47,7 @@ const payRoutes = compose(

mount({
"/": route(async (req) => {
console.log("inside pay mount");
const paymentRequest = await getPaymentRequest(req);
if (!paymentRequest) {
return {
Expand Down
1 change: 1 addition & 0 deletions editor.planx.uk/src/routes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 7e1d876

Please sign in to comment.