import React, { useMemo, useCallback } from 'react'; import moment from 'moment'; import classnames from 'classnames'; import { FormattedMessage as T } from 'components'; import intl from 'react-intl-universal'; import 'style/pages/FinancialStatements/FinancialSheet.scss'; import { If, LoadingIndicator, MODIFIER } from 'components'; export default function FinancialSheet({ companyName, sheetType, fromDate, toDate, asDate, children, accountingBasis, name, loading, className, basis, minimal = false, fullWidth = false, currentDate = true, }) { const format = 'DD MMMM YYYY'; const formattedFromDate = useMemo(() => moment(fromDate).format(format), [ fromDate, ]); const formattedToDate = useMemo(() => moment(toDate).format(format), [ toDate, ]); const formattedAsDate = useMemo(() => moment(asDate).format(format), [ asDate, ]); const nameModifer = name ? `financial-sheet--${name}` : ''; const methodsLabels = useMemo( () => ({ cash: intl.get('cash'), accrual: intl.get('accrual'), }), [], ); const getBasisLabel = useCallback((b) => methodsLabels[b], [methodsLabels]); const basisLabel = useMemo(() => getBasisLabel(basis), [ getBasisLabel, basis, ]); return (