Skip to content

Commit

Permalink
Merge pull request #4921 from HSLdevcom/DT-6175
Browse files Browse the repository at this point in the history
DT-6175 part1: code cleanup
  • Loading branch information
optionsome authored Jan 10, 2024
2 parents 29e46c1 + e11f44b commit a76787f
Show file tree
Hide file tree
Showing 58 changed files with 1,433 additions and 1,537 deletions.
14 changes: 7 additions & 7 deletions app/component/SummaryRow.js → app/component/Itinerary.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const hasOneTransitLeg = data => {
return data.legs.filter(leg => leg.transitLeg).length === 1;
};

const SummaryRow = (
const Itinerary = (
{
data,
breakpoint,
Expand Down Expand Up @@ -911,7 +911,7 @@ const SummaryRow = (
);
};

SummaryRow.propTypes = {
Itinerary.propTypes = {
refTime: PropTypes.number.isRequired,
data: PropTypes.object.isRequired,
passive: PropTypes.bool,
Expand All @@ -928,7 +928,7 @@ SummaryRow.propTypes = {
lowestCo2value: PropTypes.number,
};

SummaryRow.defaultProps = {
Itinerary.defaultProps = {
zones: [],
passive: false,
intermediatePlaces: [],
Expand All @@ -938,13 +938,13 @@ SummaryRow.defaultProps = {
lowestCo2value: 0,
};

SummaryRow.contextTypes = {
Itinerary.contextTypes = {
intl: intlShape.isRequired,
config: PropTypes.object.isRequired,
};

SummaryRow.displayName = 'SummaryRow';
Itinerary.displayName = 'Itinerary';

const SummaryRowWithBreakpoint = withBreakpoint(SummaryRow);
const ItineraryWithBreakpoint = withBreakpoint(Itinerary);

export { SummaryRow as component, SummaryRowWithBreakpoint as default };
export { Itinerary as component, ItineraryWithBreakpoint as default };
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const ItineraryShape = PropTypes.shape({
});

/* eslint-disable prettier/prettier */
class ItineraryTab extends React.Component {
class ItineraryDetails extends React.Component {
static propTypes = {
plan: PropTypes.shape({
date: PropTypes.number.isRequired,
Expand Down Expand Up @@ -408,18 +408,18 @@ class ItineraryTab extends React.Component {
}

const withRelay = createFragmentContainer(
connectToStores(ItineraryTab, ['TimeStore'], context => ({
connectToStores(ItineraryDetails, ['TimeStore'], context => ({
currentTime: context.getStore('TimeStore').getCurrentTime().unix(),
currentLanguage: context.getStore('PreferencesStore').getLanguage(),
})),
{
plan: graphql`
fragment ItineraryTab_plan on Plan {
fragment ItineraryDetails_plan on Plan {
date
}
`,
itinerary: graphql`
fragment ItineraryTab_itinerary on Itinerary {
fragment ItineraryDetails_itinerary on Itinerary {
walkDistance
duration
startTime
Expand Down Expand Up @@ -643,4 +643,4 @@ const withRelay = createFragmentContainer(
},
);

export { ItineraryTab as Component, withRelay as default };
export { ItineraryDetails as Component, withRelay as default };
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import cx from 'classnames';
import ChildrenShape from '../../../../prop-types/ChildrenShape';
import Icon from '../../../Icon';
import { ICON_INFO, ICON_CAUTION, ICON_TYPE_CAUTION } from '../constants';
import ChildrenShape from '../../prop-types/ChildrenShape';
import Icon from '../Icon';
import { ICON_INFO, ICON_CAUTION, ICON_TYPE_CAUTION } from './constants';

const Title = ({ msgId }) => (
<div className="in-the-past">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import { FormattedMessage } from 'react-intl';
import cx from 'classnames';
import { matchShape } from 'found';
import Icon from '../Icon';
import SummaryRow from '../SummaryRow';
import Itinerary from '../Itinerary';
import { isBrowser } from '../../util/browser';
import { getZones } from '../../util/legUtils';
import CanceledItineraryToggler from '../CanceledItineraryToggler';
import { itineraryHasCancelation } from '../../util/alertUtils';
import { ItinerarySummarySubtitle } from '../ItinerarySummarySubtitle';
import { ItineraryListHeader } from './ItineraryListHeader';
import Loading from '../Loading';
import ItinerarySummaryMessage from './components/ItinerarySummaryMessage';
import ItinerarySummaryMessage from './ItinerarySummaryMessage';
import LocationShape from '../../prop-types/LocationShape';
import ErrorShape from '../../prop-types/ErrorShape';
import RoutingErrorShape from '../../prop-types/RoutingErrorShape';
import RoutingFeedbackPrompt from '../RoutingFeedbackPrompt';

function ItinerarySummaryListContainer(
function ItineraryList(
{
activeIndex,
currentTime,
Expand Down Expand Up @@ -63,7 +63,7 @@ function ItinerarySummaryListContainer(
}, 0).emissionsPerPerson?.co2,
);
const summaries = itineraries.map((itinerary, i) => (
<SummaryRow
<Itinerary
refTime={searchTime}
key={i} // eslint-disable-line react/no-array-index-key
hash={i}
Expand All @@ -90,7 +90,7 @@ function ItinerarySummaryListContainer(
summaries.splice(
0,
0,
<ItinerarySummarySubtitle
<ItineraryListHeader
translationId="itinerary-summary.bikePark-title"
defaultMessage="Biking \u0026 public transport \u0026 walking"
key="itinerary-summary.bikePark-title"
Expand Down Expand Up @@ -120,7 +120,7 @@ function ItinerarySummaryListContainer(
summaries.splice(
bikeAndParkItinerariesToShow ? bikeAndParkItinerariesToShow + 1 : 0,
0,
<ItinerarySummarySubtitle
<ItineraryListHeader
translationId={`itinerary-summary.bikeAndPublic-${allModes
.sort()
.join('-')}-title`}
Expand Down Expand Up @@ -287,7 +287,7 @@ function ItinerarySummaryListContainer(
);
}

ItinerarySummaryListContainer.propTypes = {
ItineraryList.propTypes = {
activeIndex: PropTypes.number.isRequired,
currentTime: PropTypes.number.isRequired,
error: ErrorShape,
Expand All @@ -313,7 +313,7 @@ ItinerarySummaryListContainer.propTypes = {
routingFeedbackPosition: PropTypes.number,
};

ItinerarySummaryListContainer.defaultProps = {
ItineraryList.defaultProps = {
error: undefined,
intermediatePlaces: [],
itineraries: [],
Expand All @@ -328,114 +328,107 @@ ItinerarySummaryListContainer.defaultProps = {
onlyHasWalkingItineraries: false,
};

ItinerarySummaryListContainer.contextTypes = {
ItineraryList.contextTypes = {
config: PropTypes.object.isRequired,
match: matchShape.isRequired,
};

const containerComponent = createFragmentContainer(
ItinerarySummaryListContainer,
{
itineraries: graphql`
fragment ItinerarySummaryListContainer_itineraries on Itinerary
@relay(plural: true) {
walkDistance
const containerComponent = createFragmentContainer(ItineraryList, {
itineraries: graphql`
fragment ItineraryList_itineraries on Itinerary @relay(plural: true) {
walkDistance
startTime
endTime
emissionsPerPerson {
co2
}
legs {
realTime
realtimeState
transitLeg
startTime
endTime
emissionsPerPerson {
co2
mode
distance
duration
rentedBike
interlineWithPreviousLeg
intermediatePlace
intermediatePlaces {
stop {
zoneId
}
}
legs {
realTime
realtimeState
transitLeg
startTime
endTime
route {
mode
distance
duration
rentedBike
interlineWithPreviousLeg
intermediatePlace
intermediatePlaces {
shortName
type
color
agency {
name
}
alerts {
alertSeverityLevel
effectiveEndDate
effectiveStartDate
}
}
trip {
pattern {
code
}
stoptimes {
realtimeState
stop {
zoneId
gtfsId
}
pickupType
}
route {
mode
shortName
type
color
agency {
name
}
occupancy {
occupancyStatus
}
}
from {
name
lat
lon
stop {
gtfsId
zoneId
platformCode
alerts {
alertSeverityLevel
effectiveEndDate
effectiveStartDate
}
}
trip {
pattern {
code
}
stoptimes {
realtimeState
stop {
gtfsId
}
pickupType
}
occupancy {
occupancyStatus
vehicleRentalStation {
vehiclesAvailable
network
}
}
to {
stop {
gtfsId
zoneId
alerts {
alertSeverityLevel
effectiveEndDate
effectiveStartDate
}
}
from {
bikePark {
bikeParkId
name
lat
lon
stop {
gtfsId
zoneId
platformCode
alerts {
alertSeverityLevel
effectiveEndDate
effectiveStartDate
}
}
vehicleRentalStation {
vehiclesAvailable
network
}
}
to {
stop {
gtfsId
zoneId
alerts {
alertSeverityLevel
effectiveEndDate
effectiveStartDate
}
}
bikePark {
bikeParkId
name
}
carPark {
carParkId
name
}
carPark {
carParkId
name
}
}
}
`,
},
);
}
`,
});

export {
containerComponent as default,
ItinerarySummaryListContainer as Component,
};
export { containerComponent as default, ItineraryList as Component };
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import PropTypes from 'prop-types';
import React from 'react';
import { FormattedMessage } from 'react-intl';

export const ItinerarySummarySubtitle = ({ translationId, defaultMessage }) => {
export const ItineraryListHeader = ({ translationId, defaultMessage }) => {
return (
<div className="itinerary-summary-subtitle-container">
<FormattedMessage id={translationId} defaultMessage={defaultMessage} />
</div>
);
};

ItinerarySummarySubtitle.propTypes = {
ItineraryListHeader.propTypes = {
translationId: PropTypes.string.isRequired,
defaultMessage: PropTypes.string,
};

ItinerarySummarySubtitle.defaultProps = {
ItineraryListHeader.defaultProps = {
defaultMessage: '',
};

export default ItinerarySummarySubtitle;
export default ItineraryListHeader;
Loading

0 comments on commit a76787f

Please sign in to comment.