From 51532350cc6da97367a9eea7a8bd9c8c86a60e3c Mon Sep 17 00:00:00 2001 From: Stavros Date: Fri, 9 May 2025 16:25:12 +0300 Subject: [PATCH] feat: finalize pages --- frontend/src/components/ui/code.tsx | 22 +++++++ frontend/src/components/ui/oauth-button.tsx | 2 +- frontend/src/lib/i18n/locales/en-US.json | 16 ++--- frontend/src/lib/i18n/locales/en.json | 16 ++--- frontend/src/main.tsx | 14 ++++- frontend/src/pages/continue-page.tsx | 11 ++-- frontend/src/pages/error-page.tsx | 2 +- ...-password.tsx => forgot-password-page.tsx} | 2 +- frontend/src/pages/login-page.tsx | 24 ++++++-- frontend/src/pages/logout-page.tsx | 58 ++++++++++++++++++ frontend/src/pages/not-found-page.tsx | 2 +- frontend/src/pages/totp-page.tsx | 2 +- frontend/src/pages/unauthorized-page.tsx | 60 +++++++++++++++++++ frontend/src/utils/utils.ts | 3 + 14 files changed, 199 insertions(+), 35 deletions(-) create mode 100644 frontend/src/components/ui/code.tsx rename frontend/src/pages/{forgot-password.tsx => forgot-password-page.tsx} (93%) create mode 100644 frontend/src/pages/logout-page.tsx create mode 100644 frontend/src/pages/unauthorized-page.tsx create mode 100644 frontend/src/utils/utils.ts diff --git a/frontend/src/components/ui/code.tsx b/frontend/src/components/ui/code.tsx new file mode 100644 index 0000000..a4bc8cb --- /dev/null +++ b/frontend/src/components/ui/code.tsx @@ -0,0 +1,22 @@ +import { twMerge } from "tailwind-merge"; + +interface CodeProps extends React.ComponentPropsWithoutRef<"code"> { + children?: React.ReactNode; + className?: string; +} + +function Code({ children, className, ...props }: CodeProps) { + return ( + + {children} + + ); +} + +export { Code }; diff --git a/frontend/src/components/ui/oauth-button.tsx b/frontend/src/components/ui/oauth-button.tsx index c47ab6d..a817b78 100644 --- a/frontend/src/components/ui/oauth-button.tsx +++ b/frontend/src/components/ui/oauth-button.tsx @@ -16,7 +16,7 @@ export const OAuthButton = (props: Props) => { return ( + + + ); +}; diff --git a/frontend/src/pages/not-found-page.tsx b/frontend/src/pages/not-found-page.tsx index b4f010b..8f0c051 100644 --- a/frontend/src/pages/not-found-page.tsx +++ b/frontend/src/pages/not-found-page.tsx @@ -14,7 +14,7 @@ export const NotFoundPage = () => { const navigate = useNavigate(); return ( - + {t("notFoundTitle")} {t("notFoundSubtitle")} diff --git a/frontend/src/pages/totp-page.tsx b/frontend/src/pages/totp-page.tsx index 13ecb70..9862e47 100644 --- a/frontend/src/pages/totp-page.tsx +++ b/frontend/src/pages/totp-page.tsx @@ -20,7 +20,7 @@ export const TotpPage = () => { }; return ( - + {t("totpTitle")} {t("totpSubtitle")} diff --git a/frontend/src/pages/unauthorized-page.tsx b/frontend/src/pages/unauthorized-page.tsx new file mode 100644 index 0000000..540e20f --- /dev/null +++ b/frontend/src/pages/unauthorized-page.tsx @@ -0,0 +1,60 @@ +import { Button } from "@/components/ui/button"; +import { + Card, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { Code } from "@/components/ui/code"; +import { Trans, useTranslation } from "react-i18next"; +import { Navigate } from "react-router"; + +export const UnauthorizedPage = () => { + const searchParams = new URLSearchParams(window.location.search); + const username = searchParams.get("username"); + const resource = searchParams.get("resource"); + const groupErr = searchParams.get("groupErr"); + + const { t } = useTranslation(); + + if (!username) { + return ; + } + + let i18nKey = "unaothorizedLoginSubtitle"; + + if (resource) { + i18nKey = "unauthorizedResourceSubtitle"; + } + + if (groupErr === "true") { + i18nKey = "unauthorizedGroupsSubtitle"; + } + + return ( + + + {t("unauthorizedTitle")} + + , + }} + values={{ + username: username, + resource: resource, + }} + /> + + + + + + + ); +}; diff --git a/frontend/src/utils/utils.ts b/frontend/src/utils/utils.ts new file mode 100644 index 0000000..dbf7d10 --- /dev/null +++ b/frontend/src/utils/utils.ts @@ -0,0 +1,3 @@ +export const capitalize = (str: string) => { + return str.charAt(0).toUpperCase() + str.slice(1); +} \ No newline at end of file