mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 03:43:28 +10:00
Merge pull request #597 from sharetribe/add-enquiry-prop-types
Handle enquiry transactions
This commit is contained in:
commit
cee3abce4f
7 changed files with 39 additions and 22 deletions
|
|
@ -72,6 +72,7 @@ Review.propTypes = {
|
|||
const shouldRenderTransition = transition => {
|
||||
return [
|
||||
propTypes.TX_TRANSITION_PREAUTHORIZE,
|
||||
propTypes.TX_TRANSITION_PREAUTHORIZE_ENQUIRY,
|
||||
propTypes.TX_TRANSITION_ACCEPT,
|
||||
propTypes.TX_TRANSITION_DECLINE,
|
||||
propTypes.TX_TRANSITION_AUTO_DECLINE,
|
||||
|
|
@ -121,6 +122,7 @@ const resolveTransitionMessage = (
|
|||
|
||||
switch (currentTransition) {
|
||||
case propTypes.TX_TRANSITION_PREAUTHORIZE:
|
||||
case propTypes.TX_TRANSITION_PREAUTHORIZE_ENQUIRY:
|
||||
return isOwnTransition ? (
|
||||
<FormattedMessage id="ActivityFeed.ownTransitionRequest" values={{ listingTitle }} />
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -121,10 +121,12 @@ export const InboxItem = props => {
|
|||
const isSaleNotification = !isOrder && propTypes.txIsPreauthorized(tx);
|
||||
const rowNotificationDot = isSaleNotification ? <div className={css.notificationDot} /> : null;
|
||||
const lastTransitionedAt = formatDate(intl, tx.attributes.lastTransitionedAt);
|
||||
const bookingStart = formatDate(intl, booking.attributes.start);
|
||||
const bookingEnd = formatDate(intl, booking.attributes.end);
|
||||
|
||||
const bookingPrice = isOrder ? tx.attributes.payinTotal : tx.attributes.payoutTotal;
|
||||
const price = formatMoney(intl, bookingPrice);
|
||||
const hasBookingInfo = !!(booking && bookingPrice);
|
||||
const bookingStart = hasBookingInfo ? formatDate(intl, booking.attributes.start) : null;
|
||||
const bookingEnd = hasBookingInfo ? formatDate(intl, booking.attributes.end) : null;
|
||||
const price = hasBookingInfo ? formatMoney(intl, bookingPrice) : null;
|
||||
|
||||
const linkClasses = classNames(css.itemLink, {
|
||||
[css.bannedUserLink]: isOtherUserBanned,
|
||||
|
|
@ -146,8 +148,8 @@ export const InboxItem = props => {
|
|||
{otherUserDisplayName}
|
||||
</div>
|
||||
<div className={classNames(css.bookingInfo, stateData.bookingClassName)}>
|
||||
{bookingStart.short} - {bookingEnd.short}
|
||||
<span className={css.itemPrice}>{price}</span>
|
||||
{hasBookingInfo ? `${bookingStart.short} - ${bookingEnd.short}` : null}
|
||||
{hasBookingInfo ? <span className={css.itemPrice}>{price}</span> : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className={css.itemState}>
|
||||
|
|
|
|||
|
|
@ -359,9 +359,7 @@ exports[`InboxPage matches snapshot 2`] = `
|
|||
<div
|
||||
className=""
|
||||
>
|
||||
2017-02-15
|
||||
-
|
||||
2017-02-16
|
||||
2017-02-15 - 2017-02-16
|
||||
<span
|
||||
className={undefined}
|
||||
>
|
||||
|
|
@ -751,9 +749,7 @@ exports[`InboxPage matches snapshot 4`] = `
|
|||
<div
|
||||
className=""
|
||||
>
|
||||
2017-02-15
|
||||
-
|
||||
2017-02-16
|
||||
2017-02-15 - 2017-02-16
|
||||
<span
|
||||
className={undefined}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -276,8 +276,9 @@ export class ListingPageComponent extends Component {
|
|||
const isOwnListing =
|
||||
userAndListingAuthorAvailable && currentListing.author.id.uuid === currentUser.id.uuid;
|
||||
|
||||
const currentAuthor = ensureUser(authorAvailable ? currentListing.author : {});
|
||||
const currentAuthorDisplayName = currentAuthor.attributes.profile.displayName;
|
||||
const currentAuthor = authorAvailable ? currentListing.author : null;
|
||||
const ensuredAuthor = ensureUser(currentAuthor);
|
||||
const authorDisplayName = ensuredAuthor.attributes.profile.displayName;
|
||||
|
||||
// TODO location address is currently serialized inside address field (API will change later)
|
||||
// Content is something like { locationAddress: 'Street, Province, Country', building: 'A 42' };
|
||||
|
|
@ -374,7 +375,7 @@ export class ListingPageComponent extends Component {
|
|||
params={params}
|
||||
to={{ hash: '#host' }}
|
||||
>
|
||||
{currentAuthorDisplayName}
|
||||
{authorDisplayName}
|
||||
</NamedLink>
|
||||
);
|
||||
|
||||
|
|
@ -393,7 +394,7 @@ export class ListingPageComponent extends Component {
|
|||
<Page
|
||||
title={schemaTitle}
|
||||
scrollingDisabled={scrollingDisabled}
|
||||
author={currentAuthorDisplayName}
|
||||
author={authorDisplayName}
|
||||
contentType="website"
|
||||
description={description}
|
||||
facebookImages={facebookImages}
|
||||
|
|
@ -527,7 +528,7 @@ export class ListingPageComponent extends Component {
|
|||
<span className={css.authorName}>
|
||||
<FormattedMessage
|
||||
id="ListingPage.hostedBy"
|
||||
values={{ name: currentAuthorDisplayName }}
|
||||
values={{ name: authorDisplayName }}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { updatedEntities, denormalisedEntities } from '../util/data';
|
||||
import { storableError } from '../util/errors';
|
||||
import { TX_TRANSITION_PREAUTHORIZE } from '../util/propTypes';
|
||||
import { TX_TRANSITION_PREAUTHORIZE, TX_TRANSITION_PREAUTHORIZE_ENQUIRY } from '../util/propTypes';
|
||||
import * as log from '../util/log';
|
||||
import { authInfo } from './Auth.duck';
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ export const fetchCurrentUserNotifications = () => (dispatch, getState, sdk) =>
|
|||
|
||||
const apiQueryParams = {
|
||||
only: 'sale',
|
||||
last_transitions: [TX_TRANSITION_PREAUTHORIZE],
|
||||
last_transitions: [TX_TRANSITION_PREAUTHORIZE, TX_TRANSITION_PREAUTHORIZE_ENQUIRY],
|
||||
page: 1,
|
||||
per_page: NOTIFICATION_PAGE_SIZE,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ export const denormalisedEntities = (entities, type, ids) => {
|
|||
*
|
||||
* @param {Object} transaction entity object, which is to be ensured agains null values
|
||||
*/
|
||||
export const ensureTransaction = (transaction, booking = {}, listing = {}, provider = {}) => {
|
||||
export const ensureTransaction = (transaction, booking = null, listing = null, provider = null) => {
|
||||
const empty = {
|
||||
id: null,
|
||||
type: 'transaction',
|
||||
|
|
|
|||
|
|
@ -147,6 +147,11 @@ export const booking = shape({
|
|||
// provider sees the transaction in the SalePage.
|
||||
export const TX_TRANSITION_PREAUTHORIZE = 'transition/preauthorize';
|
||||
|
||||
// A customer can also initiate a transaction with an enquiry, and
|
||||
// then transition that by preauthorization.
|
||||
export const TX_TRANSITION_ENQUIRE = 'transition/enquire';
|
||||
export const TX_TRANSITION_PREAUTHORIZE_ENQUIRY = 'transition/preauthorize-enquiry';
|
||||
|
||||
// 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';
|
||||
|
|
@ -176,6 +181,8 @@ export const TX_TRANSITION_AUTO_COMPLETE_WITHOUT_REVIEWS =
|
|||
'transition/auto-complete-without-reviews';
|
||||
|
||||
export const TX_TRANSITIONS = [
|
||||
TX_TRANSITION_ENQUIRE,
|
||||
TX_TRANSITION_PREAUTHORIZE_ENQUIRY,
|
||||
TX_TRANSITION_PREAUTHORIZE,
|
||||
TX_TRANSITION_ACCEPT,
|
||||
TX_TRANSITION_DECLINE,
|
||||
|
|
@ -206,7 +213,12 @@ export const TX_TRANSITION_ACTORS = [
|
|||
|
||||
const txLastTransition = tx => ensureTransaction(tx).attributes.lastTransition;
|
||||
|
||||
export const txIsPreauthorized = tx => txLastTransition(tx) === TX_TRANSITION_PREAUTHORIZE;
|
||||
export const txIsPreauthorized = tx => {
|
||||
const transition = txLastTransition(tx);
|
||||
return (
|
||||
transition === TX_TRANSITION_PREAUTHORIZE || transition === TX_TRANSITION_PREAUTHORIZE_ENQUIRY
|
||||
);
|
||||
};
|
||||
|
||||
export const txIsAccepted = tx => txLastTransition(tx) === TX_TRANSITION_ACCEPT;
|
||||
|
||||
|
|
@ -272,8 +284,12 @@ export const transaction = shape({
|
|||
createdAt: instanceOf(Date).isRequired,
|
||||
lastTransitionedAt: instanceOf(Date).isRequired,
|
||||
lastTransition: oneOf(TX_TRANSITIONS).isRequired,
|
||||
payinTotal: money.isRequired,
|
||||
payoutTotal: money.isRequired,
|
||||
|
||||
// An enquiry won't need a total sum nor a booking so these are
|
||||
// optional.
|
||||
payinTotal: money,
|
||||
payoutTotal: money,
|
||||
|
||||
lineItems: arrayOf(
|
||||
shape({
|
||||
code: string.isRequired,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue