feat: create separate component for message

This commit is contained in:
RadoslavDimchev 2023-08-09 10:58:47 +03:00
parent c7120820bf
commit a6387398db

View File

@ -0,0 +1,19 @@
import { GREEN_CHECKMARK_ICON, RED_CHECKMARK_ICON } from '../constants'
import IconText from './IconText'
type StatusIconTextProps = {
percentage: number
threshold: number
goodText: string
badText: string
}
const StatusIconText = ({ percentage, threshold, goodText, badText }: StatusIconTextProps) => {
const isGood = percentage < threshold
const icon = isGood ? GREEN_CHECKMARK_ICON : RED_CHECKMARK_ICON
const text = isGood ? goodText : badText
return <IconText icon={icon}>{text}</IconText>
}
export default StatusIconText