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:
1 parent
3ccf3bfcfa
commit
9fcb6ebab6
1 file changed
+13
-11
@@ -158,10 +158,12 @@ interface ProvisioningJob {
|
|||||||
updatedAt: string
|
updatedAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InstanceDetail extends Instance {
|
interface InstanceDetail {
|
||||||
|
instance: Instance & {
|
||||||
events: InstanceEvent[]
|
events: InstanceEvent[]
|
||||||
jobs: ProvisioningJob[]
|
jobs: ProvisioningJob[]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface InstanceStats {
|
interface InstanceStats {
|
||||||
total: number
|
total: number
|
||||||
@@ -618,16 +620,7 @@ function InstanceDetailSheet({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse metadata for Dokploy resource IDs
|
// Parse metadata for Dokploy resource IDs
|
||||||
const meta = useMemo(() => {
|
const instance = data?.instance ?? null
|
||||||
if (!data?.metadata) return {}
|
|
||||||
try {
|
|
||||||
return JSON.parse(data.metadata) as Record<string, unknown>
|
|
||||||
} catch {
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
}, [data?.metadata])
|
|
||||||
|
|
||||||
const instance = data
|
|
||||||
const status = instance?.status ?? ''
|
const status = instance?.status ?? ''
|
||||||
const fullDomain = instance ? `${instance.subdomain}.dfmpanel.eu` : ''
|
const fullDomain = instance ? `${instance.subdomain}.dfmpanel.eu` : ''
|
||||||
|
|
||||||
@@ -635,6 +628,15 @@ function InstanceDetailSheet({
|
|||||||
const events = instance?.events ?? []
|
const events = instance?.events ?? []
|
||||||
const license = instance?.license ?? null
|
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 (
|
return (
|
||||||
<Sheet open={open} onOpenChange={onOpenChange}>
|
<Sheet open={open} onOpenChange={onOpenChange}>
|
||||||
<SheetContent
|
<SheetContent
|
||||||
|
|||||||
Reference in new issue
Block a user