Skip to content

Commit 5e93367

Browse files
committed
refactor(SeriesSalesList): reduce code duplication.
1 parent 2f7645b commit 5e93367

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/main/frontend/src/components/SeriesSalesList.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ class SeriesSaleItem extends React.PureComponent {
8686
const hasTransactionUrl = !!sale.transactionUrl;
8787
const hasSecondPrice = !!sale.secondPrice;
8888

89+
let priceInfo = `${sale.firstPrice}\u00A0${sale.firstCurrency}`;
90+
if (hasSecondPrice) {
91+
priceInfo += ` (${sale.secondPrice}\u00A0${sale.secondCurrency})`;
92+
}
93+
8994
return (
9095
<li id={ `series-sale-${index}-info` }>
9196
{ hasDate && sale.date }
@@ -101,15 +106,9 @@ class SeriesSaleItem extends React.PureComponent {
101106
{' '}
102107
{ hasBuyer && (l10n['t_sold_for'] || 'for') }
103108
{' '}
104-
{ hasTransactionUrl ?
105-
<a href={sale.transactionUrl} id={ `series-sale-${index}-transaction` } rel="nofollow">
106-
{ `${sale.firstPrice}\u00A0${sale.firstCurrency}` }
107-
{ hasSecondPrice && ` (${sale.secondPrice}\u00A0${sale.secondCurrency})` }
108-
</a>
109-
: <React.Fragment>
110-
{ `${sale.firstPrice}\u00A0${sale.firstCurrency}` }
111-
{ hasSecondPrice && ` (${sale.secondPrice}\u00A0${sale.secondCurrency})` }
112-
</React.Fragment>
109+
{ hasTransactionUrl
110+
? <a href={sale.transactionUrl} id={ `series-sale-${index}-transaction` } rel="nofollow">{ priceInfo }</a>
111+
: priceInfo
113112
}
114113
{ hasCondition && ` (${sale.condition !== 'CANCELLED' ? sale.condition : (l10n['t_cancelled'] || 'cancelled')})` }
115114
</li>

0 commit comments

Comments
 (0)