mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-31 02:26:50 +10:00
Fetch related listing for the sale page transaction
This commit is contained in:
parent
b1003a62b0
commit
215c2b0b5e
1 changed files with 12 additions and 1 deletions
|
|
@ -81,15 +81,26 @@ const rejectSaleError = e => ({ type: REJECT_SALE_ERROR, error: true, payload: e
|
|||
|
||||
// ================ Thunks ================ //
|
||||
|
||||
const listingRelationship = txResponse => {
|
||||
return txResponse.data.data.relationships.listing.data;
|
||||
};
|
||||
|
||||
export const fetchSale = id =>
|
||||
(dispatch, getState, sdk) => {
|
||||
dispatch(fetchSaleRequest());
|
||||
let txResponse = null;
|
||||
|
||||
return sdk.transactions
|
||||
.show({ id, include: ['customer', 'provider', 'listing', 'booking'] }, { expand: true })
|
||||
.then(response => {
|
||||
txResponse = response;
|
||||
const listingId = listingRelationship(response).id;
|
||||
return sdk.listings.show({ id: listingId, include: ['author', 'images'] });
|
||||
})
|
||||
.then(response => {
|
||||
dispatch(addMarketplaceEntities(txResponse));
|
||||
dispatch(addMarketplaceEntities(response));
|
||||
dispatch(fetchSaleSuccess(response));
|
||||
dispatch(fetchSaleSuccess(txResponse));
|
||||
return response;
|
||||
})
|
||||
.catch(e => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue