From 096af7c766a9bc7a948f6f5513c4c0b04679d88c Mon Sep 17 00:00:00 2001 From: Mikko Koski Date: Fri, 30 Jun 2017 10:58:12 +0300 Subject: [PATCH] Fix merge conflicts and run prettier --- .../BookingBreakdown.example.js | 107 ++++++++++-------- .../BookingBreakdown/BookingBreakdown.js | 16 +-- .../BookingBreakdown/BookingBreakdown.test.js | 51 +++++---- .../BookingDatesForm/BookingDatesForm.js | 14 ++- src/util/test-data.js | 23 ++-- 5 files changed, 118 insertions(+), 93 deletions(-) diff --git a/src/components/BookingBreakdown/BookingBreakdown.example.js b/src/components/BookingBreakdown/BookingBreakdown.example.js index a41ffcc0..3050038c 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.example.js +++ b/src/components/BookingBreakdown/BookingBreakdown.example.js @@ -7,13 +7,15 @@ export const Checkout = { props: { bookingStart: new Date(Date.UTC(2017, 3, 14)), bookingEnd: new Date(Date.UTC(2017, 3, 16)), - userRole: "customer", - lineItems: [{ - code: "line-item.purchase/night", - quantity: new Decimal(2), - unitPrice: new types.Money(4500, 'USD'), - lineTotal: new types.Money(9000, 'USD'), - }], + userRole: 'customer', + lineItems: [ + { + code: 'line-item.purchase/night', + quantity: new Decimal(2), + unitPrice: new types.Money(4500, 'USD'), + lineTotal: new types.Money(9000, 'USD'), + }, + ], payinTotal: new types.Money(9000, 'USD'), }, }; @@ -23,13 +25,15 @@ export const CustomerOrder = { props: { bookingStart: new Date(Date.UTC(2017, 3, 14)), bookingEnd: new Date(Date.UTC(2017, 3, 16)), - userRole: "customer", - lineItems: [{ - code: "line-item.purchase/night", - quantity: new Decimal(2), - unitPrice: new types.Money(4500, 'USD'), - lineTotal: new types.Money(9000, 'USD'), - }], + userRole: 'customer', + lineItems: [ + { + code: 'line-item.purchase/night', + quantity: new Decimal(2), + unitPrice: new types.Money(4500, 'USD'), + lineTotal: new types.Money(9000, 'USD'), + }, + ], payinTotal: new types.Money(9000, 'USD'), }, }; @@ -39,17 +43,20 @@ export const ProviderSale = { props: { bookingStart: new Date(Date.UTC(2017, 3, 14)), bookingEnd: new Date(Date.UTC(2017, 3, 16)), - userRole: "provider", - lineItems: [{ - code: "line-item.purchase/night", - quantity: new Decimal(2), - unitPrice: new types.Money(4500, 'USD'), - lineTotal: new types.Money(9000, 'USD'), - }, { - code: "line-item.commission/provider", - unitPrice: new types.Money(-2000, 'USD'), - lineTotal: new types.Money(-2000, 'USD'), - }], + userRole: 'provider', + lineItems: [ + { + code: 'line-item.purchase/night', + quantity: new Decimal(2), + unitPrice: new types.Money(4500, 'USD'), + lineTotal: new types.Money(9000, 'USD'), + }, + { + code: 'line-item.commission/provider', + unitPrice: new types.Money(-2000, 'USD'), + lineTotal: new types.Money(-2000, 'USD'), + }, + ], payoutTotal: new types.Money(7000, 'USD'), }, }; @@ -59,17 +66,20 @@ export const ProviderSaleZeroCommission = { props: { bookingStart: new Date(Date.UTC(2017, 3, 14)), bookingEnd: new Date(Date.UTC(2017, 3, 16)), - userRole: "provider", - lineItems: [{ - code: "line-item.purchase/night", - quantity: new Decimal(2), - unitPrice: new types.Money(4500, 'USD'), - lineTotal: new types.Money(9000, 'USD'), - }, { - code: "line-item.commission/provider", - unitPrice: new types.Money(0, 'USD'), - lineTotal: new types.Money(0, 'USD'), - }], + userRole: 'provider', + lineItems: [ + { + code: 'line-item.purchase/night', + quantity: new Decimal(2), + unitPrice: new types.Money(4500, 'USD'), + lineTotal: new types.Money(9000, 'USD'), + }, + { + code: 'line-item.commission/provider', + unitPrice: new types.Money(0, 'USD'), + lineTotal: new types.Money(0, 'USD'), + }, + ], payoutTotal: new types.Money(9000, 'USD'), }, }; @@ -79,17 +89,20 @@ export const ProviderSaleSingleNight = { props: { bookingStart: new Date(Date.UTC(2017, 3, 14)), bookingEnd: new Date(Date.UTC(2017, 3, 15)), - userRole: "provider", - lineItems: [{ - code: "line-item.purchase/night", - quantity: new Decimal(1), - unitPrice: new types.Money(4500, 'USD'), - lineTotal: new types.Money(4500, 'USD'), - },{ - code: "line-item.commission/provider", - lineTotal: new types.Money(-2000, 'USD'), - unitPrice: new types.Money(-2000, 'USD'), - }], + userRole: 'provider', + lineItems: [ + { + code: 'line-item.purchase/night', + quantity: new Decimal(1), + unitPrice: new types.Money(4500, 'USD'), + lineTotal: new types.Money(4500, 'USD'), + }, + { + code: 'line-item.commission/provider', + unitPrice: new types.Money(-2000, 'USD'), + lineTotal: new types.Money(-2000, 'USD'), + }, + ], payoutTotal: new types.Money(2500, 'USD'), }, }; diff --git a/src/components/BookingBreakdown/BookingBreakdown.js b/src/components/BookingBreakdown/BookingBreakdown.js index 1329f1ee..cc7627a6 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.js +++ b/src/components/BookingBreakdown/BookingBreakdown.js @@ -71,20 +71,20 @@ export const BookingBreakdownComponent = props => { // If commission is passed it will be shown as a fee already reduces from the total price let commissionInfo = null; - if (userRole === "provider") { + if (userRole === 'provider') { const commission = providerCommission.lineTotal; const commissionAsNumber = commission ? convertMoneyToNumber(commission, subUnitDivisor) : 0; const formattedCommission = commission - ? intl.formatNumber(new Decimal(commissionAsNumber).negated().toNumber(), currencyConfig) - : null; + ? intl.formatNumber(new Decimal(commissionAsNumber).negated().toNumber(), currencyConfig) + : null; commissionInfo = (
- - - - {formattedCommission} -
+ + + + {formattedCommission} + ); } diff --git a/src/components/BookingBreakdown/BookingBreakdown.test.js b/src/components/BookingBreakdown/BookingBreakdown.test.js index 7e5183ae..0694464d 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.test.js +++ b/src/components/BookingBreakdown/BookingBreakdown.test.js @@ -13,12 +13,14 @@ describe('BookingBreakdown', () => { bookingEnd={new Date(Date.UTC(2017, 3, 16))} payinTotal={new types.Money(2000, 'USD')} userRole="customer" - lineItems={[{ - code: "line-item.purchase/night", - quantity: new Decimal(2), - lineTotal: new types.Money(2000, 'USD'), - unitPrice: new types.Money(1000, 'USD'), - }]} + lineItems={[ + { + code: 'line-item.purchase/night', + quantity: new Decimal(2), + lineTotal: new types.Money(2000, 'USD'), + unitPrice: new types.Money(1000, 'USD'), + }, + ]} intl={fakeIntl} /> ); @@ -32,12 +34,14 @@ describe('BookingBreakdown', () => { bookingEnd={new Date(Date.UTC(2017, 3, 16))} userRole="customer" payinTotal={new types.Money(2000, 'USD')} - lineItems={[{ - code: "line-item.purchase/night", - quantity: new Decimal(2), - lineTotal: new types.Money(2000, 'USD'), - unitPrice: new types.Money(1000, 'USD'), - }]} + lineItems={[ + { + code: 'line-item.purchase/night', + quantity: new Decimal(2), + lineTotal: new types.Money(2000, 'USD'), + unitPrice: new types.Money(1000, 'USD'), + }, + ]} intl={fakeIntl} /> ); @@ -52,16 +56,19 @@ describe('BookingBreakdown', () => { commission={new types.Money(200, 'USD')} payoutTotal={new types.Money(1800, 'USD')} userRole="provider" - lineItems={[{ - code: "line-item.purchase/night", - quantity: new Decimal(2), - lineTotal: new types.Money(2000, 'USD'), - unitPrice: new types.Money(1000, 'USD'), - }, { - code: "line-item.commission/provider", - lineTotal: new types.Money(200, 'USD'), - unitPrice: new types.Money(200, 'USD'), - }]} + lineItems={[ + { + code: 'line-item.purchase/night', + quantity: new Decimal(2), + lineTotal: new types.Money(2000, 'USD'), + unitPrice: new types.Money(1000, 'USD'), + }, + { + code: 'line-item.commission/provider', + lineTotal: new types.Money(200, 'USD'), + unitPrice: new types.Money(200, 'USD'), + }, + ]} intl={fakeIntl} /> ); diff --git a/src/containers/BookingDatesForm/BookingDatesForm.js b/src/containers/BookingDatesForm/BookingDatesForm.js index ed3aada4..623558a0 100644 --- a/src/containers/BookingDatesForm/BookingDatesForm.js +++ b/src/containers/BookingDatesForm/BookingDatesForm.js @@ -34,12 +34,14 @@ const breakdown = (bookingStart, bookingEnd, unitPrice) => { } const nightCount = nightsBetween(bookingStart, bookingEnd); const totalPrice = estimatedTotalPrice(unitPrice, nightCount); - const lineItems = [{ - code: "line-item.purchase/night", - unitPrice: unitPrice, - quantity: new Decimal(nightCount), - lineTotal: totalPrice, - }]; + const lineItems = [ + { + code: 'line-item.purchase/night', + unitPrice: unitPrice, + quantity: new Decimal(nightCount), + lineTotal: totalPrice, + }, + ]; return ( { state, payinTotal: total, payoutTotal: new Money(total.amount - commission.amount, total.currency), - lineItems: [{ - code: "line-item.purchase/night", - quantity: new Decimal(nightCount), - unitPrice: new Money(total.amount / nightCount, total.currency), - lineTotal: total, - }, { - code: "line-item.commission/provider", - unitPrice: commission, - lineTotal: commission, - }] + lineItems: [ + { + code: 'line-item.purchase/night', + quantity: new Decimal(nightCount), + unitPrice: new Money(total.amount / nightCount, total.currency), + lineTotal: total, + }, + { + code: 'line-item.commission/provider', + unitPrice: commission, + lineTotal: commission, + }, + ], }, booking, listing,