import React from 'react'; import percentPipe from 'app/shared/pipes/percent.pipe'; import { Arrow, FORECAST_TREND } from 'app/shared/modules/chart/arrow/arrow'; import cx from 'classnames'; export interface Props { currentForecast: string; previousForecast: string; ratio: string; date: string; trend: string; } const getTrendType = (trend) => { if (trend > 0) { return FORECAST_TREND.INCREASING; } if (trend < 0) { return FORECAST_TREND.DECREASING; } return FORECAST_TREND.STABLE; }; const getTrend = (trend) => { const containerClassName = cx('c-forecast-chart-tooltip__badge', 'o-layout', 'o-layout--aligned', 'o-layout--justified', { 'c-forecast-chart-tooltip__badge--increase': trend > 0, 'c-forecast-chart-tooltip__badge--decrease': trend < 0, 'c-forecast-chart-tooltip__badge--stable': trend === 0, } ); const textClassName = cx( 'c-forecast-chart-tooltip__text-badge', { 'c-forecast-chart-tooltip__text-badge--increase': trend > 0, 'c-forecast-chart-tooltip__text-badge--decrease': trend < 0, 'c-forecast-chart-tooltip__text-badge--stable': trend === 0, } ); return
{percentPipe.format(Math.abs(trend * 100))}
{date}
{currentForecast}
{getTrend(trend)}Current forecast
{ratio + '% fixed'}
{previousForecast}
Previous forecast