From 56ebf001aa2d927abffd5e90ee1602eaeb2696d8 Mon Sep 17 00:00:00 2001 From: Yana Date: Thu, 23 Jan 2025 21:46:04 +0200 Subject: [PATCH] fix build --- .../QualityIndicatorsCard.tsx | 54 ++++++++++++++----- .../staking/SubHeaderRowActions.tsx | 1 + 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/explorer-nextjs/src/components/nymNodePageComponents/QualityIndicatorsCard.tsx b/explorer-nextjs/src/components/nymNodePageComponents/QualityIndicatorsCard.tsx index 4a319edaad..4ba57b75fb 100644 --- a/explorer-nextjs/src/components/nymNodePageComponents/QualityIndicatorsCard.tsx +++ b/explorer-nextjs/src/components/nymNodePageComponents/QualityIndicatorsCard.tsx @@ -81,7 +81,7 @@ const calculateQualityOfServiceStars = (quality: number): number => { } }; -const calculateConfigScoreStars = (probeResult: LastProbeResult): number => { +function calculateConfigScoreStars(probeResult: LastProbeResult): number { const { as_entry, as_exit } = probeResult.outcome; if (as_entry && as_exit) { @@ -94,7 +94,6 @@ const calculateConfigScoreStars = (probeResult: LastProbeResult): number => { as_exit.can_route_ip_v4, as_exit.can_route_ip_v6, ]; - const combinedScore = allResults.filter(Boolean).length; switch (combinedScore) { @@ -109,17 +108,42 @@ const calculateConfigScoreStars = (probeResult: LastProbeResult): number => { } } - return 1; // Default case -}; + if (as_entry) { + const entryScore = [as_entry.can_connect, as_entry.can_route].filter( + Boolean, + ).length; -const calculateWireguardPerformance = ( - probeResult: LastProbeResult, -): number => { + return entryScore === 2 ? 4 : entryScore === 1 ? 2 : 1; + } + + if (as_exit) { + const exitScore = [ + as_exit.can_connect, + as_exit.can_route_ip_external_v4, + as_exit.can_route_ip_external_v6, + as_exit.can_route_ip_v4, + as_exit.can_route_ip_v6, + ].filter(Boolean).length; + + switch (exitScore) { + case 5: + return 4; + case 4: + return 3; + case 3: + return 2; + default: + return 1; + } + } + + return 0; +} + +function calculateWireguardPerformance(probeResult: LastProbeResult): number { const { wg, as_exit } = probeResult.outcome; - if (!wg) { - return 1; // Default to 1 star if Wireguard information is missing - } + if (!wg) return 1; const pingPerformance = (wg.ping_hosts_performance_v4 + @@ -136,7 +160,6 @@ const calculateWireguardPerformance = ( wg.can_resolve_dns_v6 && pingPerformance > 0.75: return 4; - case wg.can_register && wg.can_handshake_v4 && wg.can_handshake_v6 && @@ -144,11 +167,14 @@ const calculateWireguardPerformance = ( wg.can_resolve_dns_v6 && pingPerformance <= 0.75: return 3; - + case wg.can_register && (!wg.can_handshake_v4 || !wg.can_handshake_v6): + return 2; + case as_exit && (!as_exit.can_route_ip_v4 || !as_exit.can_route_ip_v6): + return 1; default: - return 1; // Default case + return 1; } -}; +} export const QualityIndicatorsCard = ({ id }: IQualityIndicatorsCardProps) => { // Fetch node info diff --git a/explorer-nextjs/src/components/staking/SubHeaderRowActions.tsx b/explorer-nextjs/src/components/staking/SubHeaderRowActions.tsx index a9d49237d9..68ac0ca0b9 100644 --- a/explorer-nextjs/src/components/staking/SubHeaderRowActions.tsx +++ b/explorer-nextjs/src/components/staking/SubHeaderRowActions.tsx @@ -108,6 +108,7 @@ const SubHeaderRowActions = () => { fee, "Redeeming all rewards", ); + console.log("Rewards redeemed successfully:", result); setInfoModalProps({ open: true,