Skip to content

Commit

Permalink
refactor(SimpleMap): Add checks for null itinerary
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Oct 1, 2024
1 parent 650f390 commit c5b622e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
8 changes: 3 additions & 5 deletions lib/components/app/trip-preview-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ const TripPreviewLayout = ({ monitoredTrip }: Props) => {
header={previewTripText}
itinerary={itinerary}
mapElement={
itinerary && (
<MapContainer className="map-container percy-hide">
<SimpleMap itinerary={itinerary} />
</MapContainer>
)
<MapContainer className="map-container percy-hide">
<SimpleMap itinerary={itinerary} />
</MapContainer>
}
subTitle={monitoredTrip?.tripName}
title={previewTripText}
Expand Down
22 changes: 12 additions & 10 deletions lib/components/map/simple-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ComponentContext } from '../../util/contexts'

interface Props {
config: AppConfig
itinerary: Itinerary
itinerary?: Itinerary
}

function noop() {
Expand All @@ -37,7 +37,7 @@ const SimpleMap = ({ config, itinerary }: Props): JSX.Element => {
} = config.map || {}
const baseLayerUrls = baseLayers?.map((bl) => bl.url)
const { disableFlexArc } = transitive || {}
const { legs } = itinerary
const { legs = [] } = itinerary || {}

return (
<BaseMap
Expand All @@ -55,14 +55,16 @@ const SimpleMap = ({ config, itinerary }: Props): JSX.Element => {
toLocation={legs[legs.length - 1]?.to}
/>
<GeolocateControl position="top-left" />
<TransitiveOverlay
transitiveData={itineraryToTransitive(itinerary, {
companies: config.companies,
disableFlexArc,
getRouteLabel: getTransitiveRouteLabel,
intl
})}
/>
{itinerary && (
<TransitiveOverlay
transitiveData={itineraryToTransitive(itinerary, {
companies: config.companies,
disableFlexArc,
getRouteLabel: getTransitiveRouteLabel,
intl
})}
/>
)}

<NavigationControl
position={navigationControlPosition || 'bottom-right'}
Expand Down

0 comments on commit c5b622e

Please sign in to comment.