diff --git a/src/components/BookingBreakdown/BookingBreakdown.example.js b/src/components/BookingBreakdown/BookingBreakdown.example.js index 2491feef..2e714deb 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.example.js +++ b/src/components/BookingBreakdown/BookingBreakdown.example.js @@ -22,7 +22,6 @@ const exampleTransaction = params => { createdAt: created, lastTransitionedAt: created, lastTransition: propTypes.TX_TRANSITION_PREAUTHORIZE, - state: propTypes.TX_STATE_PREAUTHORIZED, // payinTotal, payoutTotal, and lineItems required in params ...params, @@ -165,7 +164,6 @@ export const ProviderSaleRejected = { props: { userRole: 'provider', transaction: exampleTransaction({ - state: propTypes.TX_STATE_REJECTED, lastTransition: propTypes.TX_TRANSITION_REJECT, payinTotal: new Money(4500, 'USD'), payoutTotal: new Money(2500, 'USD'), @@ -195,7 +193,6 @@ export const ProviderSaleDelivered = { props: { userRole: 'provider', transaction: exampleTransaction({ - state: propTypes.TX_STATE_DELIVERED, lastTransition: propTypes.TX_TRANSITION_MARK_DELIVERED, payinTotal: new Money(4500, 'USD'), payoutTotal: new Money(2500, 'USD'), diff --git a/src/components/BookingBreakdown/BookingBreakdown.js b/src/components/BookingBreakdown/BookingBreakdown.js index 9a83bb90..73aa1ecd 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.js +++ b/src/components/BookingBreakdown/BookingBreakdown.js @@ -111,9 +111,9 @@ export const BookingBreakdownComponent = props => { } let providerTotalMessageId = 'BookingBreakdown.providerTotalDefault'; - if (transaction.attributes.state === propTypes.TX_STATE_DELIVERED) { + if (transaction.attributes.lastTransition === propTypes.TX_TRANSITION_MARK_DELIVERED) { providerTotalMessageId = 'BookingBreakdown.providerTotalDelivered'; - } else if (transaction.attributes.state === propTypes.TX_STATE_REJECTED) { + } else if (transaction.attributes.lastTransition === propTypes.TX_TRANSITION_REJECT) { providerTotalMessageId = 'BookingBreakdown.providerTotalRejected'; } diff --git a/src/components/BookingBreakdown/BookingBreakdown.test.js b/src/components/BookingBreakdown/BookingBreakdown.test.js index 0985e574..8c0f4aca 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.test.js +++ b/src/components/BookingBreakdown/BookingBreakdown.test.js @@ -25,7 +25,6 @@ const exampleTransaction = params => { createdAt: created, lastTransitionedAt: created, lastTransition: propTypes.TX_TRANSITION_PREAUTHORIZE, - state: propTypes.TX_STATE_PREAUTHORIZED, // payinTotal, payoutTotal, and lineItems required in params ...params, diff --git a/src/components/OrderDetailsPanel/OrderDetailsPanel.js b/src/components/OrderDetailsPanel/OrderDetailsPanel.js index 129afb1d..ed77c31d 100644 --- a/src/components/OrderDetailsPanel/OrderDetailsPanel.js +++ b/src/components/OrderDetailsPanel/OrderDetailsPanel.js @@ -21,13 +21,9 @@ const breakdown = transaction => { : null; }; -const orderTitle = (orderState, listingLink, customerName, lastTransition) => { - const rejectedTranslationId = lastTransition === propTypes.TX_TRANSITION_AUTO_REJECT - ? 'OrderDetailsPanel.orderAutoRejectedTitle' - : 'OrderDetailsPanel.orderRejectedTitle'; - - switch (orderState) { - case propTypes.TX_STATE_PREAUTHORIZED: +const orderTitle = (lastTransition, listingLink, customerName) => { + switch (lastTransition) { + case propTypes.TX_TRANSITION_PREAUTHORIZE: return ( @@ -42,7 +38,7 @@ const orderTitle = (orderState, listingLink, customerName, lastTransition) => { /> ); - case propTypes.TX_STATE_ACCEPTED: + case propTypes.TX_TRANSITION_ACCEPT: return ( @@ -51,9 +47,15 @@ const orderTitle = (orderState, listingLink, customerName, lastTransition) => { ); - case propTypes.TX_STATE_REJECTED: - return ; - case propTypes.TX_STATE_DELIVERED: + case propTypes.TX_TRANSITION_REJECT: + return ( + + ); + case propTypes.TX_TRANSITION_AUTO_REJECT: + return ( + + ); + case propTypes.TX_TRANSITION_MARK_DELIVERED: return ( ); @@ -62,43 +64,42 @@ const orderTitle = (orderState, listingLink, customerName, lastTransition) => { } }; -const orderMessage = ( - orderState, - listingTitle, - providerName, - lastTransitionedAt, - lastTransition -) => { +const orderMessage = (lastTransition, listingTitle, providerName, lastTransitionedAt) => { const transitionDate = ( ); - - const rejectedTranslationId = lastTransition === propTypes.TX_TRANSITION_AUTO_REJECT - ? 'OrderDetailsPanel.orderAutoRejectedStatus' - : 'OrderDetailsPanel.orderRejectedStatus'; - - switch (orderState) { - case propTypes.TX_STATE_PREAUTHORIZED: + switch (lastTransition) { + case propTypes.TX_TRANSITION_PREAUTHORIZE: return ( ); - case propTypes.TX_STATE_ACCEPTED: + case propTypes.TX_TRANSITION_ACCEPT: return ( ); - case propTypes.TX_STATE_REJECTED: + case propTypes.TX_TRANSITION_REJECT: return ( - + ); - case propTypes.TX_STATE_DELIVERED: + case propTypes.TX_TRANSITION_AUTO_REJECT: + return ( + + ); + case propTypes.TX_TRANSITION_MARK_DELIVERED: return ( { const authorDisplayName = userDisplayName(currentProvider, bannedUserDisplayName); const customerDisplayName = userDisplayName(currentCustomer, bannedUserDisplayName); - const transactionState = currentTransaction.attributes.state; const lastTransitionedAt = currentTransaction.attributes.lastTransitionedAt; - const lastTransition = currentTransaction.attributes.lastTransitione; + const lastTransition = currentTransaction.attributes.lastTransition; let listingLink = null; @@ -163,21 +163,10 @@ export const OrderDetailsPanelComponent = props => { : currentListing.attributes.title; const bookingInfo = breakdown(currentTransaction); - const orderHeading = orderTitle( - transactionState, - listingLink, - customerDisplayName, - lastTransition - ); + const orderHeading = orderTitle(lastTransition, listingLink, customerDisplayName); const message = listingDeleted ? orderMessageDeletedListing - : orderMessage( - transactionState, - listingLink, - authorDisplayName, - lastTransitionedAt, - lastTransition - ); + : orderMessage(lastTransition, listingLink, authorDisplayName, lastTransitionedAt); const firstImage = currentListing.images && currentListing.images.length > 0 ? currentListing.images[0] diff --git a/src/components/OrderDetailsPanel/OrderDetailsPanel.test.js b/src/components/OrderDetailsPanel/OrderDetailsPanel.test.js index 5fbbac92..33902d45 100644 --- a/src/components/OrderDetailsPanel/OrderDetailsPanel.test.js +++ b/src/components/OrderDetailsPanel/OrderDetailsPanel.test.js @@ -4,6 +4,7 @@ import { types } from '../../util/sdkLoader'; import { createBooking, createListing, createUser, createTransaction } from '../../util/test-data'; import { renderShallow } from '../../util/test-helpers'; import { fakeIntl } from '../../util/test-data'; +import { TX_TRANSITION_PREAUTHORIZE } from '../../util/propTypes'; import { BookingBreakdown } from '../../components'; import { OrderDetailsPanelComponent } from './OrderDetailsPanel.js'; @@ -12,7 +13,7 @@ describe('OrderDetailsPanel', () => { const { Money } = types; const tx = createTransaction({ id: 'order-tx', - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, total: new Money(16500, 'USD'), booking: createBooking('booking1', { start: new Date(Date.UTC(2017, 5, 10)), @@ -29,7 +30,7 @@ describe('OrderDetailsPanel', () => { const { Money } = types; const tx = createTransaction({ id: 'order-tx', - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, total: new Money(16500, 'USD'), booking: createBooking('booking1', { start: new Date(Date.UTC(2017, 5, 10)), diff --git a/src/components/OrderDetailsPanel/__snapshots__/OrderDetailsPanel.test.js.snap b/src/components/OrderDetailsPanel/__snapshots__/OrderDetailsPanel.test.js.snap index bd276447..24dad4a0 100644 --- a/src/components/OrderDetailsPanel/__snapshots__/OrderDetailsPanel.test.js.snap +++ b/src/components/OrderDetailsPanel/__snapshots__/OrderDetailsPanel.test.js.snap @@ -141,7 +141,6 @@ exports[`OrderDetailsPanel matches snapshot 1`] = ` "amount": 16400, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { @@ -319,7 +318,6 @@ exports[`OrderDetailsPanel matches snapshot 1`] = ` "amount": 16400, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { diff --git a/src/components/SaleDetailsPanel/SaleDetailsPanel.js b/src/components/SaleDetailsPanel/SaleDetailsPanel.js index 57b6ae59..c1c4249c 100644 --- a/src/components/SaleDetailsPanel/SaleDetailsPanel.js +++ b/src/components/SaleDetailsPanel/SaleDetailsPanel.js @@ -28,30 +28,37 @@ const breakdown = transaction => { : null; }; -const saleTitle = (saleState, listingLink, customerName) => { - switch (saleState) { - case propTypes.TX_STATE_PREAUTHORIZED: +const saleTitle = (lastTransition, listingLink, customerName) => { + switch (lastTransition) { + case propTypes.TX_TRANSITION_PREAUTHORIZE: return ( ); - case propTypes.TX_STATE_ACCEPTED: + case propTypes.TX_TRANSITION_ACCEPT: return ( ); - case propTypes.TX_STATE_REJECTED: + case propTypes.TX_TRANSITION_REJECT: return ( ); - case propTypes.TX_STATE_DELIVERED: + case propTypes.TX_TRANSITION_AUTO_REJECT: + return ( + + ); + case propTypes.TX_TRANSITION_MARK_DELIVERED: return ( { } }; -const saleMessage = (saleState, customerName, lastTransitionedAt, lastTransition) => { +const saleMessage = (lastTransition, customerName, lastTransitionedAt) => { const formattedDate = ( ); - const rejectedStatusTranslationId = lastTransition === propTypes.TX_TRANSITION_AUTO_REJECT - ? 'SaleDetailsPanel.saleAutoRejectedStatus' - : 'SaleDetailsPanel.saleRejectedStatus'; - switch (saleState) { - case propTypes.TX_STATE_PREAUTHORIZED: + switch (lastTransition) { + case propTypes.TX_TRANSITION_PREAUTHORIZE: return ( ); - case propTypes.TX_STATE_ACCEPTED: { + case propTypes.TX_TRANSITION_ACCEPT: { return ( ); } - case propTypes.TX_STATE_REJECTED: - return ; - case propTypes.TX_STATE_DELIVERED: + case propTypes.TX_TRANSITION_REJECT: + return ( + + ); + case propTypes.TX_TRANSITION_AUTO_REJECT: + return ( + + ); + case propTypes.TX_TRANSITION_MARK_DELIVERED: return ( ); @@ -123,7 +133,6 @@ export const SaleDetailsPanelComponent = props => { }); const customerDisplayName = userDisplayName(currentCustomer, bannedUserDisplayName); - const transactionState = currentTransaction.attributes.state; const lastTransitionedAt = currentTransaction.attributes.lastTransitionedAt; const lastTransition = currentTransaction.attributes.lastTransition; @@ -141,20 +150,20 @@ export const SaleDetailsPanelComponent = props => { const bookingInfo = breakdown(currentTransaction); - const title = saleTitle(transactionState, listingLink, customerDisplayName, lastTransition); + const title = saleTitle(lastTransition, listingLink, customerDisplayName); const message = isCustomerBanned ? intl.formatMessage({ id: 'SaleDetailsPanel.customerBannedStatus', }) - : saleMessage(transactionState, customerDisplayName, lastTransitionedAt, lastTransition); + : saleMessage(lastTransition, customerDisplayName, lastTransitionedAt); const listingTitle = currentListing.attributes.title; const firstImage = currentListing.images && currentListing.images.length > 0 ? currentListing.images[0] : null; - const isPreauthorizedState = currentTransaction.attributes.state === - propTypes.TX_STATE_PREAUTHORIZED; + const isPreauthorizedState = currentTransaction.attributes.lastTransition === + propTypes.TX_TRANSITION_PREAUTHORIZE; const canShowButtons = isPreauthorizedState && !isCustomerBanned; const buttonsDisabled = acceptInProgress || rejectInProgress; diff --git a/src/components/SaleDetailsPanel/SaleDetailsPanel.test.js b/src/components/SaleDetailsPanel/SaleDetailsPanel.test.js index 0bd976a0..e9983bb6 100644 --- a/src/components/SaleDetailsPanel/SaleDetailsPanel.test.js +++ b/src/components/SaleDetailsPanel/SaleDetailsPanel.test.js @@ -4,6 +4,7 @@ import { types } from '../../util/sdkLoader'; import { createTransaction, createBooking, createListing, createUser } from '../../util/test-data'; import { renderShallow } from '../../util/test-helpers'; import { fakeIntl } from '../../util/test-data'; +import { TX_TRANSITION_PREAUTHORIZE } from '../../util/propTypes'; import { BookingBreakdown } from '../../components'; import { SaleDetailsPanelComponent } from './SaleDetailsPanel.js'; @@ -14,7 +15,7 @@ describe('SaleDetailsPanel', () => { const { Money } = types; const transaction = createTransaction({ id: 'sale-tx', - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, total: new Money(16500, 'USD'), commission: new Money(1000, 'USD'), booking: createBooking('booking1', { @@ -40,7 +41,7 @@ describe('SaleDetailsPanel', () => { const { Money } = types; const transaction = createTransaction({ id: 'sale-tx', - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, total: new Money(16500, 'USD'), commission: new Money(1000, 'USD'), booking: createBooking('booking1', { diff --git a/src/components/SaleDetailsPanel/__snapshots__/SaleDetailsPanel.test.js.snap b/src/components/SaleDetailsPanel/__snapshots__/SaleDetailsPanel.test.js.snap index dd3f8af3..e723112c 100644 --- a/src/components/SaleDetailsPanel/__snapshots__/SaleDetailsPanel.test.js.snap +++ b/src/components/SaleDetailsPanel/__snapshots__/SaleDetailsPanel.test.js.snap @@ -167,7 +167,6 @@ exports[`SaleDetailsPanel matches snapshot 1`] = ` "amount": 15500, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { @@ -302,7 +301,6 @@ exports[`SaleDetailsPanel matches snapshot 1`] = ` "amount": 15500, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { diff --git a/src/containers/BookingDatesForm/BookingDatesForm.js b/src/containers/BookingDatesForm/BookingDatesForm.js index 0fbe6083..0b112b8e 100644 --- a/src/containers/BookingDatesForm/BookingDatesForm.js +++ b/src/containers/BookingDatesForm/BookingDatesForm.js @@ -40,7 +40,6 @@ const estimatedNightlyTransaction = (bookingStart, bookingEnd, unitPrice) => { createdAt: now, lastTransitionedAt: now, lastTransition: propTypes.TX_TRANSITION_PREAUTHORIZE, - state: propTypes.TX_STATE_PREAUTHORIZED, payinTotal: totalPrice, payoutTotal: totalPrice, lineItems: [ diff --git a/src/containers/BookingDatesForm/BookingDatesForm.test.js b/src/containers/BookingDatesForm/BookingDatesForm.test.js index c9b2755c..2095f898 100644 --- a/src/containers/BookingDatesForm/BookingDatesForm.test.js +++ b/src/containers/BookingDatesForm/BookingDatesForm.test.js @@ -50,7 +50,6 @@ describe('BookingDatesForm', () => { expect(booking.attributes.start).toEqual(startDate); expect(booking.attributes.end).toEqual(endDate); expect(transaction.attributes.lastTransition).toEqual(propTypes.TX_TRANSITION_PREAUTHORIZE); - expect(transaction.attributes.state).toEqual(propTypes.TX_STATE_PREAUTHORIZED); expect(transaction.attributes.payinTotal).toEqual(new Money(2198, 'USD')); expect(transaction.attributes.payoutTotal).toEqual(new Money(2198, 'USD')); expect(transaction.attributes.lineItems).toEqual([ diff --git a/src/containers/InboxPage/InboxPage.js b/src/containers/InboxPage/InboxPage.js index 5438681a..fd23d4e4 100644 --- a/src/containers/InboxPage/InboxPage.js +++ b/src/containers/InboxPage/InboxPage.js @@ -39,8 +39,8 @@ const formatDate = (intl, date) => { // Translated name of the state of the given transaction const txState = (intl, tx, isOrder) => { - const { attributes: { state } } = tx; - if (state === propTypes.TX_STATE_ACCEPTED) { + const { attributes: { lastTransition } } = tx; + if (lastTransition === propTypes.TX_TRANSITION_ACCEPT) { return { nameClassName: css.nameAccepted, bookingClassName: css.bookingAccepted, @@ -50,7 +50,7 @@ const txState = (intl, tx, isOrder) => { id: 'InboxPage.stateAccepted', }), }; - } else if (state === propTypes.TX_STATE_REJECTED) { + } else if (lastTransition === propTypes.TX_TRANSITION_REJECT) { return { nameClassName: css.nameDeclined, bookingClassName: css.bookingDeclined, @@ -60,7 +60,7 @@ const txState = (intl, tx, isOrder) => { id: 'InboxPage.stateDeclined', }), }; - } else if (state === propTypes.TX_STATE_DELIVERED) { + } else if (lastTransition === propTypes.TX_TRANSITION_MARK_DELIVERED) { return { nameClassName: css.nameDelivered, bookingClassName: css.bookingDelivered, @@ -101,7 +101,8 @@ export const InboxItem = props => { const otherUserDisplayName = userDisplayName(otherUser, bannedUserDisplayName); const stateData = txState(intl, tx, isOrder); - const isSaleNotification = !isOrder && tx.attributes.state === propTypes.TX_STATE_PREAUTHORIZED; + const isPreauthorized = tx.attributes.lastTransition === propTypes.TX_TRANSITION_PREAUTHORIZE; + const isSaleNotification = !isOrder && isPreauthorized; const rowNotificationDot = isSaleNotification ?
: null; const lastTransitionedAt = formatDate(intl, tx.attributes.lastTransitionedAt); const bookingStart = formatDate(intl, booking.attributes.start); diff --git a/src/containers/InboxPage/InboxPage.test.js b/src/containers/InboxPage/InboxPage.test.js index 3fe348ea..a19fc4fb 100644 --- a/src/containers/InboxPage/InboxPage.test.js +++ b/src/containers/InboxPage/InboxPage.test.js @@ -5,6 +5,7 @@ import { fakeIntl, createUser, createTransaction, createBooking } from '../../ut import { InboxPageComponent, InboxItem } from './InboxPage'; import routesConfiguration from '../../routesConfiguration'; import { flattenRoutes } from '../../util/routes'; +import { TX_TRANSITION_PREAUTHORIZE } from '../../util/propTypes'; const noop = () => null; @@ -39,14 +40,14 @@ describe('InboxPage', () => { transactions: [ createTransaction({ id: 'order-1', - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, provider, lastTransitionedAt: new Date(Date.UTC(2017, 0, 15)), booking: booking1, }), createTransaction({ id: 'order-2', - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, provider, lastTransitionedAt: new Date(Date.UTC(2016, 0, 15)), booking: booking2, @@ -86,14 +87,14 @@ describe('InboxPage', () => { transactions: [ createTransaction({ id: 'sale-1', - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, customer, lastTransitionedAt: new Date(Date.UTC(2017, 0, 15)), booking: booking1, }), createTransaction({ id: 'sale-2', - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, customer, lastTransitionedAt: new Date(Date.UTC(2016, 0, 15)), booking: booking2, diff --git a/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap b/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap index c8c6cfa2..ec68e807 100644 --- a/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap +++ b/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap @@ -127,7 +127,6 @@ exports[`InboxPage matches snapshot 1`] = ` "amount": 900, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { @@ -215,7 +214,6 @@ exports[`InboxPage matches snapshot 1`] = ` "amount": 900, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { @@ -437,7 +435,6 @@ exports[`InboxPage matches snapshot 3`] = ` "amount": 900, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { @@ -525,7 +522,6 @@ exports[`InboxPage matches snapshot 3`] = ` "amount": 900, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { diff --git a/src/containers/OrderPage/OrderPage.test.js b/src/containers/OrderPage/OrderPage.test.js index 0b34c99e..9525e239 100644 --- a/src/containers/OrderPage/OrderPage.test.js +++ b/src/containers/OrderPage/OrderPage.test.js @@ -8,6 +8,7 @@ import { fakeIntl, } from '../../util/test-data'; import { renderShallow } from '../../util/test-helpers'; +import { TX_TRANSITION_PREAUTHORIZE } from '../../util/propTypes'; import { OrderPageComponent } from './OrderPage'; const noop = () => null; @@ -17,7 +18,7 @@ describe('OrderPage', () => { const txId = 'tx-order-1'; const transaction = createTransaction({ id: txId, - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, booking: createBooking('booking1', { start: new Date(Date.UTC(2017, 5, 10)), end: new Date(Date.UTC(2017, 5, 13)), diff --git a/src/containers/OrderPage/__snapshots__/OrderPage.test.js.snap b/src/containers/OrderPage/__snapshots__/OrderPage.test.js.snap index 6a0c4e9d..5599df1c 100644 --- a/src/containers/OrderPage/__snapshots__/OrderPage.test.js.snap +++ b/src/containers/OrderPage/__snapshots__/OrderPage.test.js.snap @@ -86,7 +86,6 @@ exports[`OrderPage matches snapshot 1`] = ` "amount": 900, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { diff --git a/src/containers/SalePage/SalePage.test.js b/src/containers/SalePage/SalePage.test.js index faa564b1..2c5a74a4 100644 --- a/src/containers/SalePage/SalePage.test.js +++ b/src/containers/SalePage/SalePage.test.js @@ -8,6 +8,7 @@ import { fakeIntl, } from '../../util/test-data'; import { renderShallow } from '../../util/test-helpers'; +import { TX_TRANSITION_PREAUTHORIZE } from '../../util/propTypes'; import { SalePageComponent } from './SalePage'; const noop = () => null; @@ -17,7 +18,7 @@ describe('SalePage', () => { const txId = 'tx-sale-1'; const transaction = createTransaction({ id: txId, - state: 'state/preauthorized', + lastTransition: TX_TRANSITION_PREAUTHORIZE, booking: createBooking('booking1', { start: new Date(Date.UTC(2017, 5, 10)), end: new Date(Date.UTC(2017, 5, 13)), diff --git a/src/containers/SalePage/__snapshots__/SalePage.test.js.snap b/src/containers/SalePage/__snapshots__/SalePage.test.js.snap index e2fc9d4b..3a600384 100644 --- a/src/containers/SalePage/__snapshots__/SalePage.test.js.snap +++ b/src/containers/SalePage/__snapshots__/SalePage.test.js.snap @@ -93,7 +93,6 @@ exports[`SalePage matches snapshot 1`] = ` "amount": 900, "currency": "USD", }, - "state": "state/preauthorized", }, "booking": Object { "attributes": Object { diff --git a/src/ducks/user.duck.js b/src/ducks/user.duck.js index ea8c59e4..ede121a4 100644 --- a/src/ducks/user.duck.js +++ b/src/ducks/user.duck.js @@ -1,5 +1,4 @@ import { updatedEntities, denormalisedEntities } from '../util/data'; -import { TX_STATE_PREAUTHORIZED } from '../util/propTypes'; // ================ Action types ================ // @@ -299,7 +298,8 @@ export const fetchCurrentUserNotifications = () => const apiQueryParams = { only: 'sale', - states: [TX_STATE_PREAUTHORIZED], + // TODO: how to change this to use lastTransition? + // states: [TX_STATE_PREAUTHORIZED], page: 1, per_page: NOTIFICATION_PAGE_SIZE, }; diff --git a/src/util/propTypes.js b/src/util/propTypes.js index e89e6446..2529bd6c 100644 --- a/src/util/propTypes.js +++ b/src/util/propTypes.js @@ -135,18 +135,6 @@ export const booking = shape({ }), }); -export const TX_STATE_ACCEPTED = 'state/accepted'; -export const TX_STATE_REJECTED = 'state/rejected'; -export const TX_STATE_PREAUTHORIZED = 'state/preauthorized'; -export const TX_STATE_DELIVERED = 'state/delivered'; - -export const TX_STATES = [ - TX_STATE_ACCEPTED, - TX_STATE_REJECTED, - TX_STATE_PREAUTHORIZED, - TX_STATE_DELIVERED, -]; - // When the customer requests a booking, a transaction is created. The // initial state is preauthorized that is transitioned with the // initial preauthorize transition. The customer can see this @@ -183,7 +171,6 @@ export const transaction = shape({ createdAt: instanceOf(Date).isRequired, lastTransitionedAt: instanceOf(Date).isRequired, lastTransition: oneOf(TX_TRANSITIONS).isRequired, - state: oneOf(TX_STATES).isRequired, payinTotal: money.isRequired, payoutTotal: money.isRequired, lineItems: arrayOf( diff --git a/src/util/test-data.js b/src/util/test-data.js index 5086bd02..4145ec80 100644 --- a/src/util/test-data.js +++ b/src/util/test-data.js @@ -89,7 +89,6 @@ export const createListing = (id, attributes = {}, includes = {}) => ({ export const createTransaction = options => { const { id, - state = propTypes.TX_STATE_PREAUTHORIZED, lastTransition = propTypes.TX_TRANSITION_PREAUTHORIZE, total = new Money(1000, 'USD'), commission = new Money(100, 'USD'), @@ -106,7 +105,6 @@ export const createTransaction = options => { attributes: { createdAt: new Date(Date.UTC(2017, 4, 1)), lastTransitionedAt, - state, lastTransition, payinTotal: total, payoutTotal: new Money(total.amount - commission.amount, total.currency),