/** * External dependencies */ import classnames from 'classnames'; import { isValidElement } from '@wordpress/element'; import type { ReactElement, ReactNode } from 'react'; import type { Currency } from '@woocommerce/types'; /** * Internal dependencies */ import './style.scss'; import FormattedMonetaryAmount from '../../formatted-monetary-amount'; export interface TotalsItemProps { className?: string | undefined; currency: Currency; label: string; // Value may be a number, or react node. Numbers are passed to FormattedMonetaryAmount. value: number | ReactNode; description?: ReactNode; } const TotalsItemValue = ( { value, currency, }: Partial< TotalsItemProps > ): ReactElement | null => { if ( isValidElement( value ) ) { return <>{ value }; } return Number.isFinite( value ) ? ( ) : null; }; const TotalsItem = ( { className, currency, label, value, description, }: TotalsItemProps ): ReactElement => { return (
{ label }
{ description }
); }; export default TotalsItem;