mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-18 10:02:16 +00:00
Update health-status-modal.tsx
This commit is contained in:
@@ -375,12 +375,28 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu
|
|||||||
body: JSON.stringify({ error_key: errorKey }),
|
body: JSON.stringify({ error_key: errorKey }),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const responseData = await response.json().catch(() => ({}))
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorData = await response.json().catch(() => ({}))
|
throw new Error(responseData.error || `Failed to dismiss error (${response.status})`)
|
||||||
throw new Error(errorData.error || `Failed to dismiss error (${response.status})`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await fetchHealthDetails()
|
// Optimistically update local state to avoid slow re-fetch
|
||||||
|
// Add the dismissed item to the local list immediately
|
||||||
|
if (responseData.result || responseData.success) {
|
||||||
|
const dismissedItem = {
|
||||||
|
error_key: errorKey,
|
||||||
|
category: responseData.result?.category || responseData.category || '',
|
||||||
|
severity: responseData.result?.original_severity || 'WARNING',
|
||||||
|
reason: 'Dismissed by user',
|
||||||
|
dismissed: true,
|
||||||
|
acknowledged_at: new Date().toISOString()
|
||||||
|
}
|
||||||
|
setDismissedItems(prev => [...prev, dismissedItem])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch fresh data in background (non-blocking)
|
||||||
|
fetchHealthDetails().catch(() => {})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error dismissing:", err)
|
console.error("Error dismissing:", err)
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user