Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PBError mas lindo #141

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")!}/>
}