rename frontend directory to frontend
This commit is contained in:
parent
71a9b69e04
commit
c7d996dbeb
30 changed files with 1 additions and 1 deletions
74
crawler/frontend/src/App.tsx
Normal file
74
crawler/frontend/src/App.tsx
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue