import React, { useState } from 'react'; import { isEmpty } from 'lodash'; import { useSelector } from 'react-redux'; import { createMarketsErrorStatusSelector, createMarketsIsLoadingSelector, selectHasImoCargoInExposure, selectProgressBarExposures, } from '../store/markets.selectors'; import { ProgressBar } from 'app/shared/components/ProgressBar/progressBar'; import { MARKETS } from '../store/markets.constants'; import { Spinner } from 'app/shared/components/spinner/spinner'; import { Headline, Paragraph } from 'app/shared/components/text/text'; import { ProgressBarLegend } from 'app/shared/components/ProgressBar/progressBarLegend'; import ToggleButton from 'app/shared/components/ToggleButton/toggleButton'; import cx from 'classnames'; const IMO_CARGO_LABEL = 'IMO Cargo'; export const PositioningExposure = () => { const [ showImoCargo, setImoCargoVisibility ] = useState(false); const marketForecastExposure = useSelector(selectProgressBarExposures); const hasImoCargo = useSelector(selectHasImoCargoInExposure); const isLoading = useSelector(createMarketsIsLoadingSelector([ MARKETS.FETCH_EXPOSURE_SELECTOR ])); const error = useSelector(createMarketsErrorStatusSelector([ MARKETS.FETCH_EXPOSURE_SELECTOR ])); if ((isEmpty(marketForecastExposure.pool) || isEmpty(marketForecastExposure.market) || error) && !isLoading){ return There are no positioning exposures for this period of time ; } const marketExposureClassName = cx('c-positioning-exposure__market-exposure', { 'c-positioning-exposure__market-exposure--with-imo-cargo': showImoCargo, }); return isLoading ? :
Pool {hasImoCargo && }
Market
; };