diff --git a/CHANGELOG.md b/CHANGELOG.md index 82efe230..a4d8f05a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ way to update this template, but currently, we follow a pattern: ## Upcoming version 2019-XX-XX +- [fix] In `LineItemProviderCommissionMaybe.js` file check that `providerCommissionLineItem` exists. + In default transaction process the `providerCommissionLineItem` can be expected to be there but if + the process is using only customer commission there will be error. + [#1112](https://github.com/sharetribe/flex-template-web/pull/1112) - [fix] Fix a bug in showing review links. Because of the bug the second review link was not visible in `ActivityFeed`. [#1106](https://github.com/sharetribe/flex-template-web/pull/1106) - [fix] Emptying the priceFilter component in the searchPage caused a page breaking error. diff --git a/src/components/BookingBreakdown/LineItemCustomerCommissionMaybe.js b/src/components/BookingBreakdown/LineItemCustomerCommissionMaybe.js index 6f156392..d926e292 100644 --- a/src/components/BookingBreakdown/LineItemCustomerCommissionMaybe.js +++ b/src/components/BookingBreakdown/LineItemCustomerCommissionMaybe.js @@ -12,7 +12,11 @@ const { Money } = sdkTypes; // Validate the assumption that the commission exists and the amount // is zero or positive. const isValidCommission = commissionLineItem => { - return commissionLineItem.lineTotal instanceof Money && commissionLineItem.lineTotal.amount >= 0; + return ( + commissionLineItem && + commissionLineItem.lineTotal instanceof Money && + commissionLineItem.lineTotal.amount >= 0 + ); }; const LineItemCustomerCommissionMaybe = props => { diff --git a/src/components/BookingBreakdown/LineItemProviderCommissionMaybe.js b/src/components/BookingBreakdown/LineItemProviderCommissionMaybe.js index d8b034fe..8016e641 100644 --- a/src/components/BookingBreakdown/LineItemProviderCommissionMaybe.js +++ b/src/components/BookingBreakdown/LineItemProviderCommissionMaybe.js @@ -12,11 +12,7 @@ const { Money } = sdkTypes; // Validate the assumption that the commission exists and the amount // is zero or negative. const isValidCommission = commissionLineItem => { - return ( - commissionLineItem && - commissionLineItem.lineTotal instanceof Money && - commissionLineItem.lineTotal.amount <= 0 - ); + return commissionLineItem.lineTotal instanceof Money && commissionLineItem.lineTotal.amount <= 0; }; const LineItemProviderCommissionMaybe = props => { @@ -29,7 +25,10 @@ const LineItemProviderCommissionMaybe = props => { // If commission is passed it will be shown as a fee already reduces from the total price let commissionItem = null; - if (isProvider) { + // Flex Template for Web is using the default transaction process (https://www.sharetribe.com/docs/background/transaction-process/#sharetribe-flex-default-transaction-process) + // which containt provider commissions so by default the providerCommissionLineItem should exist. + // If you are not using provider commisison you might want to remove this whole component from BookingBreakdown.js file. + if (isProvider && providerCommissionLineItem) { if (!isValidCommission(providerCommissionLineItem)) { // eslint-disable-next-line no-console console.error('invalid commission line item:', providerCommissionLineItem);