|
| 1 | +import { |
| 2 | + VAULT_HEALTH_PERCENT_GREEN, |
| 3 | + VAULT_HEALTH_PERCENT_YELLOW, |
| 4 | + VAULT_HEALTH_PERCENT_RED, |
| 5 | + VAULT_UTILIZATION_RATIO_GREEN, |
| 6 | + VAULT_UTILIZATION_RATIO_RED, |
| 7 | +} from 'consts/threshold'; |
| 8 | + |
| 9 | +export const getHealthFactorColor = (healthFactor: string | number) => { |
| 10 | + if (!healthFactor) return ''; |
| 11 | + let healthFactorNumber = 0; |
| 12 | + |
| 13 | + if (typeof healthFactor === 'string') |
| 14 | + healthFactorNumber = Number(healthFactor.split('%')[0]); |
| 15 | + else healthFactorNumber = healthFactor; |
| 16 | + |
| 17 | + if (healthFactorNumber >= VAULT_HEALTH_PERCENT_GREEN) return '#53BA95'; |
| 18 | + if (healthFactorNumber >= VAULT_HEALTH_PERCENT_YELLOW) return '#ffbf00'; |
| 19 | + if (healthFactorNumber >= VAULT_HEALTH_PERCENT_RED) return '#E14D4D'; |
| 20 | + return 'darkRed'; |
| 21 | +}; |
| 22 | + |
| 23 | +export const getUtilizationRatioColor = (utilizationRatio: string) => { |
| 24 | + if (!utilizationRatio) return ''; |
| 25 | + let utilizationRatioNumber = 0; |
| 26 | + |
| 27 | + if (typeof utilizationRatio === 'string') |
| 28 | + utilizationRatioNumber = Number(utilizationRatio.split('%')[0]); |
| 29 | + else utilizationRatioNumber = utilizationRatio; |
| 30 | + |
| 31 | + if (utilizationRatioNumber < VAULT_UTILIZATION_RATIO_GREEN) return '#53BA95'; |
| 32 | + if (utilizationRatioNumber < VAULT_UTILIZATION_RATIO_RED) return '#ffbf00'; |
| 33 | + if (utilizationRatioNumber === VAULT_UTILIZATION_RATIO_RED) return '#E14D4D'; |
| 34 | + if (utilizationRatioNumber > VAULT_UTILIZATION_RATIO_RED) return 'darkRed'; |
| 35 | +}; |
0 commit comments