From 164b76fad806b078aad8c537ba9bdcfbfc757dca Mon Sep 17 00:00:00 2001 From: physcik Date: Tue, 5 May 2026 11:39:54 +0500 Subject: css changes + error handling --- front/src/ErrorHandler.tsx | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 front/src/ErrorHandler.tsx (limited to 'front/src/ErrorHandler.tsx') diff --git a/front/src/ErrorHandler.tsx b/front/src/ErrorHandler.tsx new file mode 100644 index 0000000..177a9d0 --- /dev/null +++ b/front/src/ErrorHandler.tsx @@ -0,0 +1,37 @@ +import { useContext } from "react"; +import { useRouteError } from "react-router"; +import { AllowedLanguages, LanguageContext } from "./Locales/Context"; +import { GetLocalizedString } from "./Locales/Locales"; + +type RouteError = { + status: number, + statusText: string, + internal: boolean, + data: string +}; + +function ErrorHandler() { + const language = useContext(LanguageContext); + let error = useRouteError() as RouteError; + + if (error.status == 403) + return forbid(language); + + return ( +
+

{error.status} {error.statusText}

+
+ ); +} + + +function forbid(language: AllowedLanguages) { + return ( +
+

{ GetLocalizedString("Forbidden", language) }

+

{ GetLocalizedString("*forbidden*", language) }

+
+ ); +} + +export default ErrorHandler; -- cgit v1.3