From ce5970c6e28582a8016a45086d9470adf8ff4486 Mon Sep 17 00:00:00 2001 From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com> Date: Thu, 20 Aug 2020 12:04:37 -0400 Subject: [PATCH] fix(Itineraries): Hide the Save Trip button if no user is logged in. --- lib/components/narrative/default/default-itinerary.js | 8 ++++++-- lib/components/narrative/itinerary-carousel.js | 6 ++++-- lib/components/narrative/line-itin/line-itinerary.js | 7 +++++-- lib/components/narrative/narrative-itineraries.js | 5 ++++- lib/components/narrative/tabbed-itineraries.js | 7 +++++-- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lib/components/narrative/default/default-itinerary.js b/lib/components/narrative/default/default-itinerary.js index 62a6292cd..f93f356c0 100644 --- a/lib/components/narrative/default/default-itinerary.js +++ b/lib/components/narrative/default/default-itinerary.js @@ -21,7 +21,8 @@ export default class DefaultItinerary extends NarrativeItinerary { itinerary, LegIcon, setActiveLeg, - setActiveStep + setActiveStep, + user } = this.props return (
@@ -32,7 +33,10 @@ export default class DefaultItinerary extends NarrativeItinerary { Itinerary {index + 1}{' '} {formatDuration(itinerary.duration)}{' '} {formatTime(itinerary.startTime)}—{formatTime(itinerary.endTime)} - Save{' '} + {user && (<> + Save{' '} + + )} {(active || expanded) && diff --git a/lib/components/narrative/itinerary-carousel.js b/lib/components/narrative/itinerary-carousel.js index 55ad57435..2b0e91736 100644 --- a/lib/components/narrative/itinerary-carousel.js +++ b/lib/components/narrative/itinerary-carousel.js @@ -50,7 +50,7 @@ class ItineraryCarousel extends Component { } render () { - const { activeItinerary, itineraries, itineraryClass, hideHeader, pending } = this.props + const { activeItinerary, itineraries, itineraryClass, hideHeader, pending, user } = this.props if (pending) return if (!itineraries) return null @@ -61,6 +61,7 @@ class ItineraryCarousel extends Component { key: index, expanded: this.props.expanded, onClick: this._onItineraryClick, + user, ...this.props }) }) @@ -112,7 +113,8 @@ const mapStateToProps = (state, ownProps) => { activeLeg: activeSearch && activeSearch.activeLeg, activeStep: activeSearch && activeSearch.activeStep, companies: state.otp.currentQuery.companies, - timeFormat: coreUtils.time.getTimeFormat(state.otp.config) + timeFormat: coreUtils.time.getTimeFormat(state.otp.config), + user: state.user.loggedInUser } } diff --git a/lib/components/narrative/line-itin/line-itinerary.js b/lib/components/narrative/line-itin/line-itinerary.js index 89b1c194d..05fc8f311 100644 --- a/lib/components/narrative/line-itin/line-itinerary.js +++ b/lib/components/narrative/line-itin/line-itinerary.js @@ -54,7 +54,8 @@ export default class LineItinerary extends NarrativeItinerary { onClick, setActiveLeg, showRealtimeAnnotation, - timeFormat + timeFormat, + user } = this.props if (!itinerary) { @@ -76,7 +77,9 @@ export default class LineItinerary extends NarrativeItinerary { timeOptions={timeOptions} /> - Save this option + {user && + Save this option + } {showRealtimeAnnotation && } {active || expanded diff --git a/lib/components/narrative/narrative-itineraries.js b/lib/components/narrative/narrative-itineraries.js index a690b7fa8..ece772272 100644 --- a/lib/components/narrative/narrative-itineraries.js +++ b/lib/components/narrative/narrative-itineraries.js @@ -41,7 +41,8 @@ class NarrativeItineraries extends Component { itineraries, itineraryClass, realtimeEffects, - useRealtime + useRealtime, + user } = this.props if (!itineraries) return null @@ -69,6 +70,7 @@ class NarrativeItineraries extends Component { key: index, active: index === activeItinerary, routingType: 'ITINERARY', + user, ...this.props }) })} @@ -95,6 +97,7 @@ const mapStateToProps = (state, ownProps) => { activeLeg: activeSearch && activeSearch.activeLeg, activeStep: activeSearch && activeSearch.activeStep, useRealtime, + user: state.user.loggedInUser, companies: state.otp.currentQuery.companies } } diff --git a/lib/components/narrative/tabbed-itineraries.js b/lib/components/narrative/tabbed-itineraries.js index 94f38eeb8..739429e64 100644 --- a/lib/components/narrative/tabbed-itineraries.js +++ b/lib/components/narrative/tabbed-itineraries.js @@ -40,7 +40,8 @@ class TabbedItineraries extends Component { itineraryClass, realtimeEffects, useRealtime, - timeFormat + timeFormat, + user } = this.props if (!itineraries) return null @@ -123,6 +124,7 @@ class TabbedItineraries extends Component { active: true, routingType: 'ITINERARY', showRealtimeAnnotation, + user, ...this.props })} @@ -149,7 +151,8 @@ const mapStateToProps = (state, ownProps) => { useRealtime, companies: state.otp.currentQuery.companies, tnc: state.otp.tnc, - timeFormat: getTimeFormat(state.otp.config) + timeFormat: getTimeFormat(state.otp.config), + user: state.user.loggedInUser } }