mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 12:43:11 +10:00
Use transaction lastTransition instead of state
This commit is contained in:
parent
35a2a74f5a
commit
0c7b8ca355
21 changed files with 88 additions and 115 deletions
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<span>
|
||||
<span className={css.mainTitle}>
|
||||
|
|
@ -42,7 +38,7 @@ const orderTitle = (orderState, listingLink, customerName, lastTransition) => {
|
|||
/>
|
||||
</span>
|
||||
);
|
||||
case propTypes.TX_STATE_ACCEPTED:
|
||||
case propTypes.TX_TRANSITION_ACCEPT:
|
||||
return (
|
||||
<span>
|
||||
<span className={css.mainTitle}>
|
||||
|
|
@ -51,9 +47,15 @@ const orderTitle = (orderState, listingLink, customerName, lastTransition) => {
|
|||
<FormattedMessage id="OrderDetailsPanel.orderAcceptedSubtitle" values={{ listingLink }} />
|
||||
</span>
|
||||
);
|
||||
case propTypes.TX_STATE_REJECTED:
|
||||
return <FormattedMessage id={rejectedTranslationId} values={{ listingLink }} />;
|
||||
case propTypes.TX_STATE_DELIVERED:
|
||||
case propTypes.TX_TRANSITION_REJECT:
|
||||
return (
|
||||
<FormattedMessage id="OrderDetailsPanel.orderRejectedTitle" values={{ listingLink }} />
|
||||
);
|
||||
case propTypes.TX_TRANSITION_AUTO_REJECT:
|
||||
return (
|
||||
<FormattedMessage id="OrderDetailsPanel.orderAutoRejectedTitle" values={{ listingLink }} />
|
||||
);
|
||||
case propTypes.TX_TRANSITION_MARK_DELIVERED:
|
||||
return (
|
||||
<FormattedMessage id="OrderDetailsPanel.orderDeliveredTitle" values={{ listingLink }} />
|
||||
);
|
||||
|
|
@ -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 = (
|
||||
<span className={css.transitionDate}>
|
||||
<FormattedDate value={lastTransitionedAt} year="numeric" month="short" day="numeric" />
|
||||
</span>
|
||||
);
|
||||
|
||||
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 (
|
||||
<FormattedMessage
|
||||
id="OrderDetailsPanel.orderPreauthorizedStatus"
|
||||
values={{ providerName }}
|
||||
/>
|
||||
);
|
||||
case propTypes.TX_STATE_ACCEPTED:
|
||||
case propTypes.TX_TRANSITION_ACCEPT:
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="OrderDetailsPanel.orderAcceptedStatus"
|
||||
values={{ providerName, transitionDate }}
|
||||
/>
|
||||
);
|
||||
case propTypes.TX_STATE_REJECTED:
|
||||
case propTypes.TX_TRANSITION_REJECT:
|
||||
return (
|
||||
<FormattedMessage id={rejectedTranslationId} values={{ providerName, transitionDate }} />
|
||||
<FormattedMessage
|
||||
id="OrderDetailsPanel.orderRejectedStatus"
|
||||
values={{ providerName, transitionDate }}
|
||||
/>
|
||||
);
|
||||
case propTypes.TX_STATE_DELIVERED:
|
||||
case propTypes.TX_TRANSITION_AUTO_REJECT:
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="OrderDetailsPanel.orderAutoRejectedStatus"
|
||||
values={{ providerName, transitionDate }}
|
||||
/>
|
||||
);
|
||||
case propTypes.TX_TRANSITION_MARK_DELIVERED:
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="OrderDetailsPanel.orderDeliveredStatus"
|
||||
|
|
@ -140,9 +141,8 @@ export const OrderDetailsPanelComponent = props => {
|
|||
|
||||
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]
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<FormattedMessage
|
||||
id="SaleDetailsPanel.listingRequestedTitle"
|
||||
values={{ customerName, listingLink }}
|
||||
/>
|
||||
);
|
||||
case propTypes.TX_STATE_ACCEPTED:
|
||||
case propTypes.TX_TRANSITION_ACCEPT:
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="SaleDetailsPanel.listingAcceptedTitle"
|
||||
values={{ customerName, listingLink }}
|
||||
/>
|
||||
);
|
||||
case propTypes.TX_STATE_REJECTED:
|
||||
case propTypes.TX_TRANSITION_REJECT:
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="SaleDetailsPanel.listingRejectedTitle"
|
||||
values={{ customerName, listingLink }}
|
||||
/>
|
||||
);
|
||||
case propTypes.TX_STATE_DELIVERED:
|
||||
case propTypes.TX_TRANSITION_AUTO_REJECT:
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="SaleDetailsPanel.listingRejectedTitle"
|
||||
values={{ customerName, listingLink }}
|
||||
/>
|
||||
);
|
||||
case propTypes.TX_TRANSITION_MARK_DELIVERED:
|
||||
return (
|
||||
<FormattedMessage
|
||||
id="SaleDetailsPanel.listingDeliveredTitle"
|
||||
|
|
@ -63,7 +70,7 @@ const saleTitle = (saleState, listingLink, customerName) => {
|
|||
}
|
||||
};
|
||||
|
||||
const saleMessage = (saleState, customerName, lastTransitionedAt, lastTransition) => {
|
||||
const saleMessage = (lastTransition, customerName, lastTransitionedAt) => {
|
||||
const formattedDate = (
|
||||
<span className={css.nowrap}>
|
||||
<FormattedDate
|
||||
|
|
@ -75,22 +82,25 @@ const saleMessage = (saleState, customerName, lastTransitionedAt, lastTransition
|
|||
/>
|
||||
</span>
|
||||
);
|
||||
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 (
|
||||
<FormattedMessage id="SaleDetailsPanel.saleRequestedStatus" values={{ customerName }} />
|
||||
);
|
||||
case propTypes.TX_STATE_ACCEPTED: {
|
||||
case propTypes.TX_TRANSITION_ACCEPT: {
|
||||
return (
|
||||
<FormattedMessage id="SaleDetailsPanel.saleAcceptedStatus" values={{ formattedDate }} />
|
||||
);
|
||||
}
|
||||
case propTypes.TX_STATE_REJECTED:
|
||||
return <FormattedMessage id={rejectedStatusTranslationId} values={{ formattedDate }} />;
|
||||
case propTypes.TX_STATE_DELIVERED:
|
||||
case propTypes.TX_TRANSITION_REJECT:
|
||||
return (
|
||||
<FormattedMessage id="SaleDetailsPanel.saleRejectedStatus" values={{ formattedDate }} />
|
||||
);
|
||||
case propTypes.TX_TRANSITION_AUTO_REJECT:
|
||||
return (
|
||||
<FormattedMessage id="SaleDetailsPanel.saleAutoRejectedStatus" values={{ formattedDate }} />
|
||||
);
|
||||
case propTypes.TX_TRANSITION_MARK_DELIVERED:
|
||||
return (
|
||||
<FormattedMessage id="SaleDetailsPanel.saleDeliveredStatus" values={{ formattedDate }} />
|
||||
);
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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', {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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: [
|
||||
|
|
|
|||
|
|
@ -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([
|
||||
|
|
|
|||
|
|
@ -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 ? <div className={css.notificationDot} /> : null;
|
||||
const lastTransitionedAt = formatDate(intl, tx.attributes.lastTransitionedAt);
|
||||
const bookingStart = formatDate(intl, booking.attributes.start);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ exports[`OrderPage matches snapshot 1`] = `
|
|||
"amount": 900,
|
||||
"currency": "USD",
|
||||
},
|
||||
"state": "state/preauthorized",
|
||||
},
|
||||
"booking": Object {
|
||||
"attributes": Object {
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ exports[`SalePage matches snapshot 1`] = `
|
|||
"amount": 900,
|
||||
"currency": "USD",
|
||||
},
|
||||
"state": "state/preauthorized",
|
||||
},
|
||||
"booking": Object {
|
||||
"attributes": Object {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue