feat: Initialize frontend and backend structure with essential configurations
- Added TypeScript build info for frontend. - Created Vite configuration for React application. - Implemented pre-commit hook to run checks before commits. - Set up PostgreSQL Dockerfile with PostGIS support and initialization scripts. - Added database creation script for PostgreSQL with necessary extensions. - Established Python project configuration with dependencies and development tools. - Developed pre-commit script to enforce code quality checks for backend and frontend. - Created PowerShell script to set up Git hooks path.
This commit is contained in:
88
frontend/src/App.tsx
Normal file
88
frontend/src/App.tsx
Normal file
@@ -0,0 +1,88 @@
|
||||
import './styles/global.css';
|
||||
|
||||
import { LoginForm } from './components/auth/LoginForm';
|
||||
import { NetworkMap } from './components/map/NetworkMap';
|
||||
import { useNetworkSnapshot } from './hooks/useNetworkSnapshot';
|
||||
import { useAuth } from './state/AuthContext';
|
||||
|
||||
function App(): JSX.Element {
|
||||
const { token, user, status: authStatus, logout } = useAuth();
|
||||
const isAuthenticated = authStatus === 'authenticated' && token !== null;
|
||||
const { data, status, error } = useNetworkSnapshot(isAuthenticated ? token : null);
|
||||
|
||||
return (
|
||||
<div className="app-shell">
|
||||
<header className="app-header">
|
||||
<div>
|
||||
<h1>Rail Game</h1>
|
||||
<p>Build and manage a railway network using real-world map data.</p>
|
||||
</div>
|
||||
{isAuthenticated && (
|
||||
<div className="auth-meta">
|
||||
<span>Signed in as {user?.fullName ?? user?.username}</span>
|
||||
<button type="button" onClick={() => logout()} className="ghost-button">
|
||||
Sign out
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
<main className="app-main">
|
||||
{!isAuthenticated ? (
|
||||
<section className="card">
|
||||
<LoginForm />
|
||||
</section>
|
||||
) : (
|
||||
<section className="card">
|
||||
<h2>Network Snapshot</h2>
|
||||
{status === 'loading' && <p>Loading network data…</p>}
|
||||
{status === 'error' && <p className="error-text">{error}</p>}
|
||||
{status === 'success' && data && (
|
||||
<div className="snapshot-layout">
|
||||
<div className="map-wrapper">
|
||||
<NetworkMap snapshot={data} />
|
||||
</div>
|
||||
<div className="grid">
|
||||
<div>
|
||||
<h3>Stations</h3>
|
||||
<ul>
|
||||
{data.stations.map((station) => (
|
||||
<li key={station.id}>
|
||||
{station.name} ({station.latitude.toFixed(3)},{' '}
|
||||
{station.longitude.toFixed(3)})
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h3>Trains</h3>
|
||||
<ul>
|
||||
{data.trains.map((train) => (
|
||||
<li key={train.id}>
|
||||
{train.designation} · {train.capacity} capacity ·{' '}
|
||||
{train.maxSpeedKph} km/h
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<h3>Tracks</h3>
|
||||
<ul>
|
||||
{data.tracks.map((track) => (
|
||||
<li key={track.id}>
|
||||
{track.startStationId} → {track.endStationId} ·{' '}
|
||||
{(track.lengthMeters / 1000).toFixed(1)} km
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
Reference in New Issue
Block a user