Skip to content

Commit

Permalink
Merge pull request #141 from Program-AR/pb-error
Browse files Browse the repository at this point in the history
PBError mas lindo
  • Loading branch information
dlopezalvas authored Nov 16, 2023
2 parents 2af48b8 + 3e7fc97 commit 8d1ad4b
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 38 deletions.
5 changes: 0 additions & 5 deletions locales/en-us/pageNotFound.json

This file was deleted.

8 changes: 8 additions & 0 deletions locales/en-us/pbError.json
Original file line number Diff line number Diff line change
@@ -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."
}
}
5 changes: 0 additions & 5 deletions locales/es-ar/pageNotFound.json

This file was deleted.

8 changes: 8 additions & 0 deletions locales/es-ar/pbError.json
Original file line number Diff line number Diff line change
@@ -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."
}
}
5 changes: 0 additions & 5 deletions locales/pt-br/pageNotFound.json

This file was deleted.

8 changes: 8 additions & 0 deletions locales/pt-br/pbError.json
Original file line number Diff line number Diff line change
@@ -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."
}
}
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 0 additions & 6 deletions src/components/PBError.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions src/components/pageNotFound/PBError.tsx
Original file line number Diff line number Diff line change
@@ -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 <>
<Header/>
<Stack direction='column' alignItems='center'>
<Typography className={styles.title} variant="h4">{props.title ? props.title : t("errorOcurred")}</Typography>
<img alt="capy" className={styles.image} src='imagenes/capy_error.png' />
<Typography className={styles.text} variant="h6">{props.error ? props.error : error.message}</Typography>
<Link to="/">
<Button variant="contained" color="success" >{t("home")}</Button>
</Link>
</Stack>
</>
}
20 changes: 4 additions & 16 deletions src/components/pageNotFound/PageNotFound.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +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";

export const PageNotFound = () =>{
const {t} = useTranslation("pageNotFound")
return <>
<Header/>
<Stack direction='column' alignItems='center'>
<Typography className={styles.title} variant="h4">{t("title")}</Typography>
<img alt="capy" className={styles.image} src='imagenes/capy_error.png' />
<Typography className={styles.text} variant="h6">{t("text")}</Typography>
<Link to="">
<Button variant="contained" color="success" >{t("home")}</Button>
</Link>
</Stack>
</>
const {t} = useTranslation("pbError")

return <PBError title={t("pageNotFound.title")!} error={t("pageNotFound.text")!}/>
}

0 comments on commit 8d1ad4b

Please sign in to comment.