Skip to content
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

Add scooter stop fallback message #767

Open
wants to merge 3 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/component/BikeRentalStationPageMapContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ BikeRentalStationPageMapContainer.propTypes = {
lat: PropTypes.number.isRequired,
lon: PropTypes.number.isRequired,
name: PropTypes.string,
networks: PropTypes.oneOfType([
PropTypes.string,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will networks be string, when array?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always a string array. When it has only one element, it can be handled as a string.

PropTypes.arrayOf(PropTypes.string),
]).isRequired,
}),
};

Expand All @@ -34,6 +38,7 @@ const containerComponent = createFragmentContainer(
lat
lon
name
networks
}
`,
},
Expand Down
17 changes: 16 additions & 1 deletion app/component/SelectedStopPopupContent.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import PropTypes from 'prop-types';
import React from 'react';

import { FormattedMessage } from 'react-intl';

const SelectedStopPopupContent = ({ stop }) => (
<div className="origin-popup">
<div className="origin-popup-header">
<div className="selected-stop-header">{stop.name}</div>
<div className="selected-stop-header">
{!stop.name || stop.networks[0] === 'tier_REUTLINGEN' ? (
<FormattedMessage
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not use network specific code here. Is there a way to deduce the vehicleType from the stop and use a vehicleType specific message?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used this solution because originally the popup should show the name of the actual stop - but in case of this network, the name is an incomprehensible number code. If we'd use any other condition, this process will change. Should we refactor this anyway and do not use the name (not at any stop popup) but display a message based on the vehicle type?

id={`${stop.networks}-station-no-id`}
defaultMessage="Station"
/>
) : (
stop.name
)}
</div>
</div>
{(stop.code || stop.desc) && (
<div>
Expand All @@ -22,6 +33,10 @@ const SelectedStopPopupContent = ({ stop }) => (

SelectedStopPopupContent.propTypes = {
stop: PropTypes.object.isRequired,
networks: PropTypes.oneOfType([
PropTypes.string,
PropTypes.arrayOf(PropTypes.string),
]).isRequired,
};

SelectedStopPopupContent.displayName = 'SelectedStopPopupContent';
Expand Down