From 42f1b4de384bcbbdab3b80d8e5cc53b36fcffd50 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Thu, 12 Feb 2026 21:50:56 -0800 Subject: Implement frontend login logic with >90% coverage --- frontend/src/App.tsx | 85 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 29 deletions(-) (limited to 'frontend/src/App.tsx') diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 3d7ded3..b986198 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,35 +1,62 @@ -import { useState } from 'react' -import reactLogo from './assets/react.svg' -import viteLogo from '/vite.svg' -import './App.css' +import React, { useEffect, useState } from 'react'; +import { BrowserRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom'; +import Login from './components/Login'; +import './App.css'; -function App() { - const [count, setCount] = useState(0) +// Protected Route wrapper +function RequireAuth({ children }: { children: React.ReactElement }) { + const [auth, setAuth] = useState(null); + const location = useLocation(); + + useEffect(() => { + fetch('/api/auth') + .then((res) => { + if (res.ok) { + setAuth(true); + } else { + setAuth(false); + } + }) + .catch(() => setAuth(false)); + }, []); + + if (auth === null) { + return
Loading...
; + } + + if (!auth) { + return ; + } + + return children; +} +function Dashboard() { + // Placeholder for now return ( - <> -
- - Vite logo - - - React logo - -
-

Vite + React

-
- -

- Edit src/App.tsx and save to test HMR -

-
-

- Click on the Vite and React logos to learn more -

- +
+

Dashboard

+

Welcome to the new Neko/v2 frontend.

+
) } -export default App +function App() { + return ( + + + } /> + + + + } + /> + + + ); +} + +export default App; -- cgit v1.2.3