feat: enhance rendering of attribute changes for improved display of array and object values

This commit is contained in:
Yoga Pangestu 2026-08-22 16:09:58 +07:00
parent 8cd64307da
commit 1f61ff895a

View File

@ -47,11 +47,38 @@ function renderValue(value: unknown): React.ReactNode {
return <span className="text-muted-foreground">-</span>; return <span className="text-muted-foreground">-</span>;
} }
if (value.every((item) => typeof item !== 'object' || item === null)) {
return value.join(', '); return value.join(', ');
} }
return (
<div className="space-y-2">
{value.map((item, index) => (
<div key={index} className="rounded border border-border/50 px-2 py-1">
{renderValue(item)}
</div>
))}
</div>
);
}
if (typeof value === 'object') { if (typeof value === 'object') {
return JSON.stringify(value); const entries = Object.entries(value as Record<string, unknown>);
if (entries.length === 0) {
return <span className="text-muted-foreground">-</span>;
}
return (
<div className="space-y-0.5">
{entries.map(([key, val]) => (
<div key={key}>
<span className="text-muted-foreground">{key}:</span>{' '}
{renderValue(val)}
</div>
))}
</div>
);
} }
return String(value); return String(value);