feat(iace): "Neu initialisieren" Button + DeleteHazard
- POST /initialize?force=true loescht bestehende Hazards + Mitigations und erstellt sie neu mit aktuellen Betriebszustaenden - Orange "Neu initialisieren" Button auf Interview-Seite (mit Confirm-Dialog) - DeleteHazard Store-Methode (kaskadiert Risk Assessments) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -236,6 +236,47 @@ export default function IACEInterviewPage() {
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
disabled={initStatus === 'running' || completionPct < 30}
|
||||
onClick={async () => {
|
||||
if (!confirm('Alle bestehenden Gefaehrdungen und Massnahmen loeschen und neu erstellen?')) return
|
||||
if (saveTimerRef.current) {
|
||||
clearTimeout(saveTimerRef.current)
|
||||
await saveToBackend(latestFormRef.current)
|
||||
}
|
||||
setInitStatus('running')
|
||||
setInitResult(null)
|
||||
try {
|
||||
const res = await fetch(`/api/sdk/v1/iace/projects/${projectId}/initialize?force=true`, { method: 'POST' })
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({}))
|
||||
alert(err.error || 'Neu-Initialisierung fehlgeschlagen')
|
||||
setInitStatus('error')
|
||||
return
|
||||
}
|
||||
const data = await res.json()
|
||||
setInitResult(data)
|
||||
setInitStatus('done')
|
||||
} catch {
|
||||
setInitStatus('error')
|
||||
}
|
||||
}}
|
||||
className="flex items-center gap-2 px-4 py-2 bg-orange-600 text-white rounded-lg hover:bg-orange-700 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{initStatus === 'running' ? (
|
||||
<>
|
||||
<span className="animate-spin inline-block w-3.5 h-3.5 border-2 border-white border-t-transparent rounded-full" />
|
||||
Laeuft...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<svg className="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
||||
</svg>
|
||||
Neu initialisieren
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (saveTimerRef.current) {
|
||||
|
||||
Reference in New Issue
Block a user