diff --git a/js/apps/account-ui/maven-resources/theme/keycloak.v3/account/messages/messages_en.properties b/js/apps/account-ui/maven-resources/theme/keycloak.v3/account/messages/messages_en.properties index 3f37d8fb068..882986fb458 100644 --- a/js/apps/account-ui/maven-resources/theme/keycloak.v3/account/messages/messages_en.properties +++ b/js/apps/account-ui/maven-resources/theme/keycloak.v3/account/messages/messages_en.properties @@ -95,6 +95,7 @@ deleteAccount=Delete account permissionRequest=Permission requests - {{name}} add=Add error-invalid-value='{{0}}' has invalid value. +pageNotFound=The requested page was not found. somethingWentWrong=Something went wrong somethingWentWrongDescription=Sorry, an unexpected error has occurred. tryAgain=Try again diff --git a/js/apps/account-ui/src/root/Root.tsx b/js/apps/account-ui/src/root/Root.tsx index 0c2afb47d16..47c1e159167 100644 --- a/js/apps/account-ui/src/root/Root.tsx +++ b/js/apps/account-ui/src/root/Root.tsx @@ -1,12 +1,15 @@ import { ErrorPage, + useAlerts, useEnvironment, KeycloakContext, } from "@keycloak/keycloak-ui-shared"; -import { Page, Spinner } from "@patternfly/react-core"; -import { Suspense, useState } from "react"; +import { AlertVariant, Page, Spinner } from "@patternfly/react-core"; +import { Suspense, useEffect, useState } from "react"; +import { useTranslation } from "react-i18next"; import { createBrowserRouter, + Navigate, Outlet, RouteObject, RouterProvider, @@ -45,6 +48,17 @@ function mapRoutes( .flat(); } +function CatchAllRedirect() { + const { t } = useTranslation(); + const { addAlert } = useAlerts(); + + useEffect(() => { + addAlert(t("pageNotFound"), AlertVariant.warning); + }, [addAlert, t]); + + return ; +} + export const Root = () => { const context = useEnvironment(); const [content, setContent] = useState(); @@ -65,7 +79,10 @@ export const Root = () => { ), errorElement: , - children: mapRoutes(context, content), + children: [ + ...mapRoutes(context, content), + { path: "*", element: }, + ], }, ]); },