mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Merge pull request #1112 from sharetribe/prevent-provider-commission-error
Prevent provider commission error
This commit is contained in:
commit
c46e9f2ca0
3 changed files with 14 additions and 7 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 => {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue