Initialize HemHub project foundation

This commit is contained in:
Urban Modig
2026-07-23 22:06:56 +02:00
commit 9957383e88
23 changed files with 2430 additions and 0 deletions

48
frontend/src/App.tsx Normal file
View File

@ -0,0 +1,48 @@
import { useEffect, useState } from 'react'
type HealthResponse = {
status: string
}
function App() {
const [backendStatus, setBackendStatus] = useState<string | null>(null)
const [hasError, setHasError] = useState(false)
useEffect(() => {
const loadHealth = async () => {
try {
const response = await fetch('/api/health')
if (!response.ok) {
throw new Error(`Backend svarade med status ${response.status}`)
}
const health = (await response.json()) as HealthResponse
setBackendStatus(health.status)
} catch {
setHasError(true)
}
}
void loadHealth()
}, [])
let statusMessage = 'Kontrollerar backend…'
if (hasError) {
statusMessage = 'Backend kunde inte nås'
} else if (backendStatus) {
statusMessage = `Backend: ${backendStatus}`
}
return (
<main>
<h1>HemHub</h1>
<p>Frontend har startat.</p>
<p aria-live="polite">{statusMessage}</p>
</main>
)
}
export default App