mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-25 22:37:18 +10:00
prevent error when a provider commission does not exist
This commit is contained in:
parent
a740d03ca2
commit
4b2560b228
2 changed files with 7 additions and 7 deletions
|
|
@ -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,7 @@ 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) {
|
||||
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