import React from 'react' import cn from 'classnames' import stl from './ErrorBars.module.css' const GOOD = 'Good' const LESS_CRITICAL = 'Few Issues' const CRITICAL = 'Many Issues' const getErrorState = (count: number) => { if (count === 0) { return GOOD } if (count < 3) { return LESS_CRITICAL } return CRITICAL } interface Props { count?: number } export default function ErrorBars(props: Props) { const { count = 2 } = props const state = React.useMemo(() => getErrorState(count), [count]) const isGood = state === GOOD const showFirstBar = (state === LESS_CRITICAL || state === CRITICAL) const showSecondBar = (state === CRITICAL) // const showThirdBar = (state === GOOD || state === CRITICAL); // const bgColor = { 'bg-red' : state === CRITICAL, 'bg-red2' : state === LESS_CRITICAL } const bgColor = 'bg-red2' return isGood ? <> : (
{ showFirstBar &&
} { showSecondBar &&
} {/* { showThirdBar &&
} */}
{/*
*/}
{state}
) }