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

Frontend: implemented useNavigate hook at required loactions #90

Merged
merged 1 commit into from
Jun 11, 2024
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: 4 additions & 1 deletion frontend/src/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react';
import Button from './library/button';
import './index.css';
import { useNavigate } from 'react-router-dom';

type NavbarProps = {
isLoggedIn?: boolean;
Expand All @@ -17,6 +18,8 @@ const Navbar: React.FC<NavbarProps> = ({
}) => {
const [isOpen, setIsOpen] = useState(false);

const navigate = useNavigate();

const toggleMenu = () => {
setIsOpen(!isOpen);
};
Expand Down Expand Up @@ -92,7 +95,7 @@ const Navbar: React.FC<NavbarProps> = ({
buttonSize="w-[170px] h-12"
px="px-0"
onClick={() => {
window.location.href = '/error';
navigate('/error');
}}
/>
</div>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/pages/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import ErrorImage from '../assets/tornCard.svg';
import Button from '../library/button';
import { useNavigate } from 'react-router-dom';

function Error() {
const navigate = useNavigate();
return (
<div className="min-h-screen w-full flex items-center justify-center bg-white">
<div className="grid grid-rows-3 justify-items-center text-center gap-4 max-w-[400px] p-8 text-[#333333] md:grid-cols-2 md:gap-2 md:gap-x-14 md:max-w-screen-xl lg:gap-x-20">
Expand All @@ -26,7 +28,7 @@ function Error() {
buttonSize="w-80 h-12"
className="border-4"
rounded="rounded-full"
onClick={() => (window.location.href = '/')}
onClick={() => navigate('/')}
/>
</div>
</div>
Expand Down
Loading