fix: instance detail — correct API response mapping (data.instance, not data)

Root cause: useFetch<InstanceDetail> returns { instance: {...} } but code
used 'const instance = data' instead of 'const instance = data?.instance'.
This meant all instance fields (events, license, metadata) were undefined.

Fix:
- Changed InstanceDetail type to { instance: Instance & {...} }
- const instance = data?.instance ?? null
- Moved instance assignment before meta useMemo
- All subsequent code uses 'events' and 'license' safe accessors
This commit is contained in:
Z User committed 2026-10-29 18:44:26 +00:00
1 parent 3ccf3bfcfa
commit 9fcb6ebab6
1 file changed
+13 -11
+13 -11
View File
@@ -158,9 +158,11 @@ interface ProvisioningJob {
updatedAt: string
}
interface InstanceDetail extends Instance {
interface InstanceDetail {
instance: Instance & {
events: InstanceEvent[]
jobs: ProvisioningJob[]
}
}
interface InstanceStats {
@@ -618,16 +620,7 @@ function InstanceDetailSheet({
}
// Parse metadata for Dokploy resource IDs
const meta = useMemo(() => {
if (!data?.metadata) return {}
try {
return JSON.parse(data.metadata) as Record<string, unknown>
} catch {
return {}
}
}, [data?.metadata])
const instance = data
const instance = data?.instance ?? null
const status = instance?.status ?? ''
const fullDomain = instance ? `${instance.subdomain}.dfmpanel.eu` : ''
@@ -635,6 +628,15 @@ function InstanceDetailSheet({
const events = instance?.events ?? []
const license = instance?.license ?? null
const meta = useMemo(() => {
if (!instance?.metadata) return {}
try {
return JSON.parse(instance.metadata) as Record<string, unknown>
} catch {
return {}
}
}, [instance?.metadata])
return (
<Sheet open={open} onOpenChange={onOpenChange}>
<SheetContent