fix: handle undefined inbounds/outbounds in traffic tab

API may return nodes without inbounds/outbounds arrays. Made fields
optional in NodeRealtimeStats and added null safety guards in TrafficTab.
This commit is contained in:
Fringg
2026-03-28 23:33:06 +03:00
parent 5d7b94fc48
commit 06f6cbeb8e
2 changed files with 6 additions and 6 deletions

View File

@@ -174,8 +174,8 @@ export interface NodeRealtimeStats {
uploadBytes: number;
totalBytes: number;
usersOnline: number;
inbounds: InboundTraffic[];
outbounds: InboundTraffic[];
inbounds?: InboundTraffic[];
outbounds?: InboundTraffic[];
}
// Squads

View File

@@ -923,12 +923,12 @@ function TrafficTab({ data, isLoading, onRefresh }: TrafficTabProps) {
<span className="text-sm text-dark-300">{formatBytes(node.totalBytes)}</span>
</div>
{node.inbounds.length > 0 && (
{(node.inbounds?.length ?? 0) > 0 && (
<div className="space-y-1">
<p className="mb-2 text-xs font-medium text-dark-400">
{t('admin.remnawave.traffic.inbounds', 'Inbounds')}
</p>
{[...node.inbounds]
{[...(node.inbounds ?? [])]
.sort((a, b) => b.totalBytes - a.totalBytes)
.map((ib) => (
<div
@@ -948,12 +948,12 @@ function TrafficTab({ data, isLoading, onRefresh }: TrafficTabProps) {
</div>
)}
{node.outbounds.length > 0 && (
{(node.outbounds?.length ?? 0) > 0 && (
<div className="mt-3 space-y-1">
<p className="mb-2 text-xs font-medium text-dark-400">
{t('admin.remnawave.traffic.outbounds', 'Outbounds')}
</p>
{[...node.outbounds]
{[...(node.outbounds ?? [])]
.sort((a, b) => b.totalBytes - a.totalBytes)
.map((ob) => (
<div