From 5fc44042ce633f0cb1c5c787a109aa2bd2bea432 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Thu, 18 Jul 2024 05:07:33 +0530 Subject: [PATCH] feat(*): avoid extra DNS lookup, add note --- apps/frontend/app/lib/hooks.ts | 2 +- apps/frontend/app/lib/utilities.server.ts | 3 ++- apps/frontend/app/routes/_dashboard._index.tsx | 9 +++++++++ apps/frontend/app/routes/_dashboard.tsx | 11 ++++++++--- apps/frontend/app/routes/auth.tsx | 4 +--- ci/Caddyfile | 6 +++--- docs/includes/backend-config-schema.yaml | 4 ++++ libs/config/src/lib.rs | 2 ++ 8 files changed, 30 insertions(+), 11 deletions(-) diff --git a/apps/frontend/app/lib/hooks.ts b/apps/frontend/app/lib/hooks.ts index 5da575fdc5..83e090f4b8 100644 --- a/apps/frontend/app/lib/hooks.ts +++ b/apps/frontend/app/lib/hooks.ts @@ -115,7 +115,7 @@ export const useUserMetadataDetails = (metadataId?: string | null) => { return useQuery(getUserMetadataDetailsQuery(metadataId)); }; -const useDashboardLayoutData = () => { +export const useDashboardLayoutData = () => { const loaderData = useRouteLoaderData("routes/_dashboard"); return loaderData; diff --git a/apps/frontend/app/lib/utilities.server.ts b/apps/frontend/app/lib/utilities.server.ts index 91965049fd..355f29c70b 100644 --- a/apps/frontend/app/lib/utilities.server.ts +++ b/apps/frontend/app/lib/utilities.server.ts @@ -41,7 +41,7 @@ import { toastKey, } from "~/lib/generals"; -export const API_URL = process.env.API_URL || "http://localhost:8000/backend"; +export const API_URL = process.env.API_URL || "http://127.0.0.1:8000/backend"; class AuthenticatedGraphQLClient extends GraphQLClient { async authenticatedRequest( @@ -130,6 +130,7 @@ const expectedServerVariables = z.object({ FRONTEND_OIDC_BUTTON_LABEL: z .string() .default("Continue with OpenID Connect"), + FRONTEND_DASHBOARD_MESSAGE: z.string().optional(), }); /** diff --git a/apps/frontend/app/routes/_dashboard._index.tsx b/apps/frontend/app/routes/_dashboard._index.tsx index 41449fade3..4961dc2fbd 100644 --- a/apps/frontend/app/routes/_dashboard._index.tsx +++ b/apps/frontend/app/routes/_dashboard._index.tsx @@ -1,5 +1,6 @@ import { $path } from "@ignisda/remix-routes"; import { + Alert, Box, Center, Container, @@ -28,6 +29,7 @@ import { humanizeDuration, isNumber } from "@ryot/ts-utils"; import { IconBarbell, IconFriends, + IconInfoCircle, IconScaleOutline, IconServer, } from "@tabler/icons-react"; @@ -42,6 +44,7 @@ import { } from "~/components/media"; import { dayjsLib, getLot, getMetadataIcon } from "~/lib/generals"; import { + useDashboardLayoutData, useGetMantineColor, useUserPreferences, useUserUnitSystem, @@ -108,11 +111,17 @@ export default function Page() { const userPreferences = useUserPreferences(); const unitSystem = useUserUnitSystem(); const theme = useMantineTheme(); + const dashboardLayoutData = useDashboardLayoutData(); const latestUserSummary = loaderData.latestUserSummary.data; return ( + {dashboardLayoutData.envData.FRONTEND_DASHBOARD_MESSAGE ? ( + }> + {dashboardLayoutData.envData.FRONTEND_DASHBOARD_MESSAGE} + + ) : null} {userPreferences.general.dashboard.map((de) => match([de.section, de.hidden]) .with([DashboardElementLot.Upcoming, false], () => diff --git a/apps/frontend/app/routes/_dashboard.tsx b/apps/frontend/app/routes/_dashboard.tsx index bf4cdc3bd5..1cdfc12046 100644 --- a/apps/frontend/app/routes/_dashboard.tsx +++ b/apps/frontend/app/routes/_dashboard.tsx @@ -259,6 +259,9 @@ export const loader = unstable_defineLoader(async ({ request }) => { export function ErrorBoundary() { const error = useRouteError() as Error; + const message = isRouteErrorResponse(error) + ? error.data.message + : error.message; return ( @@ -266,9 +269,11 @@ export function ErrorBoundary() { We encountered an error - - {isRouteErrorResponse(error) ? error.data.message : error.message} - + {message ? ( + + {message} + + ) : null}