Skip to content

Commit

Permalink
Revert to previous behavior, add guard
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenyeargin committed Jun 23, 2023
1 parent e9c44e3 commit b525caa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
14 changes: 6 additions & 8 deletions src/components/BCycleMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ import bCycleIconImage from '../resources/bcycle.svg';
import './BCycleMarker.scss';

function BCycleMarker({ station }) {
// Ignore if stations doesn't have status, or if it isn't "installed"
if (typeof station.status === 'undefined' || !station.status.is_installed) {
return;
}

let warning = '';
let opacity = 1.0;
if (!station.status.is_installed) {
opacity = 0.3;
warning = (
<div className="p-2 bg-info text-center">
<div><FontAwesomeIcon icon={faBicycle} fixedWidth={true}></FontAwesomeIcon> Coming soon!</div>
</div>
);
} else if (!station.status.is_renting || !station.status.is_returning) {
if (!station.status.is_renting || !station.status.is_returning) {
opacity = 0.3;
warning = (
<div className="p-2 mb-2 bg-warning text-center">
Expand Down
20 changes: 11 additions & 9 deletions src/controllers/BCycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ function BCycle() {
// Combine BCycle data into one hash
if (bCycleStations.length > 0 && bCycleStationsStatus.length > 0) {
bCycleStations.forEach((station, index) => {
const stationStatus = bCycleStationsStatus.find((s) => station.station_id === s.station_id);
bCycleStations[index].status = stationStatus || { is_installed: 0, is_renting: 0, is_returning: 0, num_bikes_available: 0, num_docks_available: 0 };
bCycleStations[index].status = bCycleStationsStatus.find((s) => station.station_id === s.station_id);
// Remove if no status available
if (!bCycleStations[index].status) {
delete bCycleStations[index];
}
});
}

Expand Down Expand Up @@ -131,14 +134,13 @@ function BCycle() {
</div>
<div className="">
{bCycleStations.map((station) => {
// Ignore if stations doesn't have status, or if it isn't "installed"
if (typeof station.status === 'undefined' || !station.status.is_installed) {
return;
}

let warning = '';
if (!station.status.is_installed) {
warning = (
<div className="p-2 bg-info text-center">
<div><FontAwesomeIcon icon={faBicycle} fixedWidth={true}></FontAwesomeIcon> Coming soon!</div>
</div>
);
} else if (!station.status.is_renting || !station.status.is_returning) {
if (!station.status.is_renting || !station.status.is_returning) {
warning = (
<div className="p-2 bg-warning text-center">
{!station.status.is_renting && (
Expand Down

0 comments on commit b525caa

Please sign in to comment.