diff options
| author | physcik <mynameisgennadiy@vk.com> | 2026-05-05 11:39:54 +0500 |
|---|---|---|
| committer | physcik <mynameisgennadiy@vk.com> | 2026-05-05 11:39:54 +0500 |
| commit | 164b76fad806b078aad8c537ba9bdcfbfc757dca (patch) | |
| tree | 9e3d38765c307a88792c8e98c22a4d4673a03e40 /front/src/ErrorHandler.tsx | |
| parent | b82265994c5f72c40f68c6b3a4960869b6a67951 (diff) | |
css changes + error handling
Diffstat (limited to 'front/src/ErrorHandler.tsx')
| -rw-r--r-- | front/src/ErrorHandler.tsx | 37 |
1 files changed, 37 insertions, 0 deletions
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 ( + <div> + <h1> {error.status} {error.statusText} </h1> + </div> + ); +} + + +function forbid(language: AllowedLanguages) { + return ( + <div> + <h1> { GetLocalizedString("Forbidden", language) } </h1> + <p> { GetLocalizedString("*forbidden*", language) } </p> + </div> + ); +} + +export default ErrorHandler; |
