-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DT-4910: New texts for infobox #4875
Changes from 27 commits
9846088
33b3c11
182ba1c
67fc9ae
99f7b31
e807d10
290cf17
7cb8c67
f569001
ed2ca98
3cb02df
6cb1f7f
22ed412
08845a0
acad2d2
ca55d23
81dfc4b
ac037fb
ae21227
28d9113
2487893
9c720c7
14043e3
291099d
798ee74
98260b8
f83a7c3
8934ca8
0954c57
44d211b
c5d341d
dafbba7
f3274b1
1c1b6e1
f575303
8ee65b8
88aad96
84758f0
d8faf24
a5bec27
d94c436
f1c717e
125255c
bc3c5a5
7b77158
b9c7ed1
0285ffa
8b6c417
65567b7
74e5f3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import get from 'lodash/get'; | ||
import PropTypes from 'prop-types'; | ||
import Icon from './Icon'; | ||
|
||
const FareDisclaimer = ( | ||
{ textId, values, href = null, configData = null }, | ||
{ config }, | ||
) => { | ||
return ( | ||
<div className="disclaimer-container unknown-fare-disclaimer__top"> | ||
<div className="icon-container"> | ||
<Icon className="info" img="icon-icon_info" /> | ||
</div> | ||
<div className="description-container"> | ||
<FormattedMessage | ||
id={textId} | ||
values={{ agencyName: get(config, values) }} | ||
/> | ||
|
||
{href && ( | ||
<a href={href}> | ||
<FormattedMessage id={configData} defaultMessage={configData} /> | ||
</a> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
FareDisclaimer.propTypes = { | ||
textId: PropTypes.string.isRequired, | ||
values: PropTypes.string.isRequired, | ||
href: PropTypes.string, | ||
configData: PropTypes.string, | ||
}; | ||
|
||
FareDisclaimer.defaultProps = { | ||
href: null, | ||
configData: null, | ||
}; | ||
|
||
FareDisclaimer.contextTypes = { | ||
config: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default FareDisclaimer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
import get from 'lodash/get'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import { createFragmentContainer, graphql } from 'react-relay'; | ||
import cx from 'classnames'; | ||
import { matchShape, routerShape } from 'found'; | ||
import { FormattedMessage, intlShape } from 'react-intl'; | ||
import connectToStores from 'fluxible-addons-react/connectToStores'; | ||
|
||
import Icon from './Icon'; | ||
import TicketInformation from './TicketInformation'; | ||
import RouteInformation from './RouteInformation'; | ||
import ItinerarySummary from './ItinerarySummary'; | ||
import ItineraryLegs from './ItineraryLegs'; | ||
import BackButton from './BackButton'; | ||
import MobileTicketPurchaseInformation from './MobileTicketPurchaseInformation'; | ||
import { | ||
getRoutes, | ||
getZones, | ||
compressLegs, | ||
getRoutes, | ||
getTotalBikingDistance, | ||
getTotalBikingDuration, | ||
getTotalDrivingDistance, | ||
getTotalDrivingDuration, | ||
getTotalWalkingDistance, | ||
getTotalWalkingDuration, | ||
legContainsRentalBike, | ||
getTotalDrivingDuration, | ||
getTotalDrivingDistance, | ||
getZones, | ||
isCallAgencyPickupType, | ||
hasLegMode, | ||
legContainsRentalBike, | ||
} from '../util/legUtils'; | ||
import { BreakpointConsumer } from '../util/withBreakpoint'; | ||
|
||
|
@@ -36,14 +34,15 @@ import { | |
} from '../util/fareUtils'; | ||
import { addAnalyticsEvent } from '../util/analyticsUtils'; | ||
import { | ||
getCurrentMillis, | ||
getFormattedTimeDate, | ||
isToday, | ||
isTomorrow, | ||
getFormattedTimeDate, | ||
getCurrentMillis, | ||
} from '../util/timeUtils'; | ||
import CityBikeDurationInfo from './CityBikeDurationInfo'; | ||
import { getCityBikeNetworkId } from '../util/citybikes'; | ||
import { FareShape } from '../util/shapes'; | ||
import FareDisclaimer from './FareDisclaimer'; | ||
|
||
const AlertShape = PropTypes.shape({ alertSeverityLevel: PropTypes.string }); | ||
|
||
|
@@ -87,7 +86,7 @@ class ItineraryTab extends React.Component { | |
|
||
static defaultProps = { | ||
hideTitle: false, | ||
currentLanguage: "fi" | ||
currentLanguage: 'fi', | ||
}; | ||
|
||
static contextTypes = { | ||
|
@@ -159,7 +158,7 @@ class ItineraryTab extends React.Component { | |
walkingDistance > 0 && | ||
(bikingDistance > 0 || drivingDistance > 0) && | ||
futureText !== ''; | ||
const extraProps = { | ||
return { | ||
walking: { | ||
duration: walkingDuration, | ||
distance: walkingDistance, | ||
|
@@ -175,7 +174,6 @@ class ItineraryTab extends React.Component { | |
futureText, | ||
isMultiRow, | ||
}; | ||
return extraProps; | ||
}; | ||
|
||
render() { | ||
|
@@ -217,8 +215,16 @@ class ItineraryTab extends React.Component { | |
const suggestionIndex = this.context.match.params.secondHash | ||
? Number(this.context.match.params.secondHash) + 1 | ||
: Number(this.context.match.params.hash) + 1; | ||
const itineraryContainsCallLegs = itinerary.legs.some(leg => isCallAgencyPickupType(leg)); | ||
|
||
const itineraryContainsCallLegs = itinerary.legs.some(leg => | ||
isCallAgencyPickupType(leg), | ||
); | ||
const hasTrainLegs = itinerary.legs.some(leg => hasLegMode(leg)); | ||
|
||
const showLegModeDisclaimer = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seuraava olisi hyvä ratkaisu: |
||
config.modeDisclaimers && config.modeDisclaimers.rail && hasTrainLegs; | ||
const showCallAgencyDisclaimer = | ||
config.callAgencyInfo && itineraryContainsCallLegs; | ||
|
||
return ( | ||
<div className="itinerary-tab"> | ||
<h2 className="sr-only"> | ||
|
@@ -241,7 +247,11 @@ class ItineraryTab extends React.Component { | |
futureText={extraProps.futureText} | ||
isMultiRow={extraProps.isMultiRow} | ||
isMobile={this.props.isMobile} | ||
hideBottomDivider={shouldShowFarePurchaseInfo(config, breakpoint, fares)} | ||
hideBottomDivider={shouldShowFarePurchaseInfo( | ||
config, | ||
breakpoint, | ||
fares, | ||
)} | ||
/> | ||
) : ( | ||
<> | ||
|
@@ -282,18 +292,19 @@ class ItineraryTab extends React.Component { | |
config={config} | ||
/> | ||
), | ||
shouldShowFareInfo(config) && ( | ||
shouldShowFarePurchaseInfo(config,breakpoint,fares) ? ( | ||
shouldShowFareInfo(config) && | ||
(shouldShowFarePurchaseInfo(config, breakpoint, fares) ? ( | ||
<MobileTicketPurchaseInformation | ||
fares={fares} | ||
zones={getZones(itinerary.legs)} | ||
/>) : | ||
( <TicketInformation | ||
/> | ||
) : ( | ||
<TicketInformation | ||
fares={fares} | ||
zones={getZones(itinerary.legs)} | ||
legs={itinerary.legs} | ||
/>) | ||
), | ||
/> | ||
)), | ||
<div | ||
className={cx('momentum-scroll itinerary-tabs__scroll', { | ||
multirow: extraProps.isMultiRow, | ||
|
@@ -307,42 +318,44 @@ class ItineraryTab extends React.Component { | |
> | ||
{shouldShowFareInfo(config) && | ||
fares.some(fare => fare.isUnknown) && ( | ||
<div className="disclaimer-container unknown-fare-disclaimer__top"> | ||
<div className="icon-container"> | ||
<Icon className="info" img="icon-icon_info" /> | ||
</div> | ||
{config.callAgencyInfo && itineraryContainsCallLegs ? | ||
(<div className="description-container"> | ||
<FormattedMessage | ||
id="separate-ticket-required-for-call-agency-disclaimer" | ||
values={{ | ||
callAgencyInfoUrl: get( | ||
config, | ||
`callAgencyInfo.${currentLanguage}.callAgencyInfoLink`, | ||
), | ||
}} | ||
/> | ||
<a href={config.callAgencyInfo[currentLanguage].callAgencyInfoLink}> | ||
<FormattedMessage | ||
id={config.callAgencyInfo[currentLanguage].callAgencyInfoLinkText} | ||
defaultMessage={config.callAgencyInfo[currentLanguage].callAgencyInfoLinkText} | ||
/> | ||
</a> | ||
</div> | ||
) : ( | ||
<div className="description-container"> | ||
<FormattedMessage | ||
id="separate-ticket-required-disclaimer" | ||
values={{ | ||
agencyName: get( | ||
config, | ||
'ticketInformation.primaryAgencyName', | ||
), | ||
}} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
<> | ||
{showLegModeDisclaimer && ( | ||
<FareDisclaimer | ||
textId="train-ticket-limited" | ||
values="appBarLink.name" | ||
href={ | ||
config.modeDisclaimers.rail[currentLanguage] | ||
.showTrainLimitationInfoLink | ||
} | ||
configData={ | ||
config.modeDisclaimers.rail[currentLanguage] | ||
.showTrainLimitationInfoLinkText | ||
} | ||
/> | ||
)} | ||
|
||
{showCallAgencyDisclaimer && ( | ||
<FareDisclaimer | ||
textId="separate-ticket-required-for-call-agency-disclaimer" | ||
values={`callAgencyInfo.${currentLanguage}.callAgencyInfoLink`} | ||
href={ | ||
config.callAgencyInfo[currentLanguage] | ||
.callAgencyInfoLink | ||
} | ||
configData={ | ||
config.callAgencyInfo[currentLanguage] | ||
.callAgencyInfoLinkText | ||
} | ||
/> | ||
)} | ||
|
||
{!showCallAgencyDisclaimer && !showLegModeDisclaimer && ( | ||
<FareDisclaimer | ||
textId="separate-ticket-required-disclaimer" | ||
values="ticketInformation.primaryAgencyName" | ||
/> | ||
)} | ||
</> | ||
)} | ||
<ItineraryLegs | ||
fares={fares} | ||
|
@@ -406,7 +419,11 @@ const withRelay = createFragmentContainer( | |
} | ||
legs { | ||
mode | ||
nextLegs(numberOfLegs: 2 originModesWithParentStation: [RAIL] destinationModesWithParentStation: [RAIL]) { | ||
nextLegs( | ||
numberOfLegs: 2 | ||
originModesWithParentStation: [RAIL] | ||
destinationModesWithParentStation: [RAIL] | ||
) { | ||
mode | ||
distance | ||
route { | ||
|
@@ -439,7 +456,7 @@ const withRelay = createFragmentContainer( | |
tripHeadsign | ||
pattern { | ||
code | ||
} | ||
} | ||
occupancy { | ||
occupancyStatus | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configData on todella huono nimi. Muuta se vaikka 'linkText'