diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 328ad8e..acb6315 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -6,6 +6,7 @@ import Error from './pages/Error'; import Game from './pages/Game'; import About from './pages/About'; import { AuthProvider } from './contexts/AuthContext'; +import Login from './pages/Login'; const router = createBrowserRouter([ { @@ -23,6 +24,8 @@ const router = createBrowserRouter([ }, { path: '/about', element: }, { path: '/error', element: }, + { path: '/login', element: }, + { path: '/signin', element: } ], }, ]); diff --git a/frontend/src/Navbar.tsx b/frontend/src/Navbar.tsx index dc2d9a7..faf7537 100644 --- a/frontend/src/Navbar.tsx +++ b/frontend/src/Navbar.tsx @@ -33,17 +33,23 @@ const Navbar: React.FC = ({ /> - {!isLoggedIn && ( -
-
- )} + {isLoggedIn ? ( + <> + + + ) : ( + <> +
+
+ + )} + {isOpen && (
diff --git a/frontend/src/contexts/AuthContext.tsx b/frontend/src/contexts/AuthContext.tsx index 78b6d25..4b34852 100644 --- a/frontend/src/contexts/AuthContext.tsx +++ b/frontend/src/contexts/AuthContext.tsx @@ -8,12 +8,12 @@ import { export type User = { name: string; - email: string; + pass: string; }; export type AuthContextProps = { getUser: () => User | null; - login: () => void; + login: (arg0: string, arg1: string) => void; logout: () => void; isLoggedIn: () => boolean; }; @@ -30,14 +30,14 @@ export function useAuth() { } export function AuthProvider({ children }: { children: ReactElement }) { - const [user, setUser] = useState(null); + const [user, setUser] = useState(null); - const login = useCallback(() => { + const login = useCallback((name: string, pass: string) => { setUser({ - name: 'John Doe', - email: '', + name: name, + pass: pass, }); - }, []); + }, [setUser]); const logout = useCallback(() => { setUser(null); diff --git a/frontend/src/library/button.tsx b/frontend/src/library/button.tsx index c9ba58a..af848eb 100644 --- a/frontend/src/library/button.tsx +++ b/frontend/src/library/button.tsx @@ -15,6 +15,7 @@ type ButtonProps = { fontSize?: string; rounded?: string; buttonSize?: string; + type?: "submit" | "reset" | "button" borderColor?: string; hoverColor?: string; hoverScale?: boolean; @@ -36,11 +37,13 @@ const Button: React.FC = ({ borderColor = 'border-black', hoverColor = 'hover:bg-lime-600', hoverScale = true, + type = 'button', onClick, className = '', }) => { return (
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+ Don't have an account? Sign in +
+
+
+ + + + + + ); +}; + +export default Login; \ No newline at end of file