Check if there are tax lines before rendering the container for them (https://github.com/woocommerce/woocommerce-blocks/pull/4284)

This commit is contained in:
Thomas Roberts 2021-06-02 11:14:42 +01:00 committed by GitHub
parent f0cb4cba90
commit 1702a6c0c3
1 changed files with 24 additions and 23 deletions

View File

@ -45,29 +45,30 @@ const TotalsTaxes = ( {
false
) as boolean;
const itemisedTaxItems: ReactElement | null = showItemisedTaxes ? (
<div
className={ classnames(
'wc-block-components-totals-taxes',
className
) }
>
{ taxLines.map( ( { name, rate, price }, i ) => {
const label = `${ name }${
showRateAfterTaxName ? ` ${ rate }` : ''
}`;
return (
<TotalsItem
key={ `tax-line-${ i }` }
className="wc-block-components-totals-taxes__grouped-rate"
currency={ currency }
label={ label }
value={ parseInt( price, 10 ) }
/>
);
} ) }{ ' ' }
</div>
) : null;
const itemisedTaxItems: ReactElement | null =
showItemisedTaxes && taxLines.length > 0 ? (
<div
className={ classnames(
'wc-block-components-totals-taxes',
className
) }
>
{ taxLines.map( ( { name, rate, price }, i ) => {
const label = `${ name }${
showRateAfterTaxName ? ` ${ rate }` : ''
}`;
return (
<TotalsItem
key={ `tax-line-${ i }` }
className="wc-block-components-totals-taxes__grouped-rate"
currency={ currency }
label={ label }
value={ parseInt( price, 10 ) }
/>
);
} ) }{ ' ' }
</div>
) : null;
return showItemisedTaxes ? (
itemisedTaxItems