diff --git a/apps/trust/src/pages/auth/AuthLayout.tsx b/apps/trust/src/pages/auth/AuthLayout.tsx index a60cc13d4..67debdf0e 100644 --- a/apps/trust/src/pages/auth/AuthLayout.tsx +++ b/apps/trust/src/pages/auth/AuthLayout.tsx @@ -1,17 +1,48 @@ +import { useSystemTheme } from "@probo/hooks"; import { Logo } from "@probo/ui"; -import type { PropsWithChildren } from "react"; +import { type PreloadedQuery, usePreloadedQuery } from "react-relay"; +import { Outlet } from "react-router"; +import { graphql } from "relay-runtime"; -export function AuthLayout(props: PropsWithChildren) { - const { children } = props; +import type { AuthLayoutQuery } from "./__generated__/AuthLayoutQuery.graphql"; + +export const authLayoutQuery = graphql` + query AuthLayoutQuery { + currentTrustCenter @required(action: THROW) { + logoFileUrl + darkLogoFileUrl + } + } +`; + +export function AuthLayout(props: { queryRef: PreloadedQuery }) { + const { queryRef } = props; + + const { currentTrustCenter: compliancePage } = usePreloadedQuery(authLayoutQuery, queryRef); + const theme = useSystemTheme(); + + const logoFileUrl = theme === "dark" + ? compliancePage.darkLogoFileUrl ?? compliancePage.logoFileUrl + : compliancePage.logoFileUrl; return (
-
{children}
+
+ +
- + {logoFileUrl + ? ( + + ) + : }
diff --git a/apps/trust/src/pages/auth/AuthLayoutLoader.tsx b/apps/trust/src/pages/auth/AuthLayoutLoader.tsx new file mode 100644 index 000000000..2c9db8ed7 --- /dev/null +++ b/apps/trust/src/pages/auth/AuthLayoutLoader.tsx @@ -0,0 +1,29 @@ +import { useEffect } from "react"; +import { useQueryLoader } from "react-relay"; + +import { RelayProvider } from "#/providers/RelayProviders"; + +import type { AuthLayoutQuery } from "./__generated__/AuthLayoutQuery.graphql"; +import { AuthLayout, authLayoutQuery } from "./AuthLayout"; + +function AuthLayoutQueryLoader() { + const [queryRef, loadQuery] = useQueryLoader(authLayoutQuery); + + useEffect(() => { + if (!queryRef) { + return loadQuery({}); + } + }); + + if (!queryRef) return null; + + return ; +} + +export default function AuthLayoutLoader() { + return ( + + + + ); +} diff --git a/apps/trust/src/pages/auth/ConnectPage.tsx b/apps/trust/src/pages/auth/ConnectPage.tsx index 5d325e685..00a844498 100644 --- a/apps/trust/src/pages/auth/ConnectPage.tsx +++ b/apps/trust/src/pages/auth/ConnectPage.tsx @@ -14,7 +14,6 @@ import { useFormWithSchema } from "#/hooks/useFormWithSchema"; import type { ConnectPageMutation } from "./__generated__/ConnectPageMutation.graphql"; import type { ConnectPageQuery } from "./__generated__/ConnectPageQuery.graphql"; -import { AuthLayout } from "./AuthLayout"; export const connectPageQuery = graphql` query ConnectPageQuery { @@ -126,49 +125,47 @@ export function ConnectPage(props: { }); return ( - -
-
-

- {__(`Connect to ${organization.name}'s compliance page`)} -

-

+

+
+

+ {__(`Connect to ${organization.name}'s compliance page`)} +

+

+ {__( + "Enter your email address to connect with a magic link and start requesting access to documents", + )} +

+
+ +
void handleSubmit(e)} className="space-y-4"> + + + {magicLinkSent && ( +

{__( - "Enter your email address to connect with a magic link and start requesting access to documents", + "Magic Link Sent! Check your emails and use the link to connect.", )}

-
+ )} - void handleSubmit(e)} className="space-y-4"> - - - {magicLinkSent && ( -

- {__( - "Magic Link Sent! Check your emails and use the link to connect.", - )} -

- )} - - - -
- + + +
); } diff --git a/apps/trust/src/pages/auth/VerifyMagicLinkPage.tsx b/apps/trust/src/pages/auth/VerifyMagicLinkPage.tsx index df4016a84..72843ce8d 100644 --- a/apps/trust/src/pages/auth/VerifyMagicLinkPage.tsx +++ b/apps/trust/src/pages/auth/VerifyMagicLinkPage.tsx @@ -12,7 +12,6 @@ import { useFormWithSchema } from "#/hooks/useFormWithSchema"; import { getPathPrefix } from "#/utils/pathPrefix"; import type { VerifyMagicLinkPageMutation } from "./__generated__/VerifyMagicLinkPageMutation.graphql"; -import { AuthLayout } from "./AuthLayout"; const verifyMagicLinkMutation = graphql` mutation VerifyMagicLinkPageMutation($input: VerifyMagicLinkInput!) { @@ -87,39 +86,37 @@ export default function VerifyMagicLinkPagePageMutation() { }); return ( - -
-
-

{__("Email Confirmation")}

-

- {__("Confirm your email address to complete registration")} -

-
- -
void handleSubmit(e)} className="space-y-4"> - - - - +
+
+

{__("Email Confirmation")}

+

+ {__("Confirm your email address to complete registration")} +

- + +
void handleSubmit(e)} className="space-y-4"> + + + + +
); } diff --git a/apps/trust/src/pages/auth/__generated__/AuthLayoutQuery.graphql.ts b/apps/trust/src/pages/auth/__generated__/AuthLayoutQuery.graphql.ts new file mode 100644 index 000000000..687ed9cb1 --- /dev/null +++ b/apps/trust/src/pages/auth/__generated__/AuthLayoutQuery.graphql.ts @@ -0,0 +1,108 @@ +/** + * @generated SignedSource<> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest } from 'relay-runtime'; +export type AuthLayoutQuery$variables = Record; +export type AuthLayoutQuery$data = { + readonly currentTrustCenter: { + readonly darkLogoFileUrl: string | null | undefined; + readonly logoFileUrl: string | null | undefined; + }; +}; +export type AuthLayoutQuery = { + response: AuthLayoutQuery$data; + variables: AuthLayoutQuery$variables; +}; + +const node: ConcreteRequest = (function(){ +var v0 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "logoFileUrl", + "storageKey": null +}, +v1 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "darkLogoFileUrl", + "storageKey": null +}; +return { + "fragment": { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "AuthLayoutQuery", + "selections": [ + { + "kind": "RequiredField", + "field": { + "alias": null, + "args": null, + "concreteType": "TrustCenter", + "kind": "LinkedField", + "name": "currentTrustCenter", + "plural": false, + "selections": [ + (v0/*: any*/), + (v1/*: any*/) + ], + "storageKey": null + }, + "action": "THROW" + } + ], + "type": "Query", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": [], + "kind": "Operation", + "name": "AuthLayoutQuery", + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "TrustCenter", + "kind": "LinkedField", + "name": "currentTrustCenter", + "plural": false, + "selections": [ + (v0/*: any*/), + (v1/*: any*/), + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + } + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "92bbf193e99aa98673d1926bd1fdc890", + "id": null, + "metadata": {}, + "name": "AuthLayoutQuery", + "operationKind": "query", + "text": "query AuthLayoutQuery {\n currentTrustCenter {\n logoFileUrl\n darkLogoFileUrl\n id\n }\n}\n" + } +}; +})(); + +(node as any).hash = "d76b10f9b919f4224c4c8b478e66b4f1"; + +export default node; diff --git a/apps/trust/src/routes.tsx b/apps/trust/src/routes.tsx index d59352ce6..841c1b756 100644 --- a/apps/trust/src/routes.tsx +++ b/apps/trust/src/routes.tsx @@ -1,10 +1,11 @@ +import { lazy } from "@probo/react-lazy"; import { type AppRoute, loaderFromQueryLoader, routeFromAppRoute, withQueryRef, } from "@probo/routes"; -import { Fragment, lazy } from "react"; +import { Fragment } from "react"; import { loadQuery } from "react-relay"; import { createBrowserRouter, redirect, useRouteError } from "react-router"; @@ -34,12 +35,17 @@ function ErrorBoundary() { const routes = [ { - path: "/connect", - Component: lazy(() => import("./pages/auth/ConnectPageLoader")), - }, - { - path: "/verify-magic-link", - Component: lazy(() => import("./pages/auth/VerifyMagicLinkPage")), + Component: lazy(() => import("#/pages/auth/AuthLayoutLoader")), + children: [ + { + path: "/connect", + Component: lazy(() => import("#/pages/auth/ConnectPageLoader")), + }, + { + path: "/verify-magic-link", + Component: lazy(() => import("#/pages/auth/VerifyMagicLinkPage")), + }, + ], }, { path: "/",