diff --git a/src/components/HealthInfoSection.tsx b/src/components/HealthInfoSection.tsx index 5a3f12ef..ebd88242 100644 --- a/src/components/HealthInfoSection.tsx +++ b/src/components/HealthInfoSection.tsx @@ -1,5 +1,4 @@ import { YStack } from 'tamagui' -import { useEffect, useState } from 'react' import StatusIconText from './StatusIconText' import { BAD_CPU_CLOCK_RATE_TEXT, @@ -25,16 +24,10 @@ const HealthInfoSection = (props: HealthInfoSectionProps) => { const { usedStorage, maxStorage, usedRamMemory, maxRamMemory, cpuClockRate, networkLatency } = props - const [usedStoragePercentage, setUsedStoragePercentage] = useState(0) - const [usedRamMemoryPercentage, setUsedRamMemoryPercentage] = useState(0) - - useEffect(() => { - setUsedStoragePercentage((usedStorage / maxStorage) * 100) - }, [usedStorage, maxStorage]) - - useEffect(() => { - setUsedRamMemoryPercentage((usedRamMemory / maxRamMemory) * 100) - }, [usedRamMemory, maxRamMemory]) + const usedStoragePercentage = (usedStorage / maxStorage) * 100 + const usedRamMemoryPercentage = (usedRamMemory / maxRamMemory) * 100 + const cpuClockRatePercentage = cpuClockRate > 2.4 ? 100 : 0 + const networkLatencyPercentage = networkLatency > 100 ? 100 : 0 return ( @@ -45,7 +38,7 @@ const HealthInfoSection = (props: HealthInfoSectionProps) => { badText={BAD_STORAGE_TEXT} /> 2.4 ? 100 : 0} + percentage={cpuClockRatePercentage} threshold={50} goodText={GOOD_CPU_CLOCK_RATE_TEXT} badText={BAD_CPU_CLOCK_RATE_TEXT} @@ -57,7 +50,7 @@ const HealthInfoSection = (props: HealthInfoSectionProps) => { badText={BAD_RAM_MEMORY_TEXT} /> 100 ? 100 : 0} + percentage={networkLatencyPercentage} threshold={50} goodText={GOOD_NETWORK_TEXT} badText={BAD_NETWORK_TEXT}