mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 03:43:28 +10:00
Pass in messaging props to SalePage
This commit is contained in:
parent
16628d6159
commit
ed488f2aee
3 changed files with 55 additions and 18 deletions
|
|
@ -4,11 +4,12 @@ import { compose } from 'redux';
|
|||
import { connect } from 'react-redux';
|
||||
import classNames from 'classnames';
|
||||
import { FormattedMessage, intlShape, injectIntl } from 'react-intl';
|
||||
import { reset as resetForm } from 'redux-form';
|
||||
import * as propTypes from '../../util/propTypes';
|
||||
import { ensureListing, ensureUser, ensureTransaction } from '../../util/data';
|
||||
import { getMarketplaceEntities } from '../../ducks/marketplaceData.duck';
|
||||
import { isScrollingDisabled } from '../../ducks/UI.duck';
|
||||
import { acceptSale, declineSale, loadData } from './SalePage.duck';
|
||||
import { acceptSale, declineSale, loadData, sendMessage } from './SalePage.duck';
|
||||
import {
|
||||
NamedRedirect,
|
||||
SaleDetailsPanel,
|
||||
|
|
@ -39,7 +40,23 @@ export const SalePageComponent = props => {
|
|||
params,
|
||||
scrollingDisabled,
|
||||
transaction,
|
||||
fetchMessagesError,
|
||||
messages,
|
||||
sendMessageInProgress,
|
||||
sendMessageError,
|
||||
onSendMessage,
|
||||
onResetForm,
|
||||
} = props;
|
||||
|
||||
console.log({
|
||||
fetchMessagesError,
|
||||
messages,
|
||||
sendMessageInProgress,
|
||||
sendMessageError,
|
||||
onSendMessage,
|
||||
onResetForm,
|
||||
});
|
||||
|
||||
const currentTransaction = ensureTransaction(transaction);
|
||||
const currentListing = ensureListing(currentTransaction.listing);
|
||||
const listingTitle = currentListing.attributes.title;
|
||||
|
|
@ -121,24 +138,35 @@ SalePageComponent.defaultProps = {
|
|||
acceptSaleError: null,
|
||||
declineSaleError: null,
|
||||
transaction: null,
|
||||
fetchMessagesError: null,
|
||||
sendMessageError: null,
|
||||
};
|
||||
|
||||
const { bool, func, oneOf, shape, string } = PropTypes;
|
||||
const { bool, func, oneOf, shape, string, arrayOf } = PropTypes;
|
||||
|
||||
SalePageComponent.propTypes = {
|
||||
params: shape({ id: string }).isRequired,
|
||||
tab: oneOf(['details', 'discussion']).isRequired,
|
||||
|
||||
currentUser: propTypes.currentUser,
|
||||
fetchSaleError: propTypes.error,
|
||||
acceptSaleError: propTypes.error,
|
||||
declineSaleError: propTypes.error,
|
||||
acceptInProgress: bool.isRequired,
|
||||
declineInProgress: bool.isRequired,
|
||||
intl: intlShape.isRequired,
|
||||
onAcceptSale: func.isRequired,
|
||||
onDeclineSale: func.isRequired,
|
||||
params: shape({ id: string }).isRequired,
|
||||
scrollingDisabled: bool.isRequired,
|
||||
tab: oneOf(['details', 'discussion']).isRequired,
|
||||
transaction: propTypes.transaction,
|
||||
fetchMessagesError: propTypes.error,
|
||||
messages: arrayOf(propTypes.message).isRequired,
|
||||
sendMessageInProgress: bool.isRequired,
|
||||
sendMessageError: propTypes.error,
|
||||
onSendMessage: func.isRequired,
|
||||
onResetForm: func.isRequired,
|
||||
|
||||
// from injectIntl
|
||||
intl: intlShape.isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = state => {
|
||||
|
|
@ -149,6 +177,10 @@ const mapStateToProps = state => {
|
|||
acceptInProgress,
|
||||
declineInProgress,
|
||||
transactionRef,
|
||||
fetchMessagesError,
|
||||
messages,
|
||||
sendMessageInProgress,
|
||||
sendMessageError,
|
||||
} = state.SalePage;
|
||||
const { currentUser } = state.user;
|
||||
|
||||
|
|
@ -164,6 +196,10 @@ const mapStateToProps = state => {
|
|||
declineInProgress,
|
||||
scrollingDisabled: isScrollingDisabled(state),
|
||||
transaction,
|
||||
fetchMessagesError,
|
||||
messages,
|
||||
sendMessageInProgress,
|
||||
sendMessageError,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -171,6 +207,8 @@ const mapDispatchToProps = dispatch => {
|
|||
return {
|
||||
onAcceptSale: transactionId => dispatch(acceptSale(transactionId)),
|
||||
onDeclineSale: transactionId => dispatch(declineSale(transactionId)),
|
||||
onSendMessage: (saleId, message) => dispatch(sendMessage(saleId, message)),
|
||||
onResetForm: formName => dispatch(resetForm(formName)),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,27 +29,20 @@ describe('SalePage', () => {
|
|||
});
|
||||
|
||||
const props = {
|
||||
params: { id: txId },
|
||||
tab: 'details',
|
||||
currentUser: createCurrentUser('provider1'),
|
||||
location: { search: '' },
|
||||
history: {
|
||||
push: () => console.log('HistoryPush called'),
|
||||
},
|
||||
authInProgress: false,
|
||||
acceptInProgress: false,
|
||||
declineInProgress: false,
|
||||
currentUserHasListings: false,
|
||||
isAuthenticated: false,
|
||||
onLogout: noop,
|
||||
onManageDisableScrolling: noop,
|
||||
onAcceptSale: noop,
|
||||
onDeclineSale: noop,
|
||||
params: { id: txId },
|
||||
scrollingDisabled: false,
|
||||
transaction,
|
||||
tab: 'details',
|
||||
messages: [],
|
||||
sendMessageInProgress: false,
|
||||
onSendMessage: noop,
|
||||
onResetForm: noop,
|
||||
intl: fakeIntl,
|
||||
sendVerificationEmailInProgress: false,
|
||||
onResendVerificationEmail: noop,
|
||||
};
|
||||
|
||||
const tree = renderShallow(<SalePageComponent {...props} />);
|
||||
|
|
|
|||
|
|
@ -26,8 +26,14 @@ exports[`SalePage matches snapshot 1`] = `
|
|||
className="undefined"
|
||||
declineInProgress={false}
|
||||
declineSaleError={null}
|
||||
fetchMessagesError={null}
|
||||
messages={Array []}
|
||||
onAcceptSale={[Function]}
|
||||
onDeclineSale={[Function]}
|
||||
onResetForm={[Function]}
|
||||
onSendMessage={[Function]}
|
||||
sendMessageError={null}
|
||||
sendMessageInProgress={false}
|
||||
transaction={
|
||||
Object {
|
||||
"attributes": Object {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue