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

feat: Added Route Not Found #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CompaniesList } from "./pages/CompaniesList";
import { CreateCompany } from "./pages/CreateCompany";
import { UpdateCompany } from "./pages/UpdateCompany";
import { ForgotPassword } from "./pages/ForgotPassword";
import { NotFound } from "./pages/NotFound";
import { Login } from "./pages/Login";
import "./styles.css";

Expand All @@ -19,6 +20,7 @@ const Layout: FC = () => {
<Route path="/companies" element={<CompaniesList />} />
<Route path="/companies/new" element={<CreateCompany />} />
<Route path="/companies/:id" element={<UpdateCompany />} />
<Route path="*" element={<NotFound />} />
</Routes>
<Footer />
</AntLayout>
Expand Down
57 changes: 57 additions & 0 deletions frontend/src/pages/NotFound/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Layout, Typography } from "antd";
import { FC, useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { Button } from "../../components/Button";
import { ACCESS_TOKEN_KEY } from "../../config";
import "./styles.css";

export const NotFound: FC = () => {
const navigate = useNavigate();

const [isUserLogged, setIsUserLogged] = useState<boolean>(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useState(localStorage[ACCESS_TOKEN_KEY] ? true : false)


const [animateParagraph, setAnimateParagraph] = useState<boolean>(false);
const [animateButton, setAnimateButton] = useState<boolean>(false);

useEffect(() => {
setIsUserLogged(localStorage[ACCESS_TOKEN_KEY] ? true : false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this


setTimeout(() => {
setAnimateParagraph(true);

setTimeout(() => {
setAnimateButton(true);
}, 800);
}, 800);
}, []);

const handleRedirect = () => navigate(isUserLogged ? "/companies" : "/");

return (
<Layout.Content className="content">
<div className="container">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use Space component from antd and see if it works correctly

<Typography.Title className="title element-animation">
Ups, parece que andas perdido.
</Typography.Title>
<Typography.Paragraph
className={
animateParagraph ? "element-animation paragraph" : "paragraph"
}
>
Mas não te preocupes, nós ajudamos-te a voltar ao caminho certo.
</Typography.Paragraph>

{animateButton && (
<div className="element-animation">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with Space

<Button
htmlType="button"
styles={{ width: "100px", height: "40px" }}
onClick={handleRedirect}
children="Voltar"
/>
</div>
)}
</div>
</Layout.Content>
);
};
34 changes: 34 additions & 0 deletions frontend/src/pages/NotFound/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.container {
background-color: #ffffff !important;
display: flex;
align-items: center;
flex-direction: column;
padding-top: 24%;
}

.title {
font-size: 2.5rem !important;
font-weight: 700;
}

.paragraph {
font-size: 1.1rem;
font-weight: 500;
opacity: 0;
}

.element-animation {
animation: renderTextAnimation 1s ease-in-out;
opacity: 1;
}

@keyframes renderTextAnimation {
0% {
opacity: 0;
transform: translateY(40px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}