From 035aa7b3d75945226d20e643dc54184aa2838a16 Mon Sep 17 00:00:00 2001 From: david Date: Sun, 15 Mar 2026 18:45:27 +0300 Subject: [PATCH] style frontend components --- frontend/src/App.tsx | 25 ++++++- frontend/src/components/Navbar.tsx | 82 +++++++++++++++++++-- frontend/src/components/icons/CloseIcon.tsx | 18 +++++ frontend/src/components/icons/MenuIcon.tsx | 19 +++++ frontend/src/hooks/useAuth.ts | 2 - frontend/src/pages/Home.tsx | 2 +- 6 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 frontend/src/components/icons/CloseIcon.tsx create mode 100644 frontend/src/components/icons/MenuIcon.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 4bfe05f..faf9ae7 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,6 @@ import { Routes, Route, Navigate } from 'react-router-dom'; +import { useEffect, useState } from 'react'; +import { useApp } from './context/AppContext'; import { ModalProvider } from './context/modals/useModal'; import { ModalRoot } from './context/modals/ModalRoot'; import { ToastProvider } from './context/toasts/useToast'; @@ -17,15 +19,34 @@ import { BoardDetail } from './pages/BoardDetail'; import { CardDetail } from './pages/CardDetail'; const App = () => { + const { token } = useApp(); + const [isAuthenticated, setIsAuthenticated] = useState(null); + + useEffect(() => { + setIsAuthenticated(!!token); + }, [token]); + + if (isAuthenticated === null) { + return null; + } return (
-
+
- } /> + + ) : ( + + ) + } + /> } /> } /> } /> diff --git a/frontend/src/components/Navbar.tsx b/frontend/src/components/Navbar.tsx index ca3cab1..942b937 100644 --- a/frontend/src/components/Navbar.tsx +++ b/frontend/src/components/Navbar.tsx @@ -1,27 +1,31 @@ import { Link } from 'react-router-dom'; +import { useState } from 'react'; import { useApp } from '../context/AppContext'; import { useAuth } from '../hooks/useAuth'; import { TaskboardLogo } from './TaskboardLogo'; +import MenuIcon from './icons/MenuIcon'; +import CloseIcon from './icons/CloseIcon'; export function Navbar() { const { user } = useApp(); const { logout } = useAuth(); + const [mobileMenuOpen, setMobileMenuOpen] = useState(false); return ( ); } diff --git a/frontend/src/components/icons/CloseIcon.tsx b/frontend/src/components/icons/CloseIcon.tsx new file mode 100644 index 0000000..9e69f38 --- /dev/null +++ b/frontend/src/components/icons/CloseIcon.tsx @@ -0,0 +1,18 @@ +const CloseIcon = () => ( + + + + +); + +export default CloseIcon; diff --git a/frontend/src/components/icons/MenuIcon.tsx b/frontend/src/components/icons/MenuIcon.tsx new file mode 100644 index 0000000..630747b --- /dev/null +++ b/frontend/src/components/icons/MenuIcon.tsx @@ -0,0 +1,19 @@ +const MenuIcon = () => ( + + + + + +); + +export default MenuIcon; diff --git a/frontend/src/hooks/useAuth.ts b/frontend/src/hooks/useAuth.ts index 3360625..acdcc07 100644 --- a/frontend/src/hooks/useAuth.ts +++ b/frontend/src/hooks/useAuth.ts @@ -45,7 +45,6 @@ export function useAuth() { } catch (err: any) { const errorMessage = err.response?.data.error || err.message || 'Login failed. Please try again.'; - // debugger // Show error toast addNotification({ type: 'error', @@ -76,7 +75,6 @@ export function useAuth() { }; // Store in localStorage first - // debugger localStorage.setItem('token', response.access_token); localStorage.setItem('user', JSON.stringify(user)); diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index 506502f..f769012 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -6,7 +6,7 @@ import { TaskboardLogo } from '../components/TaskboardLogo'; export function Home() { return ( -
+