rename frontend directory to frontend

This commit is contained in:
Viktor Barzin 2025-06-14 15:43:14 +00:00
parent 71a9b69e04
commit c7d996dbeb
No known key found for this signature in database
GPG key ID: 4056458DBDBF8863
30 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,74 @@
import type { User } from 'oidc-client-ts';
import { useEffect, useState } from 'react';
import './App.css';
import { getUser, handleCallback, login, logout } from './auth/authService';
import { Map } from './components/Map';
import { Parameters } from './components/Parameters';
function App() {
useEffect(() => {
const script = document.createElement('script');
script.src = './script.js';
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script); // Cleanup
};
}, []);
const [user, setUser] = useState<User | null>(null);
useEffect(() => {
// Check if this is a callback from Authentik (after login)
if (window.location.pathname === '/callback') {
handleCallback().then(() => {
window.location.href = '/'; // Redirect to home after login
});
return;
}
// Load user data
getUser().then(setUser);
}, []);
return (
<>
<div>
<h1>React + Authentik OIDC</h1>
{user ? (
<div>
<p>Welcome, {user.profile.email}!</p>
<button onClick={logout}>Logout</button>
</div>
) : (
<button onClick={login}>Login with Authentik</button>
)}
</div>
{/* <div>
<a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p> */}
<Parameters />
<Map />
</>
)
}
export default App