From be5661bcb948d571f08755e0c7fbefd58435dc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20L=C3=B3pez=20Alvas?= Date: Wed, 15 Nov 2023 18:39:34 -0300 Subject: [PATCH 1/2] prettier errors --- locales/en-us/pageNotFound.json | 3 ++- locales/es-ar/pageNotFound.json | 3 ++- locales/pt-br/pageNotFound.json | 3 ++- src/components/PBError.tsx | 7 ++++++- src/components/pageNotFound/PageNotFound.tsx | 14 ++++++++++---- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/locales/en-us/pageNotFound.json b/locales/en-us/pageNotFound.json index c6e736d0..488af48c 100644 --- a/locales/en-us/pageNotFound.json +++ b/locales/en-us/pageNotFound.json @@ -1,5 +1,6 @@ { "title": "Page not found", "text": "The page you are trying to access does not exist.", - "home": "Go to home page" + "home": "Go to home page", + "errorOcurred": "An error occurred (✖╭╮✖)" } diff --git a/locales/es-ar/pageNotFound.json b/locales/es-ar/pageNotFound.json index dd4a2317..65519f25 100644 --- a/locales/es-ar/pageNotFound.json +++ b/locales/es-ar/pageNotFound.json @@ -1,5 +1,6 @@ { "title": "Página no encontrada", "text": "La página a la que intentás acceder no existe.", - "home": "Ir al inicio" + "home": "Ir al inicio", + "errorOcurred": "Ocurrió un error (✖╭╮✖)" } diff --git a/locales/pt-br/pageNotFound.json b/locales/pt-br/pageNotFound.json index 9ba56d0a..65d8bc62 100644 --- a/locales/pt-br/pageNotFound.json +++ b/locales/pt-br/pageNotFound.json @@ -1,5 +1,6 @@ { "title": "Página não encontrada", "text": "A página que você está tentando acessar não existe.", - "home": "Vá para iniciar" + "home": "Vá para iniciar", + "errorOcurred": "Um erro ocorreu (✖╭╮✖)" } diff --git a/src/components/PBError.tsx b/src/components/PBError.tsx index 996add09..6448e750 100644 --- a/src/components/PBError.tsx +++ b/src/components/PBError.tsx @@ -1,6 +1,11 @@ import { useRouteError } from "react-router-dom"; +import { PageNotFound } from "./pageNotFound/PageNotFound"; +import { useTranslation } from "react-i18next"; export const PBError = () => { + const {t} = useTranslation("pageNotFound") + const error = useRouteError() as any - return

Ocurrio un error (✖╭╮✖): {error.message}

+ + return } \ No newline at end of file diff --git a/src/components/pageNotFound/PageNotFound.tsx b/src/components/pageNotFound/PageNotFound.tsx index 9ed00366..1ab7b50f 100644 --- a/src/components/pageNotFound/PageNotFound.tsx +++ b/src/components/pageNotFound/PageNotFound.tsx @@ -4,15 +4,21 @@ import { useTranslation } from "react-i18next"; import { Header } from "../header/Header" import styles from "./pageNotFound.module.css" -export const PageNotFound = () =>{ +type PageNotFoundProps = { + title?: string, + error?: string, +} + +export const PageNotFound = (props: PageNotFoundProps) =>{ const {t} = useTranslation("pageNotFound") + return <>
- {t("title")} + {props.title ? props.title : t("title")} capy - {t("text")} - + {props.error ? props.error : t("text")} + From 3e7fc97e8eeb65fa3848cb0ee2c7941d72cb2d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diana=20L=C3=B3pez=20Alvas?= Date: Wed, 15 Nov 2023 18:49:53 -0300 Subject: [PATCH 2/2] error refactor --- locales/en-us/pageNotFound.json | 6 ---- locales/en-us/pbError.json | 8 ++++++ locales/es-ar/pageNotFound.json | 6 ---- locales/es-ar/pbError.json | 8 ++++++ locales/pt-br/pageNotFound.json | 6 ---- locales/pt-br/pbError.json | 8 ++++++ src/App.tsx | 2 +- src/components/PBError.tsx | 11 -------- ...NotFound.module.css => PBError.module.css} | 0 src/components/pageNotFound/PBError.tsx | 28 +++++++++++++++++++ src/components/pageNotFound/PageNotFound.tsx | 26 +++-------------- 11 files changed, 57 insertions(+), 52 deletions(-) delete mode 100644 locales/en-us/pageNotFound.json create mode 100644 locales/en-us/pbError.json delete mode 100644 locales/es-ar/pageNotFound.json create mode 100644 locales/es-ar/pbError.json delete mode 100644 locales/pt-br/pageNotFound.json create mode 100644 locales/pt-br/pbError.json delete mode 100644 src/components/PBError.tsx rename src/components/pageNotFound/{pageNotFound.module.css => PBError.module.css} (100%) create mode 100644 src/components/pageNotFound/PBError.tsx diff --git a/locales/en-us/pageNotFound.json b/locales/en-us/pageNotFound.json deleted file mode 100644 index 488af48c..00000000 --- a/locales/en-us/pageNotFound.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "title": "Page not found", - "text": "The page you are trying to access does not exist.", - "home": "Go to home page", - "errorOcurred": "An error occurred (✖╭╮✖)" -} diff --git a/locales/en-us/pbError.json b/locales/en-us/pbError.json new file mode 100644 index 00000000..d9e8c642 --- /dev/null +++ b/locales/en-us/pbError.json @@ -0,0 +1,8 @@ +{ + "home": "Go to home page", + "errorOcurred": "An error occurred (✖╭╮✖)", + "pageNotFound": { + "title": "Page not found", + "text": "The page you are trying to access does not exist." + } +} diff --git a/locales/es-ar/pageNotFound.json b/locales/es-ar/pageNotFound.json deleted file mode 100644 index 65519f25..00000000 --- a/locales/es-ar/pageNotFound.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "title": "Página no encontrada", - "text": "La página a la que intentás acceder no existe.", - "home": "Ir al inicio", - "errorOcurred": "Ocurrió un error (✖╭╮✖)" -} diff --git a/locales/es-ar/pbError.json b/locales/es-ar/pbError.json new file mode 100644 index 00000000..86527157 --- /dev/null +++ b/locales/es-ar/pbError.json @@ -0,0 +1,8 @@ +{ + "home": "Ir al inicio", + "errorOcurred": "Ocurrió un error (✖╭╮✖)", + "pageNotFound": { + "title": "Página no encontrada", + "text": "La página a la que intentás acceder no existe." + } +} \ No newline at end of file diff --git a/locales/pt-br/pageNotFound.json b/locales/pt-br/pageNotFound.json deleted file mode 100644 index 65d8bc62..00000000 --- a/locales/pt-br/pageNotFound.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "title": "Página não encontrada", - "text": "A página que você está tentando acessar não existe.", - "home": "Vá para iniciar", - "errorOcurred": "Um erro ocorreu (✖╭╮✖)" -} diff --git a/locales/pt-br/pbError.json b/locales/pt-br/pbError.json new file mode 100644 index 00000000..e62e919f --- /dev/null +++ b/locales/pt-br/pbError.json @@ -0,0 +1,8 @@ +{ + "home": "Vá para iniciar", + "errorOcurred": "Um erro ocorreu (✖╭╮✖)", + "pageNotFound": { + "title": "Página não encontrada", + "text": "A página que você está tentando acessar não existe." + } +} \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 2d761383..a4272f72 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,7 +3,7 @@ import React, { useEffect } from 'react'; import './App.css'; import { createHashRouter, RouterProvider, Outlet } from "react-router-dom"; import { Home } from './components/home/Home'; -import { PBError } from './components/PBError'; +import { PBError } from './components/pageNotFound/PBError'; import { ChallengeById, ChallengeByName } from './components/ChallengeView'; import { BookView } from './components/book/BookView'; import { ImportedChallengeView } from './components/ImportedChallengeView'; diff --git a/src/components/PBError.tsx b/src/components/PBError.tsx deleted file mode 100644 index 6448e750..00000000 --- a/src/components/PBError.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { useRouteError } from "react-router-dom"; -import { PageNotFound } from "./pageNotFound/PageNotFound"; -import { useTranslation } from "react-i18next"; - -export const PBError = () => { - const {t} = useTranslation("pageNotFound") - - const error = useRouteError() as any - - return -} \ No newline at end of file diff --git a/src/components/pageNotFound/pageNotFound.module.css b/src/components/pageNotFound/PBError.module.css similarity index 100% rename from src/components/pageNotFound/pageNotFound.module.css rename to src/components/pageNotFound/PBError.module.css diff --git a/src/components/pageNotFound/PBError.tsx b/src/components/pageNotFound/PBError.tsx new file mode 100644 index 00000000..45756981 --- /dev/null +++ b/src/components/pageNotFound/PBError.tsx @@ -0,0 +1,28 @@ +import { Typography, Button, Stack } from "@mui/material" +import { Link, useRouteError } from "react-router-dom"; +import { useTranslation } from "react-i18next"; +import styles from "./PBError.module.css" +import { Header } from "../header/Header"; + +type PbErrorProps = { + title?: string, + error?: string, +} + +export const PBError = (props: PbErrorProps) =>{ + const {t} = useTranslation("pbError") + + const error = useRouteError() as any + + return <> +
+ + {props.title ? props.title : t("errorOcurred")} + capy + {props.error ? props.error : error.message} + + + + + +} \ No newline at end of file diff --git a/src/components/pageNotFound/PageNotFound.tsx b/src/components/pageNotFound/PageNotFound.tsx index 1ab7b50f..1083b883 100644 --- a/src/components/pageNotFound/PageNotFound.tsx +++ b/src/components/pageNotFound/PageNotFound.tsx @@ -1,26 +1,8 @@ -import { Typography, Button, Stack } from "@mui/material" -import { Link } from "react-router-dom"; import { useTranslation } from "react-i18next"; -import { Header } from "../header/Header" -import styles from "./pageNotFound.module.css" +import { PBError } from "./PBError"; -type PageNotFoundProps = { - title?: string, - error?: string, -} +export const PageNotFound = () =>{ + const {t} = useTranslation("pbError") -export const PageNotFound = (props: PageNotFoundProps) =>{ - const {t} = useTranslation("pageNotFound") - - return <> -
- - {props.title ? props.title : t("title")} - capy - {props.error ? props.error : t("text")} - - - - - + return } \ No newline at end of file