Fix back-to-checkoutpage-from-transactionpage bug

This commit is contained in:
Vesa Luusua 2018-04-05 19:23:41 +03:00
parent ea6ab42429
commit 27cffb31da

View file

@ -72,16 +72,20 @@ export class CheckoutPageComponent extends Component {
* based on this initial data.
*/
loadInitialData() {
const { bookingData, bookingDates, listing, fetchSpeculatedTransaction } = this.props;
const hasDataInProps = !!(bookingData && bookingDates && listing);
const pageData = hasDataInProps
? { bookingData, bookingDates, listing }
: storedData(STORAGE_KEY);
const { bookingData, bookingDates, listing, fetchSpeculatedTransaction, history } = this.props;
// Browser's back navigation should not rewrite data in session store.
// Action is 'POP' on both history.back() and page refresh cases.
const hasNavigatedThroughLink = history.action === 'PUSH';
const hasDataInProps = !!(bookingData && bookingDates && listing) && hasNavigatedThroughLink;
if (hasDataInProps) {
storeData(bookingData, bookingDates, listing, STORAGE_KEY);
}
const pageData = hasDataInProps
? { bookingData, bookingDates, listing }
: storedData(STORAGE_KEY);
const hasData =
pageData &&
pageData.listing &&