import React from 'react'; import HoverInfo from 'app/shared/components/hoverInfo/hoverInfo'; import datePipe from 'app/shared/pipes/date.pipe'; import moneyPipe from 'app/shared/pipes/money.pipe'; import numberPipe from 'app/shared/pipes/number.pipe'; import { useSelector } from 'react-redux'; import { createDashboardIsLoadingSelector, getDashboardCurrentKeyFigures, } from 'app/modules/dashboard/store/dashboard.selectors'; import { Spinner } from 'app/shared/components/spinner/spinner'; import { DASHBOARD } from 'app/modules/dashboard/store/dashboard.constants'; import { Dot } from 'app/shared/components/dot/dot'; import * as Text from 'app/shared/components/text/text'; import { Caption, Paragraph } from 'app/shared/components/text/text'; import { DashboardKeyFigure } from '../store/dashboard.types'; import { Figures, InfoBox } from 'app/shared/components/infoBox/infoBox'; import cx from 'classnames'; const NOT_AVAILABLE = 'N/A'; const createInfoBoxes = (keyFigure: DashboardKeyFigure) => { const figures: Figures[][] = [ [ { value: keyFigure.bunkerPrice ? '$' + numberPipe.format(keyFigure.bunkerPrice, 2, 2) : NOT_AVAILABLE, type: 'text', description: 'Price', additionalDescription: 'Compliant', unit: '/mt', } ], ]; if (keyFigure.isScrubber) { figures.push([ { value: keyFigure.bunkerPriceWithScrubber ? '$' + numberPipe.format(keyFigure.bunkerPriceWithScrubber, 2, 2) : NOT_AVAILABLE, type: 'text', description: 'Price', additionalDescription: 'Non compliant', unit: '/mt', } ]); } return figures; }; export const DashboardKeyFigures = () => { const keyFigures = useSelector(getDashboardCurrentKeyFigures); const infoBoxes = createInfoBoxes(keyFigures); const dashboardFetchCollectionSelector = [ DASHBOARD.FETCH_KEY_FIGURES_SELECTOR ]; const loadingStatus = useSelector(createDashboardIsLoadingSelector(dashboardFetchCollectionSelector)); return loadingStatus ? :
PAY OUT | {keyFigures.date ? datePipe.formatShortMonthWithYear(keyFigures.date) : NOT_AVAILABLE} {keyFigures.isForecast && | FORECAST }
Average pool earnings $/day
{keyFigures.isForecast &&
fixed unfixed
}
{keyFigures.tce ? moneyPipe.format(keyFigures.tce) : NOT_AVAILABLE} /day
Earnings
{infoBoxes.map((figure, index) => { const figureClassName = cx('o-layout__item-12', 'o-layout__item-lg-4', 'o-layout--wrap', 'o-gutter-bottom--small', { 'o-gutter-lg-right--small': index < infoBoxes.length - 1, 'o-gutter-lg-left--tiny': index > 0, } ); return
; })}
Bunker consumption and bunker prices are an estimate based on the latest reported data
; };