mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 20:53:24 +10:00
Refactor fetchSpeculatedTransaction to accommodate booking data easily if needed
This commit is contained in:
parent
239eb1fad2
commit
b310613017
2 changed files with 8 additions and 15 deletions
|
|
@ -155,18 +155,12 @@ export const initiateOrder = (orderParams, initialMessage) => (dispatch, getStat
|
|||
* pricing info for the booking breakdown to get a proper estimate for
|
||||
* the price with the chosen information.
|
||||
*/
|
||||
export const speculateTransaction = (listingId, bookingStart, bookingEnd) => (
|
||||
dispatch,
|
||||
getState,
|
||||
sdk
|
||||
) => {
|
||||
export const speculateTransaction = params => (dispatch, getState, sdk) => {
|
||||
dispatch(speculateTransactionRequest());
|
||||
const bodyParams = {
|
||||
transition: TRANSITION_REQUEST,
|
||||
params: {
|
||||
listingId,
|
||||
bookingStart,
|
||||
bookingEnd,
|
||||
...params,
|
||||
cardToken: 'CheckoutPage_speculative_card_token',
|
||||
},
|
||||
};
|
||||
|
|
@ -185,10 +179,11 @@ export const speculateTransaction = (listingId, bookingStart, bookingEnd) => (
|
|||
dispatch(speculateTransactionSuccess(tx));
|
||||
})
|
||||
.catch(e => {
|
||||
const { listingId, bookingStart, bookingEnd } = params;
|
||||
log.error(e, 'speculate-transaction-failed', {
|
||||
listingId: listingId.uuid,
|
||||
bookingStart: bookingStart,
|
||||
bookingEnd: bookingEnd,
|
||||
bookingStart,
|
||||
bookingEnd,
|
||||
});
|
||||
return dispatch(speculateTransactionError(storableError(e)));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -90,11 +90,9 @@ export class CheckoutPageComponent extends Component {
|
|||
pageData.bookingDates.bookingEnd;
|
||||
|
||||
if (hasData) {
|
||||
this.props.fetchSpeculatedTransaction(
|
||||
pageData.listing.id,
|
||||
pageData.bookingDates.bookingStart,
|
||||
pageData.bookingDates.bookingEnd
|
||||
);
|
||||
const listingId = pageData.listing.id;
|
||||
const { bookingStart, bookingEnd } = pageData.bookingDates;
|
||||
fetchSpeculatedTransaction({ listingId, bookingStart, bookingEnd });
|
||||
}
|
||||
|
||||
this.setState({ pageData: pageData || {}, dataLoaded: true });
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue