Send the enquiry message to the created transaction

This commit is contained in:
Kimmo Puputti 2017-12-19 10:47:55 +02:00
parent 683b989e1f
commit 251e496e11
2 changed files with 7 additions and 6 deletions

View file

@ -114,7 +114,6 @@ export const fetchReviews = listingId => (dispatch, getState, sdk) => {
};
export const sendEnquiry = (listingId, message) => (dispatch, getState, sdk) => {
console.log('sendEnquiry:', listingId.uuid, message);
dispatch(sendEnquiryRequest());
const bodyParams = {
transition: propTypes.TX_TRANSITION_ENQUIRE,
@ -123,10 +122,13 @@ export const sendEnquiry = (listingId, message) => (dispatch, getState, sdk) =>
return sdk.transactions
.initiate(bodyParams)
.then(response => {
const txId = response.data.data.id;
// TODO: send message to the transaction
dispatch(sendEnquirySuccess());
return txId;
const transactionId = response.data.data.id;
// Send the message to the created transaction
return sdk.messages.send({ transactionId, content: message }).then(() => {
dispatch(sendEnquirySuccess());
return transactionId;
});
})
.catch(e => {
dispatch(sendEnquiryError(storableError(e)));

View file

@ -192,7 +192,6 @@ export class ListingPageComponent extends Component {
onSendEnquiry(listingId, msg)
.then(txId => {
console.log('enquiry success, redirect to tx page:', txId.uuid);
this.setState({ enquiryModalOpen: false });
// Redirect to OrderDetailsPage