feat: add operator landing and login
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-22 20:10:21 +02:00
parent 36d137e224
commit 115f9850a7
27 changed files with 1448 additions and 8 deletions
+64
View File
@@ -0,0 +1,64 @@
import { useEffect, useState } from 'react'
import { formatError } from '../lib/formatError'
import { getAuthSession, logout, type AuthSession } from '../services/api/auth'
const signedOutSession: AuthSession = {
authentication_required: true,
authenticated: false,
username: null,
expires_at: null,
}
export function useOperatorSession() {
const [session, setSession] = useState<AuthSession | null>(null)
const [sessionError, setSessionError] = useState<string | null>(null)
const [loggingOut, setLoggingOut] = useState(false)
useEffect(() => {
let active = true
getAuthSession()
.then((value) => {
if (active) {
setSession(value)
setSessionError(null)
}
})
.catch((error) => {
if (active) {
setSession(signedOutSession)
setSessionError(formatError(error, 'De aanmeldservice is tijdelijk niet bereikbaar.'))
}
})
return () => {
active = false
}
}, [])
useEffect(() => {
const expireSession = () => {
setSession(signedOutSession)
setSessionError('Uw sessie is verlopen. Meld u opnieuw aan.')
}
window.addEventListener('geointel:session-expired', expireSession)
return () => window.removeEventListener('geointel:session-expired', expireSession)
}, [])
const handleLogout = async () => {
setLoggingOut(true)
try {
setSession(await logout())
setSessionError(null)
} catch (error) {
setSessionError(formatError(error, 'Uitloggen is niet gelukt.'))
} finally {
setLoggingOut(false)
}
}
const handleAuthenticated = (authenticatedSession: AuthSession) => {
setSession(authenticatedSession)
setSessionError(null)
}
return { session, sessionError, loggingOut, handleAuthenticated, handleLogout }
}