import PropTypes from 'prop-types' import { Progress, Flex, Space } from 'antd' import React from 'react' import StateTag from './StateTag' const getProgressColor = (percent) => { if (percent <= 50) { return '#52c41a' // green[5] } else if (percent <= 80) { // Interpolate between green and yellow const ratio = (percent - 50) / 30 return `rgb(${Math.round(255 * ratio)}, ${Math.round(255 * (1 - ratio))}, 0)` } else { // Interpolate between yellow and red const ratio = (percent - 80) / 20 return `rgb(255, ${Math.round(255 * (1 - ratio))}, 0)` } } const FilamentStockState = ({ state = { type: 'unknown' }, showProgress = true, showState = true }) => { return ( {showState && ( )} {showProgress && state.type === 'partiallyconsumed' ? ( ) : null} ) } FilamentStockState.propTypes = { state: PropTypes.object, showProgress: PropTypes.bool, showState: PropTypes.bool } export default FilamentStockState