Commit 15f6bb15 authored by ecrofeg's avatar ecrofeg

28612: Flights lazy rendering

parent c3a2e372
Pipeline #380 passed with stages
in 3 minutes and 28 seconds
import * as React from 'react';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import Typography from '@material-ui/core/Typography';
import autobind from 'autobind-decorator';
......@@ -7,11 +8,7 @@ import FlightModel from '../models/Flight';
import { RootState } from '../store/reducers';
import { SelectedFlightAction, selectFlight } from '../store/selectedFlights/actions';
import { getCurrentLegId, isFirstLeg, isLastLeg, isMultipleLegs } from '../store/currentLeg/selectors';
import {
getRelativePrices,
getTotalPrices, getVisibleFlights,
PricesByFlights
} from '../store/selectors';
import { getRelativePrices, getTotalPrices, getVisibleFlights, PricesByFlights } from '../store/selectors';
import { hasHiddenFlights } from '../store/selectors';
import { loadMoreFlights } from '../store/numOfVisibleFlights/actions';
import { SnackbarProps, withSnackbar } from './Snackbar';
......@@ -25,7 +22,6 @@ import { getCurrency, getCurrencyRates } from '../store/currency/selectors';
import CurrencyRates from '../schemas/CurrencyRates';
import { FlightsState } from '../store/flights/reducers';
import { getAllFlights } from '../store/flights/selectors';
import { createStructuredSelector } from 'reselect';
interface StateProps {
prices: FlightsReplacement;
......@@ -163,31 +159,35 @@ class FlightsList extends React.Component<Props> {
const { currentLegId, prices, totalPrices, nemoURL, currency, rates, isLastLeg, isProMode, allFlights } = this.props;
return this.props.flights.length ?
<>
{this.props.flights.map(flight => {
const replacementFlight = prices[flight.id].isRT ? allFlights[prices[flight.id].newFlightId] : null;
return <ResultsFlight
key={flight.id}
currency={currency}
rates={rates}
nemoURL={nemoURL}
replacement={prices[flight.id]}
totalPrice={totalPrices[flight.id]}
flight={flight}
replacementFlight={replacementFlight}
selectFlight={this.selectFlight}
currentLegId={currentLegId}
showPricePrefix={this.props.isFirstLeg && this.props.isMultipleLegs}
isLastLeg={isLastLeg}
isProMode={isProMode}
/>;
})}
</> :
(
<div className="results-noResultsTitle">
<Typography variant="headline">{i18n('filters-noResultsTitle')}</Typography>
<Typography variant="subheading">{i18n('filters-noResultsSubTitle')}</Typography>
<div className="results-flights">
{this.props.flights.map(flight => {
const replacementFlight = prices[flight.id].isRT ? allFlights[prices[flight.id].newFlightId] : null;
return <ResultsFlight
key={flight.id}
currency={currency}
rates={rates}
nemoURL={nemoURL}
replacement={prices[flight.id]}
totalPrice={totalPrices[flight.id]}
flight={flight}
replacementFlight={replacementFlight}
selectFlight={this.selectFlight}
currentLegId={currentLegId}
showPricePrefix={this.props.isFirstLeg && this.props.isMultipleLegs}
isLastLeg={isLastLeg}
isProMode={isProMode}
/>;
})}
</div>
) :
(
<div className="results-flights">
<div className="results-noResultsTitle">
<Typography variant="headline">{i18n('filters-noResultsTitle')}</Typography>
<Typography variant="subheading">{i18n('filters-noResultsSubTitle')}</Typography>
</div>
</div>
);
}
......
......@@ -48,9 +48,7 @@ class Results extends React.Component<StateProps> {
<MobileFilters/>
</MediaQuery>
<div className="results-flights">
<FlightsList/>
</div>
<FlightsList/>
</> : this.renderNoFlights()}
</div>
);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment