Merge pull request #490 from sharetribe/reject-to-decline

Reject to decline
This commit is contained in:
Sampo Toiva 2017-10-13 09:47:02 +03:00 committed by GitHub
commit 4f3acd82fe
18 changed files with 936 additions and 936 deletions

View file

@ -217,12 +217,12 @@ export const ProviderSaleAccepted = {
},
};
export const ProviderSaleRejected = {
export const ProviderSaleDeclined = {
component: BookingBreakdown,
props: {
userRole: 'provider',
transaction: exampleTransaction({
lastTransition: propTypes.TX_TRANSITION_REJECT,
lastTransition: propTypes.TX_TRANSITION_DECLINE,
payinTotal: new Money(4500, 'USD'),
payoutTotal: new Money(2500, 'USD'),
lineItems: [
@ -246,12 +246,12 @@ export const ProviderSaleRejected = {
},
};
export const ProviderSaleAutoRejected = {
export const ProviderSaleAutoDeclined = {
component: BookingBreakdown,
props: {
userRole: 'provider',
transaction: exampleTransaction({
lastTransition: propTypes.TX_TRANSITION_AUTO_REJECT,
lastTransition: propTypes.TX_TRANSITION_AUTO_DECLINE,
payinTotal: new Money(4500, 'USD'),
payoutTotal: new Money(2500, 'USD'),
lineItems: [

View file

@ -123,8 +123,8 @@ export const BookingBreakdownComponent = props => {
let providerTotalMessageId = 'BookingBreakdown.providerTotalDefault';
if (propTypes.txIsDelivered(transaction)) {
providerTotalMessageId = 'BookingBreakdown.providerTotalDelivered';
} else if (propTypes.txIsRejectedOrAutorejected(transaction)) {
providerTotalMessageId = 'BookingBreakdown.providerTotalRejected';
} else if (propTypes.txIsDeclinedOrAutodeclined(transaction)) {
providerTotalMessageId = 'BookingBreakdown.providerTotalDeclined';
} else if (propTypes.txIsCanceled(transaction)) {
providerTotalMessageId = 'BookingBreakdown.providerTotalCanceled';
}

View file

@ -46,11 +46,11 @@ const orderTitle = (transaction, listingLink, customerName) => {
<FormattedMessage id="OrderDetailsPanel.orderAcceptedSubtitle" values={{ listingLink }} />
</span>
);
} else if (propTypes.txIsRejected(transaction)) {
return <FormattedMessage id="OrderDetailsPanel.orderRejectedTitle" values={{ listingLink }} />;
} else if (propTypes.txIsAutorejected(transaction)) {
} else if (propTypes.txIsDeclined(transaction)) {
return <FormattedMessage id="OrderDetailsPanel.orderDeclinedTitle" values={{ listingLink }} />;
} else if (propTypes.txIsAutodeclined(transaction)) {
return (
<FormattedMessage id="OrderDetailsPanel.orderAutoRejectedTitle" values={{ listingLink }} />
<FormattedMessage id="OrderDetailsPanel.orderAutoDeclinedTitle" values={{ listingLink }} />
);
} else if (propTypes.txIsCanceled(transaction)) {
return <FormattedMessage id="OrderDetailsPanel.orderCanceledTitle" values={{ listingLink }} />;
@ -83,17 +83,17 @@ const orderMessage = (transaction, listingTitle, providerName) => {
values={{ providerName, transitionDate }}
/>
);
} else if (propTypes.txIsRejected(transaction)) {
} else if (propTypes.txIsDeclined(transaction)) {
return (
<FormattedMessage
id="OrderDetailsPanel.orderRejectedStatus"
id="OrderDetailsPanel.orderDeclinedStatus"
values={{ providerName, transitionDate }}
/>
);
} else if (propTypes.txIsAutorejected(transaction)) {
} else if (propTypes.txIsAutodeclined(transaction)) {
return (
<FormattedMessage
id="OrderDetailsPanel.orderAutoRejectedStatus"
id="OrderDetailsPanel.orderAutoDeclinedStatus"
values={{ providerName, transitionDate }}
/>
);

View file

@ -33,15 +33,15 @@ const txAccepted = createTransaction({
...baseTxAttrs,
});
const txRejected = createTransaction({
id: 'order-rejected',
lastTransition: propTypes.TX_TRANSITION_REJECT,
const txDeclined = createTransaction({
id: 'order-declined',
lastTransition: propTypes.TX_TRANSITION_DECLINE,
...baseTxAttrs,
});
const txAutoRejected = createTransaction({
id: 'order-autorejected',
lastTransition: propTypes.TX_TRANSITION_AUTO_REJECT,
const txAutoDeclined = createTransaction({
id: 'order-autodeclined',
lastTransition: propTypes.TX_TRANSITION_AUTO_DECLINE,
...baseTxAttrs,
});
@ -70,15 +70,15 @@ describe('OrderDetailsPanel', () => {
);
expect(tree).toMatchSnapshot();
});
it('rejected matches snapshot', () => {
it('declined matches snapshot', () => {
const tree = renderShallow(
<OrderDetailsPanelComponent transaction={txRejected} intl={fakeIntl} />
<OrderDetailsPanelComponent transaction={txDeclined} intl={fakeIntl} />
);
expect(tree).toMatchSnapshot();
});
it('autorejected matches snapshot', () => {
it('autodeclined matches snapshot', () => {
const tree = renderShallow(
<OrderDetailsPanelComponent transaction={txAutoRejected} intl={fakeIntl} />
<OrderDetailsPanelComponent transaction={txAutoDeclined} intl={fakeIntl} />
);
expect(tree).toMatchSnapshot();
});

View file

@ -418,7 +418,7 @@ exports[`OrderDetailsPanel accepted matches snapshot 1`] = `
</div>
`;
exports[`OrderDetailsPanel autorejected matches snapshot 1`] = `
exports[`OrderDetailsPanel autodeclined matches snapshot 1`] = `
<div
className=""
>
@ -471,7 +471,7 @@ exports[`OrderDetailsPanel autorejected matches snapshot 1`] = `
<div>
<h1>
<FormattedMessage
id="OrderDetailsPanel.orderAutoRejectedTitle"
id="OrderDetailsPanel.orderAutoDeclinedTitle"
values={
Object {
"listingLink": <NamedLink
@ -491,7 +491,7 @@ exports[`OrderDetailsPanel autorejected matches snapshot 1`] = `
</h1>
<div>
<FormattedMessage
id="OrderDetailsPanel.orderAutoRejectedStatus"
id="OrderDetailsPanel.orderAutoDeclinedStatus"
values={
Object {
"providerName": "provider display name",
@ -533,7 +533,7 @@ exports[`OrderDetailsPanel autorejected matches snapshot 1`] = `
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/auto-reject",
"lastTransition": "transition/auto-decline",
"lastTransitionedAt": 2017-06-01T00:00:00.000Z,
"lineItems": Array [
Object {
@ -593,7 +593,7 @@ exports[`OrderDetailsPanel autorejected matches snapshot 1`] = `
"type": "user",
},
"id": UUID {
"uuid": "order-autorejected",
"uuid": "order-autodeclined",
},
"listing": Object {
"attributes": Object {
@ -717,7 +717,7 @@ exports[`OrderDetailsPanel autorejected matches snapshot 1`] = `
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/auto-reject",
"lastTransition": "transition/auto-decline",
"lastTransitionedAt": 2017-06-01T00:00:00.000Z,
"lineItems": Array [
Object {
@ -777,7 +777,7 @@ exports[`OrderDetailsPanel autorejected matches snapshot 1`] = `
"type": "user",
},
"id": UUID {
"uuid": "order-autorejected",
"uuid": "order-autodeclined",
},
"listing": Object {
"attributes": Object {
@ -1234,6 +1234,412 @@ exports[`OrderDetailsPanel canceled matches snapshot 1`] = `
</div>
`;
exports[`OrderDetailsPanel declined matches snapshot 1`] = `
<div
className=""
>
<div>
<div>
<div>
<ResponsiveImage
alt="listing1 title"
className={null}
image={null}
nameSet={
Array [
Object {
"name": "landscape-crop",
"size": "400w",
},
Object {
"name": "landscape-crop2x",
"size": "800w",
},
]
}
noImageMessage={null}
rootClassName={null}
sizes="100vw"
/>
</div>
</div>
<div
className=""
>
<AvatarMedium
user={
Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "provider abbreviated name",
"displayName": "provider display name",
},
},
"id": UUID {
"uuid": "provider",
},
"type": "user",
}
}
/>
</div>
<div>
<h1>
<FormattedMessage
id="OrderDetailsPanel.orderDeclinedTitle"
values={
Object {
"listingLink": <NamedLink
name="ListingPage"
params={
Object {
"id": "listing1",
"slug": "listing1-title",
}
}
>
listing1 title
</NamedLink>,
}
}
/>
</h1>
<div>
<FormattedMessage
id="OrderDetailsPanel.orderDeclinedStatus"
values={
Object {
"providerName": "provider display name",
"transitionDate": <span>
<FormattedDate
day="numeric"
month="short"
value={2017-06-01T00:00:00.000Z}
year="numeric"
/>
</span>,
}
}
/>
</div>
</div>
<div>
<div>
<h3>
<FormattedMessage
id="OrderDetailsPanel.bookingBreakdownTitle"
values={Object {}}
/>
</h3>
<BookingBreakdown
booking={
Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
}
}
transaction={
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/decline",
"lastTransitionedAt": 2017-06-01T00:00:00.000Z,
"lineItems": Array [
Object {
"code": "line-item/night",
"lineTotal": Money {
"amount": 16500,
"currency": "USD",
},
"quantity": "3",
"unitPrice": Money {
"amount": 5500,
"currency": "USD",
},
},
Object {
"code": "line-item/provider-commission",
"lineTotal": Money {
"amount": -100,
"currency": "USD",
},
"unitPrice": Money {
"amount": -100,
"currency": "USD",
},
},
],
"payinTotal": Money {
"amount": 16500,
"currency": "USD",
},
"payoutTotal": Money {
"amount": 16400,
"currency": "USD",
},
},
"booking": Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
},
"customer": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer abbreviated name",
"displayName": "customer display name",
},
},
"id": UUID {
"uuid": "customer",
},
"type": "user",
},
"id": UUID {
"uuid": "order-declined",
},
"listing": Object {
"attributes": Object {
"address": "listing1 address",
"closed": false,
"deleted": false,
"description": "listing1 description",
"geolocation": LatLng {
"lat": 40,
"lng": 60,
},
"price": Money {
"amount": 5500,
"currency": "USD",
},
"title": "listing1 title",
},
"id": UUID {
"uuid": "listing1",
},
"type": "listing",
},
"provider": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "provider abbreviated name",
"displayName": "provider display name",
},
},
"id": UUID {
"uuid": "provider",
},
"type": "user",
},
"type": "transaction",
}
}
userRole="customer"
/>
</div>
<div>
<div>
<div>
<ResponsiveImage
alt="listing1 title"
className={null}
image={null}
nameSet={
Array [
Object {
"name": "landscape-crop",
"size": "400w",
},
Object {
"name": "landscape-crop2x",
"size": "800w",
},
]
}
noImageMessage={null}
rootClassName={null}
sizes="100%"
/>
</div>
</div>
<div>
<AvatarMedium
user={
Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "provider abbreviated name",
"displayName": "provider display name",
},
},
"id": UUID {
"uuid": "provider",
},
"type": "user",
}
}
/>
</div>
<div>
<h2>
listing1 title
</h2>
<p>
<FormattedMessage
id="OrderDetailsPanel.hostedBy"
values={
Object {
"name": "provider display name",
}
}
/>
</p>
</div>
<h3>
<FormattedMessage
id="OrderDetailsPanel.bookingBreakdownTitle"
values={Object {}}
/>
</h3>
<BookingBreakdown
booking={
Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
}
}
transaction={
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/decline",
"lastTransitionedAt": 2017-06-01T00:00:00.000Z,
"lineItems": Array [
Object {
"code": "line-item/night",
"lineTotal": Money {
"amount": 16500,
"currency": "USD",
},
"quantity": "3",
"unitPrice": Money {
"amount": 5500,
"currency": "USD",
},
},
Object {
"code": "line-item/provider-commission",
"lineTotal": Money {
"amount": -100,
"currency": "USD",
},
"unitPrice": Money {
"amount": -100,
"currency": "USD",
},
},
],
"payinTotal": Money {
"amount": 16500,
"currency": "USD",
},
"payoutTotal": Money {
"amount": 16400,
"currency": "USD",
},
},
"booking": Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
},
"customer": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer abbreviated name",
"displayName": "customer display name",
},
},
"id": UUID {
"uuid": "customer",
},
"type": "user",
},
"id": UUID {
"uuid": "order-declined",
},
"listing": Object {
"attributes": Object {
"address": "listing1 address",
"closed": false,
"deleted": false,
"description": "listing1 description",
"geolocation": LatLng {
"lat": 40,
"lng": 60,
},
"price": Money {
"amount": 5500,
"currency": "USD",
},
"title": "listing1 title",
},
"id": UUID {
"uuid": "listing1",
},
"type": "listing",
},
"provider": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "provider abbreviated name",
"displayName": "provider display name",
},
},
"id": UUID {
"uuid": "provider",
},
"type": "user",
},
"type": "transaction",
}
}
userRole="customer"
/>
</div>
</div>
</div>
</div>
`;
exports[`OrderDetailsPanel delivered matches snapshot 1`] = `
<div
className=""
@ -2049,409 +2455,3 @@ exports[`OrderDetailsPanel preauthorized matches snapshot 1`] = `
</div>
</div>
`;
exports[`OrderDetailsPanel rejected matches snapshot 1`] = `
<div
className=""
>
<div>
<div>
<div>
<ResponsiveImage
alt="listing1 title"
className={null}
image={null}
nameSet={
Array [
Object {
"name": "landscape-crop",
"size": "400w",
},
Object {
"name": "landscape-crop2x",
"size": "800w",
},
]
}
noImageMessage={null}
rootClassName={null}
sizes="100vw"
/>
</div>
</div>
<div
className=""
>
<AvatarMedium
user={
Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "provider abbreviated name",
"displayName": "provider display name",
},
},
"id": UUID {
"uuid": "provider",
},
"type": "user",
}
}
/>
</div>
<div>
<h1>
<FormattedMessage
id="OrderDetailsPanel.orderRejectedTitle"
values={
Object {
"listingLink": <NamedLink
name="ListingPage"
params={
Object {
"id": "listing1",
"slug": "listing1-title",
}
}
>
listing1 title
</NamedLink>,
}
}
/>
</h1>
<div>
<FormattedMessage
id="OrderDetailsPanel.orderRejectedStatus"
values={
Object {
"providerName": "provider display name",
"transitionDate": <span>
<FormattedDate
day="numeric"
month="short"
value={2017-06-01T00:00:00.000Z}
year="numeric"
/>
</span>,
}
}
/>
</div>
</div>
<div>
<div>
<h3>
<FormattedMessage
id="OrderDetailsPanel.bookingBreakdownTitle"
values={Object {}}
/>
</h3>
<BookingBreakdown
booking={
Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
}
}
transaction={
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/reject",
"lastTransitionedAt": 2017-06-01T00:00:00.000Z,
"lineItems": Array [
Object {
"code": "line-item/night",
"lineTotal": Money {
"amount": 16500,
"currency": "USD",
},
"quantity": "3",
"unitPrice": Money {
"amount": 5500,
"currency": "USD",
},
},
Object {
"code": "line-item/provider-commission",
"lineTotal": Money {
"amount": -100,
"currency": "USD",
},
"unitPrice": Money {
"amount": -100,
"currency": "USD",
},
},
],
"payinTotal": Money {
"amount": 16500,
"currency": "USD",
},
"payoutTotal": Money {
"amount": 16400,
"currency": "USD",
},
},
"booking": Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
},
"customer": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer abbreviated name",
"displayName": "customer display name",
},
},
"id": UUID {
"uuid": "customer",
},
"type": "user",
},
"id": UUID {
"uuid": "order-rejected",
},
"listing": Object {
"attributes": Object {
"address": "listing1 address",
"closed": false,
"deleted": false,
"description": "listing1 description",
"geolocation": LatLng {
"lat": 40,
"lng": 60,
},
"price": Money {
"amount": 5500,
"currency": "USD",
},
"title": "listing1 title",
},
"id": UUID {
"uuid": "listing1",
},
"type": "listing",
},
"provider": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "provider abbreviated name",
"displayName": "provider display name",
},
},
"id": UUID {
"uuid": "provider",
},
"type": "user",
},
"type": "transaction",
}
}
userRole="customer"
/>
</div>
<div>
<div>
<div>
<ResponsiveImage
alt="listing1 title"
className={null}
image={null}
nameSet={
Array [
Object {
"name": "landscape-crop",
"size": "400w",
},
Object {
"name": "landscape-crop2x",
"size": "800w",
},
]
}
noImageMessage={null}
rootClassName={null}
sizes="100%"
/>
</div>
</div>
<div>
<AvatarMedium
user={
Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "provider abbreviated name",
"displayName": "provider display name",
},
},
"id": UUID {
"uuid": "provider",
},
"type": "user",
}
}
/>
</div>
<div>
<h2>
listing1 title
</h2>
<p>
<FormattedMessage
id="OrderDetailsPanel.hostedBy"
values={
Object {
"name": "provider display name",
}
}
/>
</p>
</div>
<h3>
<FormattedMessage
id="OrderDetailsPanel.bookingBreakdownTitle"
values={Object {}}
/>
</h3>
<BookingBreakdown
booking={
Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
}
}
transaction={
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/reject",
"lastTransitionedAt": 2017-06-01T00:00:00.000Z,
"lineItems": Array [
Object {
"code": "line-item/night",
"lineTotal": Money {
"amount": 16500,
"currency": "USD",
},
"quantity": "3",
"unitPrice": Money {
"amount": 5500,
"currency": "USD",
},
},
Object {
"code": "line-item/provider-commission",
"lineTotal": Money {
"amount": -100,
"currency": "USD",
},
"unitPrice": Money {
"amount": -100,
"currency": "USD",
},
},
],
"payinTotal": Money {
"amount": 16500,
"currency": "USD",
},
"payoutTotal": Money {
"amount": 16400,
"currency": "USD",
},
},
"booking": Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
},
"customer": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer abbreviated name",
"displayName": "customer display name",
},
},
"id": UUID {
"uuid": "customer",
},
"type": "user",
},
"id": UUID {
"uuid": "order-rejected",
},
"listing": Object {
"attributes": Object {
"address": "listing1 address",
"closed": false,
"deleted": false,
"description": "listing1 description",
"geolocation": LatLng {
"lat": 40,
"lng": 60,
},
"price": Money {
"amount": 5500,
"currency": "USD",
},
"title": "listing1 title",
},
"id": UUID {
"uuid": "listing1",
},
"type": "listing",
},
"provider": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "provider abbreviated name",
"displayName": "provider display name",
},
},
"id": UUID {
"uuid": "provider",
},
"type": "user",
},
"type": "transaction",
}
}
userRole="customer"
/>
</div>
</div>
</div>
</div>
`;

View file

@ -210,7 +210,7 @@
}
}
.rejectButton {
.declineButton {
margin-right: 6.5px;
}

View file

@ -43,17 +43,17 @@ const saleTitle = (transaction, listingLink, customerName) => {
values={{ customerName, listingLink }}
/>
);
} else if (propTypes.txIsRejected(transaction)) {
} else if (propTypes.txIsDeclined(transaction)) {
return (
<FormattedMessage
id="SaleDetailsPanel.listingRejectedTitle"
id="SaleDetailsPanel.listingDeclinedTitle"
values={{ customerName, listingLink }}
/>
);
} else if (propTypes.txIsAutorejected(transaction)) {
} else if (propTypes.txIsAutodeclined(transaction)) {
return (
<FormattedMessage
id="SaleDetailsPanel.listingRejectedTitle"
id="SaleDetailsPanel.listingDeclinedTitle"
values={{ customerName, listingLink }}
/>
);
@ -92,11 +92,11 @@ const saleMessage = (transaction, customerName) => {
return <FormattedMessage id="SaleDetailsPanel.saleRequestedStatus" values={{ customerName }} />;
} else if (propTypes.txIsAccepted(transaction)) {
return <FormattedMessage id="SaleDetailsPanel.saleAcceptedStatus" values={{ formattedDate }} />;
} else if (propTypes.txIsRejected(transaction)) {
return <FormattedMessage id="SaleDetailsPanel.saleRejectedStatus" values={{ formattedDate }} />;
} else if (propTypes.txIsAutorejected(transaction)) {
} else if (propTypes.txIsDeclined(transaction)) {
return <FormattedMessage id="SaleDetailsPanel.saleDeclinedStatus" values={{ formattedDate }} />;
} else if (propTypes.txIsAutodeclined(transaction)) {
return (
<FormattedMessage id="SaleDetailsPanel.saleAutoRejectedStatus" values={{ formattedDate }} />
<FormattedMessage id="SaleDetailsPanel.saleAutoDeclinedStatus" values={{ formattedDate }} />
);
} else if (propTypes.txIsCanceled(transaction)) {
return <FormattedMessage id="SaleDetailsPanel.saleCanceledStatus" values={{ formattedDate }} />;
@ -115,11 +115,11 @@ export const SaleDetailsPanelComponent = props => {
className,
transaction,
onAcceptSale,
onRejectSale,
onDeclineSale,
acceptInProgress,
rejectInProgress,
declineInProgress,
acceptSaleError,
rejectSaleError,
declineSaleError,
intl,
} = props;
const currentTransaction = ensureTransaction(transaction);
@ -161,16 +161,16 @@ export const SaleDetailsPanelComponent = props => {
: null;
const canShowButtons = propTypes.txIsPreauthorized(currentTransaction) && !isCustomerBanned;
const buttonsDisabled = acceptInProgress || rejectInProgress;
const buttonsDisabled = acceptInProgress || declineInProgress;
const acceptErrorMessage = acceptSaleError
? <p className={css.error}>
<FormattedMessage id="SaleDetailsPanel.acceptSaleFailed" />
</p>
: null;
const rejectErrorMessage = rejectSaleError
const declineErrorMessage = declineSaleError
? <p className={css.error}>
<FormattedMessage id="SaleDetailsPanel.rejectSaleFailed" />
<FormattedMessage id="SaleDetailsPanel.declineSaleFailed" />
</p>
: null;
@ -178,15 +178,15 @@ export const SaleDetailsPanelComponent = props => {
? <div className={css.actionButtons}>
<div className={css.errorDesktop}>
{acceptErrorMessage}
{rejectErrorMessage}
{declineErrorMessage}
</div>
<SecondaryButton
className={css.rejectButton}
inProgress={rejectInProgress}
className={css.declineButton}
inProgress={declineInProgress}
disabled={buttonsDisabled}
onClick={() => onRejectSale(currentTransaction.id)}
onClick={() => onDeclineSale(currentTransaction.id)}
>
<FormattedMessage id="SalePage.rejectButton" />
<FormattedMessage id="SalePage.declineButton" />
</SecondaryButton>
<PrimaryButton
className={css.acceptButton}
@ -229,7 +229,7 @@ export const SaleDetailsPanelComponent = props => {
<p className={css.message}>{message}</p>
<div className={css.errorMobile}>
{acceptErrorMessage}
{rejectErrorMessage}
{declineErrorMessage}
</div>
{actionButtons}
</div>
@ -270,7 +270,7 @@ SaleDetailsPanelComponent.defaultProps = {
rootClassName: null,
className: null,
acceptSaleError: null,
rejectSaleError: null,
declineSaleError: null,
};
const { string, func, bool, instanceOf } = PropTypes;
@ -280,11 +280,11 @@ SaleDetailsPanelComponent.propTypes = {
className: string,
transaction: propTypes.transaction.isRequired,
onAcceptSale: func.isRequired,
onRejectSale: func.isRequired,
onDeclineSale: func.isRequired,
acceptInProgress: bool.isRequired,
rejectInProgress: bool.isRequired,
declineInProgress: bool.isRequired,
acceptSaleError: instanceOf(Error),
rejectSaleError: instanceOf(Error),
declineSaleError: instanceOf(Error),
// from injectIntl
intl: intlShape.isRequired,

View file

@ -35,15 +35,15 @@ const txAccepted = createTransaction({
...baseTxAttrs,
});
const txRejected = createTransaction({
id: 'sale-rejected',
lastTransition: propTypes.TX_TRANSITION_REJECT,
const txDeclined = createTransaction({
id: 'sale-declined',
lastTransition: propTypes.TX_TRANSITION_DECLINE,
...baseTxAttrs,
});
const txAutoRejected = createTransaction({
id: 'sale-autorejected',
lastTransition: propTypes.TX_TRANSITION_AUTO_REJECT,
const txAutoDeclined = createTransaction({
id: 'sale-autodeclined',
lastTransition: propTypes.TX_TRANSITION_AUTO_DECLINE,
...baseTxAttrs,
});
@ -64,9 +64,9 @@ describe('SaleDetailsPanel', () => {
const props = {
transaction: txPreauthorized,
onAcceptSale: noop,
onRejectSale: noop,
onDeclineSale: noop,
acceptInProgress: false,
rejectInProgress: false,
declineInProgress: false,
intl: fakeIntl,
};
const tree = renderShallow(<SaleDetailsPanelComponent {...props} />);
@ -76,33 +76,33 @@ describe('SaleDetailsPanel', () => {
const props = {
transaction: txAccepted,
onAcceptSale: noop,
onRejectSale: noop,
onDeclineSale: noop,
acceptInProgress: false,
rejectInProgress: false,
declineInProgress: false,
intl: fakeIntl,
};
const tree = renderShallow(<SaleDetailsPanelComponent {...props} />);
expect(tree).toMatchSnapshot();
});
it('rejected matches snapshot', () => {
it('declined matches snapshot', () => {
const props = {
transaction: txRejected,
transaction: txDeclined,
onAcceptSale: noop,
onRejectSale: noop,
onDeclineSale: noop,
acceptInProgress: false,
rejectInProgress: false,
declineInProgress: false,
intl: fakeIntl,
};
const tree = renderShallow(<SaleDetailsPanelComponent {...props} />);
expect(tree).toMatchSnapshot();
});
it('autorejected matches snapshot', () => {
it('autodeclined matches snapshot', () => {
const props = {
transaction: txAutoRejected,
transaction: txAutoDeclined,
onAcceptSale: noop,
onRejectSale: noop,
onDeclineSale: noop,
acceptInProgress: false,
rejectInProgress: false,
declineInProgress: false,
intl: fakeIntl,
};
const tree = renderShallow(<SaleDetailsPanelComponent {...props} />);
@ -112,9 +112,9 @@ describe('SaleDetailsPanel', () => {
const props = {
transaction: txCanceled,
onAcceptSale: noop,
onRejectSale: noop,
onDeclineSale: noop,
acceptInProgress: false,
rejectInProgress: false,
declineInProgress: false,
intl: fakeIntl,
};
const tree = renderShallow(<SaleDetailsPanelComponent {...props} />);
@ -124,9 +124,9 @@ describe('SaleDetailsPanel', () => {
const props = {
transaction: txDelivered,
onAcceptSale: noop,
onRejectSale: noop,
onDeclineSale: noop,
acceptInProgress: false,
rejectInProgress: false,
declineInProgress: false,
intl: fakeIntl,
};
const tree = renderShallow(<SaleDetailsPanelComponent {...props} />);
@ -149,9 +149,9 @@ describe('SaleDetailsPanel', () => {
const props = {
transaction,
onAcceptSale: noop,
onRejectSale: noop,
onDeclineSale: noop,
acceptInProgress: false,
rejectInProgress: false,
declineInProgress: false,
intl: fakeIntl,
};
const panel = shallow(<SaleDetailsPanelComponent {...props} />);

View file

@ -367,7 +367,7 @@ exports[`SaleDetailsPanel accepted matches snapshot 1`] = `
</div>
`;
exports[`SaleDetailsPanel autorejected matches snapshot 1`] = `
exports[`SaleDetailsPanel autodeclined matches snapshot 1`] = `
<div
className=""
>
@ -437,7 +437,7 @@ exports[`SaleDetailsPanel autorejected matches snapshot 1`] = `
</div>
<h1>
<FormattedMessage
id="SaleDetailsPanel.listingRejectedTitle"
id="SaleDetailsPanel.listingDeclinedTitle"
values={
Object {
"customerName": "customer1 display name",
@ -458,7 +458,7 @@ exports[`SaleDetailsPanel autorejected matches snapshot 1`] = `
</h1>
<p>
<FormattedMessage
id="SaleDetailsPanel.saleAutoRejectedStatus"
id="SaleDetailsPanel.saleAutoDeclinedStatus"
values={
Object {
"formattedDate": <span>
@ -500,7 +500,7 @@ exports[`SaleDetailsPanel autorejected matches snapshot 1`] = `
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/auto-reject",
"lastTransition": "transition/auto-decline",
"lastTransitionedAt": 2017-06-10T00:00:00.000Z,
"lineItems": Array [
Object {
@ -560,7 +560,7 @@ exports[`SaleDetailsPanel autorejected matches snapshot 1`] = `
"type": "user",
},
"id": UUID {
"uuid": "sale-autorejected",
"uuid": "sale-autodeclined",
},
"listing": Object {
"attributes": Object {
@ -639,7 +639,7 @@ exports[`SaleDetailsPanel autorejected matches snapshot 1`] = `
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/auto-reject",
"lastTransition": "transition/auto-decline",
"lastTransitionedAt": 2017-06-10T00:00:00.000Z,
"lineItems": Array [
Object {
@ -699,7 +699,7 @@ exports[`SaleDetailsPanel autorejected matches snapshot 1`] = `
"type": "user",
},
"id": UUID {
"uuid": "sale-autorejected",
"uuid": "sale-autodeclined",
},
"listing": Object {
"attributes": Object {
@ -842,7 +842,7 @@ exports[`SaleDetailsPanel canceled matches snapshot 1`] = `
onClick={[Function]}
>
<FormattedMessage
id="SalePage.rejectButton"
id="SalePage.declineButton"
values={Object {}}
/>
</SecondaryButton>
@ -1116,6 +1116,373 @@ exports[`SaleDetailsPanel canceled matches snapshot 1`] = `
</div>
`;
exports[`SaleDetailsPanel declined matches snapshot 1`] = `
<div
className=""
>
<div>
<div>
<div>
<ResponsiveImage
alt="listing1 title"
className={null}
image={null}
nameSet={
Array [
Object {
"name": "landscape-crop",
"size": "400w",
},
Object {
"name": "landscape-crop2x",
"size": "800w",
},
]
}
noImageMessage={null}
rootClassName={null}
sizes="100vw"
/>
</div>
</div>
<div>
<AvatarMedium
user={
Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer1 abbreviated name",
"displayName": "customer1 display name",
},
},
"id": UUID {
"uuid": "customer1",
},
"type": "user",
}
}
/>
</div>
<div>
<div>
<AvatarLarge
user={
Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer1 abbreviated name",
"displayName": "customer1 display name",
},
},
"id": UUID {
"uuid": "customer1",
},
"type": "user",
}
}
/>
</div>
<h1>
<FormattedMessage
id="SaleDetailsPanel.listingDeclinedTitle"
values={
Object {
"customerName": "customer1 display name",
"listingLink": <NamedLink
name="ListingPage"
params={
Object {
"id": "listing1",
"slug": "listing1-title",
}
}
>
listing1 title
</NamedLink>,
}
}
/>
</h1>
<p>
<FormattedMessage
id="SaleDetailsPanel.saleDeclinedStatus"
values={
Object {
"formattedDate": <span>
<FormattedDate
day="numeric"
month="short"
value={2017-06-10T00:00:00.000Z}
weekday="long"
year="numeric"
/>
</span>,
}
}
/>
</p>
<div />
</div>
<div>
<h3>
<FormattedMessage
id="SaleDetailsPanel.bookingBreakdownTitle"
values={Object {}}
/>
</h3>
<BookingBreakdown
booking={
Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
}
}
transaction={
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/decline",
"lastTransitionedAt": 2017-06-10T00:00:00.000Z,
"lineItems": Array [
Object {
"code": "line-item/night",
"lineTotal": Money {
"amount": 16500,
"currency": "USD",
},
"quantity": "3",
"unitPrice": Money {
"amount": 5500,
"currency": "USD",
},
},
Object {
"code": "line-item/provider-commission",
"lineTotal": Money {
"amount": -1000,
"currency": "USD",
},
"unitPrice": Money {
"amount": -1000,
"currency": "USD",
},
},
],
"payinTotal": Money {
"amount": 16500,
"currency": "USD",
},
"payoutTotal": Money {
"amount": 15500,
"currency": "USD",
},
},
"booking": Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
},
"customer": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer1 abbreviated name",
"displayName": "customer1 display name",
},
},
"id": UUID {
"uuid": "customer1",
},
"type": "user",
},
"id": UUID {
"uuid": "sale-declined",
},
"listing": Object {
"attributes": Object {
"address": "listing1 address",
"closed": false,
"deleted": false,
"description": "listing1 description",
"geolocation": LatLng {
"lat": 40,
"lng": 60,
},
"price": Money {
"amount": 5500,
"currency": "USD",
},
"title": "listing1 title",
},
"id": UUID {
"uuid": "listing1",
},
"type": "listing",
},
"provider": null,
"type": "transaction",
}
}
userRole="provider"
/>
</div>
<div>
<div>
<div>
<ResponsiveImage
alt="listing1 title"
className={null}
image={null}
nameSet={
Array [
Object {
"name": "landscape-crop",
"size": "400w",
},
Object {
"name": "landscape-crop2x",
"size": "800w",
},
]
}
noImageMessage={null}
rootClassName={null}
sizes="100%"
/>
</div>
</div>
<h3>
<FormattedMessage
id="SaleDetailsPanel.bookingBreakdownTitle"
values={Object {}}
/>
</h3>
<div>
<BookingBreakdown
booking={
Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
}
}
transaction={
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/decline",
"lastTransitionedAt": 2017-06-10T00:00:00.000Z,
"lineItems": Array [
Object {
"code": "line-item/night",
"lineTotal": Money {
"amount": 16500,
"currency": "USD",
},
"quantity": "3",
"unitPrice": Money {
"amount": 5500,
"currency": "USD",
},
},
Object {
"code": "line-item/provider-commission",
"lineTotal": Money {
"amount": -1000,
"currency": "USD",
},
"unitPrice": Money {
"amount": -1000,
"currency": "USD",
},
},
],
"payinTotal": Money {
"amount": 16500,
"currency": "USD",
},
"payoutTotal": Money {
"amount": 15500,
"currency": "USD",
},
},
"booking": Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
},
"customer": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer1 abbreviated name",
"displayName": "customer1 display name",
},
},
"id": UUID {
"uuid": "customer1",
},
"type": "user",
},
"id": UUID {
"uuid": "sale-declined",
},
"listing": Object {
"attributes": Object {
"address": "listing1 address",
"closed": false,
"deleted": false,
"description": "listing1 description",
"geolocation": LatLng {
"lat": 40,
"lng": 60,
},
"price": Money {
"amount": 5500,
"currency": "USD",
},
"title": "listing1 title",
},
"id": UUID {
"uuid": "listing1",
},
"type": "listing",
},
"provider": null,
"type": "transaction",
}
}
userRole="provider"
/>
</div>
</div>
</div>
</div>
`;
exports[`SaleDetailsPanel delivered matches snapshot 1`] = `
<div
className=""
@ -1591,7 +1958,7 @@ exports[`SaleDetailsPanel preauthorized matches snapshot 1`] = `
onClick={[Function]}
>
<FormattedMessage
id="SalePage.rejectButton"
id="SalePage.declineButton"
values={Object {}}
/>
</SecondaryButton>
@ -1864,370 +2231,3 @@ exports[`SaleDetailsPanel preauthorized matches snapshot 1`] = `
</div>
</div>
`;
exports[`SaleDetailsPanel rejected matches snapshot 1`] = `
<div
className=""
>
<div>
<div>
<div>
<ResponsiveImage
alt="listing1 title"
className={null}
image={null}
nameSet={
Array [
Object {
"name": "landscape-crop",
"size": "400w",
},
Object {
"name": "landscape-crop2x",
"size": "800w",
},
]
}
noImageMessage={null}
rootClassName={null}
sizes="100vw"
/>
</div>
</div>
<div>
<AvatarMedium
user={
Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer1 abbreviated name",
"displayName": "customer1 display name",
},
},
"id": UUID {
"uuid": "customer1",
},
"type": "user",
}
}
/>
</div>
<div>
<div>
<AvatarLarge
user={
Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer1 abbreviated name",
"displayName": "customer1 display name",
},
},
"id": UUID {
"uuid": "customer1",
},
"type": "user",
}
}
/>
</div>
<h1>
<FormattedMessage
id="SaleDetailsPanel.listingRejectedTitle"
values={
Object {
"customerName": "customer1 display name",
"listingLink": <NamedLink
name="ListingPage"
params={
Object {
"id": "listing1",
"slug": "listing1-title",
}
}
>
listing1 title
</NamedLink>,
}
}
/>
</h1>
<p>
<FormattedMessage
id="SaleDetailsPanel.saleRejectedStatus"
values={
Object {
"formattedDate": <span>
<FormattedDate
day="numeric"
month="short"
value={2017-06-10T00:00:00.000Z}
weekday="long"
year="numeric"
/>
</span>,
}
}
/>
</p>
<div />
</div>
<div>
<h3>
<FormattedMessage
id="SaleDetailsPanel.bookingBreakdownTitle"
values={Object {}}
/>
</h3>
<BookingBreakdown
booking={
Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
}
}
transaction={
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/reject",
"lastTransitionedAt": 2017-06-10T00:00:00.000Z,
"lineItems": Array [
Object {
"code": "line-item/night",
"lineTotal": Money {
"amount": 16500,
"currency": "USD",
},
"quantity": "3",
"unitPrice": Money {
"amount": 5500,
"currency": "USD",
},
},
Object {
"code": "line-item/provider-commission",
"lineTotal": Money {
"amount": -1000,
"currency": "USD",
},
"unitPrice": Money {
"amount": -1000,
"currency": "USD",
},
},
],
"payinTotal": Money {
"amount": 16500,
"currency": "USD",
},
"payoutTotal": Money {
"amount": 15500,
"currency": "USD",
},
},
"booking": Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
},
"customer": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer1 abbreviated name",
"displayName": "customer1 display name",
},
},
"id": UUID {
"uuid": "customer1",
},
"type": "user",
},
"id": UUID {
"uuid": "sale-rejected",
},
"listing": Object {
"attributes": Object {
"address": "listing1 address",
"closed": false,
"deleted": false,
"description": "listing1 description",
"geolocation": LatLng {
"lat": 40,
"lng": 60,
},
"price": Money {
"amount": 5500,
"currency": "USD",
},
"title": "listing1 title",
},
"id": UUID {
"uuid": "listing1",
},
"type": "listing",
},
"provider": null,
"type": "transaction",
}
}
userRole="provider"
/>
</div>
<div>
<div>
<div>
<ResponsiveImage
alt="listing1 title"
className={null}
image={null}
nameSet={
Array [
Object {
"name": "landscape-crop",
"size": "400w",
},
Object {
"name": "landscape-crop2x",
"size": "800w",
},
]
}
noImageMessage={null}
rootClassName={null}
sizes="100%"
/>
</div>
</div>
<h3>
<FormattedMessage
id="SaleDetailsPanel.bookingBreakdownTitle"
values={Object {}}
/>
</h3>
<div>
<BookingBreakdown
booking={
Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
}
}
transaction={
Object {
"attributes": Object {
"createdAt": 2017-05-01T00:00:00.000Z,
"lastTransition": "transition/reject",
"lastTransitionedAt": 2017-06-10T00:00:00.000Z,
"lineItems": Array [
Object {
"code": "line-item/night",
"lineTotal": Money {
"amount": 16500,
"currency": "USD",
},
"quantity": "3",
"unitPrice": Money {
"amount": 5500,
"currency": "USD",
},
},
Object {
"code": "line-item/provider-commission",
"lineTotal": Money {
"amount": -1000,
"currency": "USD",
},
"unitPrice": Money {
"amount": -1000,
"currency": "USD",
},
},
],
"payinTotal": Money {
"amount": 16500,
"currency": "USD",
},
"payoutTotal": Money {
"amount": 15500,
"currency": "USD",
},
},
"booking": Object {
"attributes": Object {
"end": 2017-06-13T00:00:00.000Z,
"start": 2017-06-10T00:00:00.000Z,
},
"id": UUID {
"uuid": "booking1",
},
"type": "booking",
},
"customer": Object {
"attributes": Object {
"banned": false,
"profile": Object {
"abbreviatedName": "customer1 abbreviated name",
"displayName": "customer1 display name",
},
},
"id": UUID {
"uuid": "customer1",
},
"type": "user",
},
"id": UUID {
"uuid": "sale-rejected",
},
"listing": Object {
"attributes": Object {
"address": "listing1 address",
"closed": false,
"deleted": false,
"description": "listing1 description",
"geolocation": LatLng {
"lat": 40,
"lng": 60,
},
"price": Money {
"amount": 5500,
"currency": "USD",
},
"title": "listing1 title",
},
"id": UUID {
"uuid": "listing1",
},
"type": "listing",
},
"provider": null,
"type": "transaction",
}
}
userRole="provider"
/>
</div>
</div>
</div>
</div>
`;

View file

@ -401,7 +401,7 @@
.lastTransitionedAtCanceled,
.lastTransitionedAtAccepted,
.lastTransitionedAtRejected,
.lastTransitionedAtDeclined,
.lastTransitionedAtDelivered {
color: var(--matterColorAnti);
}

View file

@ -46,11 +46,11 @@ const txState = (intl, tx, isOrder) => {
id: 'InboxPage.stateAccepted',
}),
};
} else if (propTypes.txIsRejectedOrAutorejected(tx)) {
} else if (propTypes.txIsDeclinedOrAutodeclined(tx)) {
return {
nameClassName: css.nameDeclined,
bookingClassName: css.bookingDeclined,
lastTransitionedAtClassName: css.lastTransitionedAtRejected,
lastTransitionedAtClassName: css.lastTransitionedAtDeclined,
stateClassName: css.stateDeclined,
state: intl.formatMessage({
id: 'InboxPage.stateDeclined',

View file

@ -14,9 +14,9 @@ export const ACCEPT_SALE_REQUEST = 'app/SalePage/ACCEPT_SALE_REQUEST';
export const ACCEPT_SALE_SUCCESS = 'app/SalePage/ACCEPT_SALE_SUCCESS';
export const ACCEPT_SALE_ERROR = 'app/SalePage/ACCEPT_SALE_ERROR';
export const REJECT_SALE_REQUEST = 'app/SalePage/REJECT_SALE_REQUEST';
export const REJECT_SALE_SUCCESS = 'app/SalePage/REJECT_SALE_SUCCESS';
export const REJECT_SALE_ERROR = 'app/SalePage/REJECT_SALE_ERROR';
export const DECLINE_SALE_REQUEST = 'app/SalePage/DECLINE_SALE_REQUEST';
export const DECLINE_SALE_SUCCESS = 'app/SalePage/DECLINE_SALE_SUCCESS';
export const DECLINE_SALE_ERROR = 'app/SalePage/DECLINE_SALE_ERROR';
// ================ Reducer ================ //
@ -25,9 +25,9 @@ const initialState = {
fetchSaleError: null,
transactionRef: null,
acceptInProgress: false,
rejectInProgress: false,
declineInProgress: false,
acceptSaleError: null,
rejectSaleError: null,
declineSaleError: null,
};
export default function checkoutPageReducer(state = initialState, action = {}) {
@ -44,18 +44,18 @@ export default function checkoutPageReducer(state = initialState, action = {}) {
return { ...state, fetchInProgress: false, fetchSaleError: payload };
case ACCEPT_SALE_REQUEST:
return { ...state, acceptInProgress: true, acceptSaleError: null, rejectSaleError: null };
return { ...state, acceptInProgress: true, acceptSaleError: null, declineSaleError: null };
case ACCEPT_SALE_SUCCESS:
return { ...state, acceptInProgress: false };
case ACCEPT_SALE_ERROR:
return { ...state, acceptInProgress: false, acceptSaleError: payload };
case REJECT_SALE_REQUEST:
return { ...state, rejectInProgress: true, rejectSaleError: null, acceptSaleError: null };
case REJECT_SALE_SUCCESS:
return { ...state, rejectInProgress: false };
case REJECT_SALE_ERROR:
return { ...state, rejectInProgress: false, rejectSaleError: payload };
case DECLINE_SALE_REQUEST:
return { ...state, declineInProgress: true, declineSaleError: null, acceptSaleError: null };
case DECLINE_SALE_SUCCESS:
return { ...state, declineInProgress: false };
case DECLINE_SALE_ERROR:
return { ...state, declineInProgress: false, declineSaleError: payload };
default:
return state;
@ -64,8 +64,8 @@ export default function checkoutPageReducer(state = initialState, action = {}) {
// ================ Selectors ================ //
export const acceptOrRejectInProgress = state => {
return state.SalePage.acceptInProgress || state.SalePage.rejectInProgress;
export const acceptOrDeclineInProgress = state => {
return state.SalePage.acceptInProgress || state.SalePage.declineInProgress;
};
// ================ Action creators ================ //
@ -78,9 +78,9 @@ const acceptSaleRequest = () => ({ type: ACCEPT_SALE_REQUEST });
const acceptSaleSuccess = () => ({ type: ACCEPT_SALE_SUCCESS });
const acceptSaleError = e => ({ type: ACCEPT_SALE_ERROR, error: true, payload: e });
const rejectSaleRequest = () => ({ type: REJECT_SALE_REQUEST });
const rejectSaleSuccess = () => ({ type: REJECT_SALE_SUCCESS });
const rejectSaleError = e => ({ type: REJECT_SALE_ERROR, error: true, payload: e });
const declineSaleRequest = () => ({ type: DECLINE_SALE_REQUEST });
const declineSaleSuccess = () => ({ type: DECLINE_SALE_SUCCESS });
const declineSaleError = e => ({ type: DECLINE_SALE_ERROR, error: true, payload: e });
// ================ Thunks ================ //
@ -130,8 +130,8 @@ export const fetchSale = id =>
export const acceptSale = id =>
(dispatch, getState, sdk) => {
if (acceptOrRejectInProgress(getState())) {
return Promise.reject(new Error('Accept or reject already in progress'));
if (acceptOrDeclineInProgress(getState())) {
return Promise.reject(new Error('Accept or decline already in progress'));
}
dispatch(acceptSaleRequest());
@ -153,26 +153,26 @@ export const acceptSale = id =>
});
};
export const rejectSale = id =>
export const declineSale = id =>
(dispatch, getState, sdk) => {
if (acceptOrRejectInProgress(getState())) {
return Promise.reject(new Error('Accept or reject already in progress'));
if (acceptOrDeclineInProgress(getState())) {
return Promise.reject(new Error('Accept or decline already in progress'));
}
dispatch(rejectSaleRequest());
dispatch(declineSaleRequest());
return sdk.transactions
.transition({ id, transition: propTypes.TX_TRANSITION_REJECT, params: {} }, { expand: true })
.transition({ id, transition: propTypes.TX_TRANSITION_DECLINE, params: {} }, { expand: true })
.then(response => {
dispatch(addMarketplaceEntities(response));
dispatch(rejectSaleSuccess());
dispatch(declineSaleSuccess());
dispatch(fetchCurrentUserNotifications());
return response;
})
.catch(e => {
dispatch(rejectSaleError(e));
dispatch(declineSaleError(e));
log.error(e, 'redect-sale-failed', {
txId: id,
transition: propTypes.TX_TRANSITION_REJECT,
transition: propTypes.TX_TRANSITION_DECLINE,
});
throw e;
});

View file

@ -7,7 +7,7 @@ import * as propTypes from '../../util/propTypes';
import { ensureListing, ensureTransaction } from '../../util/data';
import { getMarketplaceEntities } from '../../ducks/marketplaceData.duck';
import { isScrollingDisabled } from '../../ducks/UI.duck';
import { acceptSale, rejectSale, loadData } from './SalePage.duck';
import { acceptSale, declineSale, loadData } from './SalePage.duck';
import { NamedRedirect, SaleDetailsPanel, Page } from '../../components';
import { TopbarContainer } from '../../containers';
@ -21,13 +21,13 @@ export const SalePageComponent = props => {
currentUser,
fetchSaleError,
acceptSaleError,
rejectSaleError,
declineSaleError,
acceptInProgress,
rejectInProgress,
declineInProgress,
intl,
logoutError,
onAcceptSale,
onRejectSale,
onDeclineSale,
params,
scrollingDisabled,
transaction,
@ -61,11 +61,11 @@ export const SalePageComponent = props => {
className={detailsClassName}
transaction={currentTransaction}
onAcceptSale={onAcceptSale}
onRejectSale={onRejectSale}
onDeclineSale={onDeclineSale}
acceptInProgress={acceptInProgress}
rejectInProgress={rejectInProgress}
declineInProgress={declineInProgress}
acceptSaleError={acceptSaleError}
rejectSaleError={rejectSaleError}
declineSaleError={declineSaleError}
/>
: loadingOrFailedFetching;
@ -89,7 +89,7 @@ SalePageComponent.defaultProps = {
currentUser: null,
fetchSaleError: null,
acceptSaleError: null,
rejectSaleError: null,
declineSaleError: null,
logoutError: null,
transaction: null,
};
@ -101,13 +101,13 @@ SalePageComponent.propTypes = {
currentUser: propTypes.currentUser,
fetchSaleError: instanceOf(Error),
acceptSaleError: instanceOf(Error),
rejectSaleError: instanceOf(Error),
declineSaleError: instanceOf(Error),
acceptInProgress: bool.isRequired,
rejectInProgress: bool.isRequired,
declineInProgress: bool.isRequired,
intl: intlShape.isRequired,
logoutError: instanceOf(Error),
onAcceptSale: func.isRequired,
onRejectSale: func.isRequired,
onDeclineSale: func.isRequired,
params: shape({ id: string }).isRequired,
scrollingDisabled: bool.isRequired,
tab: oneOf(['details', 'discussion']).isRequired,
@ -118,9 +118,9 @@ const mapStateToProps = state => {
const {
fetchSaleError,
acceptSaleError,
rejectSaleError,
declineSaleError,
acceptInProgress,
rejectInProgress,
declineInProgress,
transactionRef,
} = state.SalePage;
const { authInfoError, logoutError } = state.Auth;
@ -134,9 +134,9 @@ const mapStateToProps = state => {
currentUser,
fetchSaleError,
acceptSaleError,
rejectSaleError,
declineSaleError,
acceptInProgress,
rejectInProgress,
declineInProgress,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
transaction,
@ -146,7 +146,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => {
return {
onAcceptSale: transactionId => dispatch(acceptSale(transactionId)),
onRejectSale: transactionId => dispatch(rejectSale(transactionId)),
onDeclineSale: transactionId => dispatch(declineSale(transactionId)),
};
};

View file

@ -36,13 +36,13 @@ describe('SalePage', () => {
},
authInProgress: false,
acceptInProgress: false,
rejectInProgress: false,
declineInProgress: false,
currentUserHasListings: false,
isAuthenticated: false,
onLogout: noop,
onManageDisableScrolling: noop,
onAcceptSale: noop,
onRejectSale: noop,
onDeclineSale: noop,
params: { id: txId },
scrollingDisabled: false,
transaction,

View file

@ -13,10 +13,10 @@ exports[`SalePage matches snapshot 1`] = `
acceptInProgress={false}
acceptSaleError={null}
className="undefined"
declineInProgress={false}
declineSaleError={null}
onAcceptSale={[Function]}
onRejectSale={[Function]}
rejectInProgress={false}
rejectSaleError={null}
onDeclineSale={[Function]}
transaction={
Object {
"attributes": Object {

View file

@ -25,7 +25,7 @@
"BookingBreakdown.providerTotalCanceled": "Total price",
"BookingBreakdown.providerTotalDefault": "You'll make",
"BookingBreakdown.providerTotalDelivered": "You made",
"BookingBreakdown.providerTotalRejected": "You would have made",
"BookingBreakdown.providerTotalDeclined": "You would have made",
"BookingBreakdown.subTotal": "Subtotal",
"BookingBreakdown.refund": "Refund",
"BookingBreakdown.total": "Total price",
@ -238,8 +238,8 @@
"OrderDetailsPanel.orderAcceptedStatus": "{providerName} accepted the request on {transitionDate}.",
"OrderDetailsPanel.orderAcceptedSubtitle": "You have booked {listingLink}",
"OrderDetailsPanel.orderAcceptedTitle": "Woohoo {customerName}!",
"OrderDetailsPanel.orderAutoRejectedStatus": "The request expired on {transitionDate}. {providerName} never replied to the request.",
"OrderDetailsPanel.orderAutoRejectedTitle": "You requested to book {listingLink}",
"OrderDetailsPanel.orderAutoDeclinedStatus": "The request expired on {transitionDate}. {providerName} never replied to the request.",
"OrderDetailsPanel.orderAutoDeclinedTitle": "You requested to book {listingLink}",
"OrderDetailsPanel.orderCanceledStatus": "The request was cancelled on {transitionDate}",
"OrderDetailsPanel.orderCanceledTitle": "You booked {listingLink}",
"OrderDetailsPanel.orderDeliveredStatus": " ",
@ -247,8 +247,8 @@
"OrderDetailsPanel.orderPreauthorizedStatus": "{providerName} has been notified about the booking request, so sit back and relax.",
"OrderDetailsPanel.orderPreauthorizedSubtitle": "You have requested to book {listingLink}",
"OrderDetailsPanel.orderPreauthorizedTitle": "Great success, {customerName}!",
"OrderDetailsPanel.orderRejectedStatus": "Unfortunately {providerName} declined the request on {transitionDate}.",
"OrderDetailsPanel.orderRejectedTitle": "You requested to book {listingLink}",
"OrderDetailsPanel.orderDeclinedStatus": "Unfortunately {providerName} declined the request on {transitionDate}.",
"OrderDetailsPanel.orderDeclinedTitle": "You requested to book {listingLink}",
"OrderPage.fetchOrderFailed": "Fetching order data failed.",
"OrderPage.loadingData": "Loading order data.",
"OrderPage.title": "Order details: {listingTitle}",
@ -388,20 +388,20 @@
"SaleDetailsPanel.listingAcceptedTitle": "Woohoo! You accepted a request from {customerName} for {listingLink}",
"SaleDetailsPanel.listingCanceledTitle": "{customerName} booked {listingLink}",
"SaleDetailsPanel.listingDeliveredTitle": "{customerName} booked {listingLink}",
"SaleDetailsPanel.listingRejectedTitle": "{customerName} requested to book {listingLink}",
"SaleDetailsPanel.listingDeclinedTitle": "{customerName} requested to book {listingLink}",
"SaleDetailsPanel.listingRequestedTitle": "{customerName} has requested to book {listingLink}",
"SaleDetailsPanel.rejectSaleFailed": "Oops, rejecting failed. Please try again.",
"SaleDetailsPanel.declineSaleFailed": "Oops, declining failed. Please try again.",
"SaleDetailsPanel.saleAcceptedStatus": "You accepted the request on {formattedDate}.",
"SaleDetailsPanel.saleAutoRejectedStatus": "You did not react to the request on time. The request expired on {formattedDate}.",
"SaleDetailsPanel.saleAutoDeclinedStatus": "You did not react to the request on time. The request expired on {formattedDate}.",
"SaleDetailsPanel.saleCanceledStatus": "The request was cancelled on {formattedDate}.",
"SaleDetailsPanel.saleDeliveredStatus": "You delivered the order on {formattedDate}.",
"SaleDetailsPanel.saleRejectedStatus": "You declined the request on {formattedDate}.",
"SaleDetailsPanel.saleDeclinedStatus": "You declined the request on {formattedDate}.",
"SaleDetailsPanel.saleRequestedStatus": "{customerName} is waiting for your response.",
"SalePage.acceptButton": "Accept",
"SalePage.fetchSaleFailed": "Fetching sale data failed.",
"SalePage.loadingData": "Loading sale data.",
"SalePage.rejectButton": "Decline",
"SalePage.rejectSaleFailed": "Rejecting sale failed.",
"SalePage.declineButton": "Decline",
"SalePage.declineSaleFailed": "Declining sale failed.",
"SalePage.title": "Sale details: {title}",
"SearchMapInfoCard.noImage": "No image",
"SearchPage.foundResults": "{count, number} {count, plural, one {sauna} other {saunas}} found",

View file

@ -143,14 +143,14 @@ export const booking = shape({
// provider sees the transaction in the SalePage.
export const TX_TRANSITION_PREAUTHORIZE = 'transition/preauthorize';
// When the provider accepts or rejects a transaction from the
// SalePage, it is transitioned with the accept or reject transition.
// When the provider accepts or declines a transaction from the
// SalePage, it is transitioned with the accept or decline transition.
export const TX_TRANSITION_ACCEPT = 'transition/accept';
export const TX_TRANSITION_REJECT = 'transition/reject';
export const TX_TRANSITION_DECLINE = 'transition/decline';
// If the backend automatically rejects the transaction, it is
// transitioned with the auto-reject transition.
export const TX_TRANSITION_AUTO_REJECT = 'transition/auto-reject';
// If the backend automatically declines the transaction, it is
// transitioned with the auto-decline transition.
export const TX_TRANSITION_AUTO_DECLINE = 'transition/auto-decline';
// Admin can also cancel the transition.
export const TX_TRANSITION_CANCEL = 'transition/cancel';
@ -162,8 +162,8 @@ export const TX_TRANSITION_MARK_DELIVERED = 'transition/mark-delivered';
export const TX_TRANSITIONS = [
TX_TRANSITION_PREAUTHORIZE,
TX_TRANSITION_ACCEPT,
TX_TRANSITION_REJECT,
TX_TRANSITION_AUTO_REJECT,
TX_TRANSITION_DECLINE,
TX_TRANSITION_AUTO_DECLINE,
TX_TRANSITION_CANCEL,
TX_TRANSITION_MARK_DELIVERED,
];
@ -174,11 +174,11 @@ export const txIsPreauthorized = tx => txLastTransition(tx) === TX_TRANSITION_PR
export const txIsAccepted = tx => txLastTransition(tx) === TX_TRANSITION_ACCEPT;
export const txIsRejected = tx => txLastTransition(tx) === TX_TRANSITION_REJECT;
export const txIsDeclined = tx => txLastTransition(tx) === TX_TRANSITION_DECLINE;
export const txIsAutorejected = tx => txLastTransition(tx) === TX_TRANSITION_AUTO_REJECT;
export const txIsAutodeclined = tx => txLastTransition(tx) === TX_TRANSITION_AUTO_DECLINE;
export const txIsRejectedOrAutorejected = tx => txIsRejected(tx) || txIsAutorejected(tx);
export const txIsDeclinedOrAutodeclined = tx => txIsDeclined(tx) || txIsAutodeclined(tx);
export const txIsCanceled = tx => txLastTransition(tx) === TX_TRANSITION_CANCEL;

View file

@ -33,7 +33,7 @@ export const pathByRouteName = (nameToFind, routes, params = {}) =>
* exact flag set to false. If not, an array containing just the first matched exact route is returned.
*/
export const matchPathname = (pathname, routeConfiguration) => {
const matchedRoutes = routeConfiguration.reduce(
const matchedRoutes = routeConfiguration.reduce(
(matches, route) => {
const { path, exact = true } = route;
const match = matchPath(pathname, { path, exact });