Skip to content

Commit

Permalink
Fixed bicycle stations ids + all function and names renamed from bike…
Browse files Browse the repository at this point in the history
… to vehicle.
  • Loading branch information
Dvun committed Oct 4, 2023
1 parent bb2627e commit cf5f1d3
Show file tree
Hide file tree
Showing 72 changed files with 575 additions and 552 deletions.
16 changes: 8 additions & 8 deletions app/component/BicycleLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ function BicycleLeg(
const [address, place] = splitStringToAddressAndPlace(leg.from.name);
const networkConfig =
leg.rentedBike &&
leg.from.bikeRentalStation &&
leg.from.vehicleRentalStation &&
getCityBikeNetworkConfig(
getCityBikeNetworkId(leg.from.bikeRentalStation.networks),
getCityBikeNetworkId(leg.from.vehicleRentalStation.network),
config,
);
const isFirstLeg = i => i === 0;
Expand Down Expand Up @@ -203,7 +203,7 @@ function BicycleLeg(
<CityBikeLeg
stationName={leg.from.name}
isScooter={isScooter}
bikeRentalStation={leg.from.bikeRentalStation}
vehicleRentalStation={leg.from.vehicleRentalStation}
/>
)}
{bicycleWalkLeg?.from.stop && (
Expand Down Expand Up @@ -311,9 +311,9 @@ BicycleLeg.propTypes = {
distance: PropTypes.number.isRequired,
from: PropTypes.shape({
name: PropTypes.string.isRequired,
bikeRentalStation: PropTypes.shape({
vehicleRentalStation: PropTypes.shape({
bikesAvailable: PropTypes.number.isRequired,
networks: PropTypes.array.isRequired,
network: PropTypes.string.isRequired,
}),
stop: PropTypes.object,
}).isRequired,
Expand All @@ -332,9 +332,9 @@ BicycleLeg.propTypes = {
startTime: PropTypes.number.isRequired,
from: PropTypes.shape({
name: PropTypes.string.isRequired,
bikeRentalStation: PropTypes.shape({
vehicleRentalStation: PropTypes.shape({
bikesAvailable: PropTypes.number.isRequired,
networks: PropTypes.array.isRequired,
network: PropTypes.string.isRequired,
}),
stop: PropTypes.object,
}).isRequired,
Expand All @@ -344,7 +344,7 @@ BicycleLeg.propTypes = {
}).isRequired,
mode: PropTypes.string.isRequired,
rentedBike: PropTypes.bool.isRequired,
}),
}).isRequired,
index: PropTypes.number.isRequired,
focusAction: PropTypes.func.isRequired,
focusToLeg: PropTypes.func.isRequired,
Expand Down
6 changes: 3 additions & 3 deletions app/component/BikeParkLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@ BikeParkLeg.contextTypes = {
BikeParkLeg.propTypes = {
index: PropTypes.number.isRequired,
focusAction: PropTypes.func.isRequired,
bikePark: PropTypes.object,
bikePark: PropTypes.object.isRequired,
leg: PropTypes.shape({
endTime: PropTypes.number.isRequired,
duration: PropTypes.number.isRequired,
startTime: PropTypes.number.isRequired,
distance: PropTypes.number.isRequired,
from: PropTypes.shape({
name: PropTypes.string.isRequired,
bikeRentalStation: PropTypes.shape({
vehicleRentalStation: PropTypes.shape({
bikesAvailable: PropTypes.number.isRequired,
networks: PropTypes.array.isRequired,
network: PropTypes.string.isRequired,
}),
stop: PropTypes.object,
}).isRequired,
Expand Down
45 changes: 0 additions & 45 deletions app/component/BikeRentalStationPageMapContainer.js

This file was deleted.

41 changes: 25 additions & 16 deletions app/component/CityBikeLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,32 @@ import PropTypes from 'prop-types';
import cx from 'classnames';
import {
BIKEAVL_UNKNOWN,
getCitybikeCapacity,
getCityBikeNetworkConfig,
getCityBikeNetworkIcon,
getCityBikeNetworkId,
getCitybikeCapacity,
hasStationCode,
} from '../util/citybikes';

import withBreakpoint from '../util/withBreakpoint';
import Icon from './Icon';
import { PREFIX_BIKESTATIONS } from '../util/path';
import {
getCityBikeAvailabilityIndicatorColor,
getCityBikeAvailabilityTextColor,
getCityVehicleAvailabilityTextColor,
getCityVehicleAvailabilityIndicatorColor,
} from '../util/legUtils';

function CityBikeLeg(
{ stationName, isScooter, bikeRentalStation, returnBike = false, breakpoint },
{
stationName,
isScooter,
vehicleRentalStation,
returnBike = false,
breakpoint,
},
{ config, intl },
) {
if (!bikeRentalStation) {
if (!vehicleRentalStation) {
return null;
}
// eslint-disable-next-line no-nested-ternary
Expand All @@ -42,22 +48,22 @@ function CityBikeLeg(
);
const citybikeicon = getCityBikeNetworkIcon(
getCityBikeNetworkConfig(
getCityBikeNetworkId(bikeRentalStation.networks),
getCityBikeNetworkId(vehicleRentalStation.network),
config,
),
);
const availabilityIndicatorColor = getCityBikeAvailabilityIndicatorColor(
bikeRentalStation.bikesAvailable,
const availabilityIndicatorColor = getCityVehicleAvailabilityIndicatorColor(
vehicleRentalStation.vehiclesAvailable,
config,
);
const availabilityTextColor = getCityBikeAvailabilityTextColor(
bikeRentalStation.bikesAvailable,
const availabilityTextColor = getCityVehicleAvailabilityTextColor(
vehicleRentalStation.vehiclesAvailable,
config,
);
const mobileReturn = breakpoint === 'small' && returnBike;
const citybikeCapacity = getCitybikeCapacity(
config,
bikeRentalStation?.networks[0],
vehicleRentalStation?.network,
);
return (
<>
Expand All @@ -71,7 +77,7 @@ function CityBikeLeg(
height={1.655}
badgeText={
citybikeCapacity !== BIKEAVL_UNKNOWN && !returnBike
? bikeRentalStation.bikesAvailable
? vehicleRentalStation.vehiclesAvailable
: null
}
badgeFill={returnBike ? null : availabilityIndicatorColor}
Expand All @@ -85,16 +91,18 @@ function CityBikeLeg(
id: 'citybike-station-no-id',
defaultMessage: 'Bike station',
})}
{hasStationCode(bikeRentalStation) && (
{hasStationCode(vehicleRentalStation) && (
<span className="itinerary-stop-code">
{bikeRentalStation.stationId}
{vehicleRentalStation.stationId}
</span>
)}
</span>
</div>
</div>
<div className="link-to-stop">
<Link to={`/${PREFIX_BIKESTATIONS}/${bikeRentalStation.stationId}`}>
<Link
to={`/${PREFIX_BIKESTATIONS}/${vehicleRentalStation.stationId}`}
>
<Icon
img="icon-icon_arrow-collapse--right"
color="#007ac9"
Expand All @@ -107,8 +115,9 @@ function CityBikeLeg(
</>
);
}

CityBikeLeg.propTypes = {
bikeRentalStation: PropTypes.object,
vehicleRentalStation: PropTypes.object,
stationName: PropTypes.string,
isScooter: PropTypes.bool,
returnBike: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import {
getCitybikeCapacity,
BIKEAVL_UNKNOWN,
BIKEAVL_WITHMAX,
BIKESTATION_OFF,
BIKESTATION_CLOSED,
} from '../util/citybikes';

const CityBikeStopContent = ({ bikeRentalStation }, { config }) => {
const CityVehicleStopContent = ({ vehicleRentalStation }, { config }) => {
const citybikeCapacity = getCitybikeCapacity(
config,
bikeRentalStation.networks[0],
vehicleRentalStation.network,
);
if (citybikeCapacity === BIKEAVL_UNKNOWN) {
return null;
Expand All @@ -26,25 +24,24 @@ const CityBikeStopContent = ({ bikeRentalStation }, { config }) => {

if (citybikeCapacity === BIKEAVL_WITHMAX) {
totalSpaces =
bikeRentalStation.capacity ||
bikeRentalStation.bikesAvailable + bikeRentalStation.spacesAvailable;
vehicleRentalStation.capacity ||
vehicleRentalStation.vehiclesAvailable +
vehicleRentalStation.spacesAvailable;
fewAvailableCount = Math.floor(totalSpaces / 3);
fewerAvailableCount = Math.floor(totalSpaces / 6);
}
const disabled =
bikeRentalStation.state === BIKESTATION_OFF ||
bikeRentalStation.state === BIKESTATION_CLOSED;
const disabled = !vehicleRentalStation.operative;

const citybikeicon = getCityBikeNetworkIcon(
getCityBikeNetworkConfig(bikeRentalStation.networks[0], config),
getCityBikeNetworkConfig(vehicleRentalStation.network, config),
disabled,
);
return (
<div className="citybike-content-container">
<Icon img={citybikeicon} />
<CityBikeAvailability
disabled={disabled}
bikesAvailable={bikeRentalStation.bikesAvailable}
bikesAvailable={vehicleRentalStation.vehiclesAvailable}
totalSpaces={totalSpaces}
fewAvailableCount={fewAvailableCount}
fewerAvailableCount={fewerAvailableCount}
Expand All @@ -54,16 +51,16 @@ const CityBikeStopContent = ({ bikeRentalStation }, { config }) => {
);
};

CityBikeStopContent.contextTypes = {
CityVehicleStopContent.contextTypes = {
config: PropTypes.object.isRequired,
};
CityBikeStopContent.propTypes = {
bikeRentalStation: PropTypes.shape({
bikesAvailable: PropTypes.number.isRequired,
CityVehicleStopContent.propTypes = {
vehicleRentalStation: PropTypes.shape({
vehiclesAvailable: PropTypes.number.isRequired,
spacesAvailable: PropTypes.number.isRequired,
capacity: PropTypes.number.isRequired,
networks: PropTypes.arrayOf(PropTypes.string),
state: PropTypes.string.isRequired,
network: PropTypes.string,
operative: PropTypes.bool.isRequired,
}),
};
export default CityBikeStopContent;
export default CityVehicleStopContent;
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { Link } from 'found';
import { graphql, createRefetchContainer } from 'react-relay';
import CityBikeStopContent from './CityBikeStopContent';
import FavouriteBikeRentalStationContainer from './FavouriteBikeRentalStationContainer';
import CityVehicleStopContent from './CityVehicleStopContent';
import FavouriteVehicleRentalStationContainer from './FavouriteVehicleRentalStationContainer';
import { PREFIX_BIKESTATIONS } from '../util/path';
import { isKeyboardSelectionEvent } from '../util/browser';
import { hasStationCode } from '../util/citybikes';

const CityBikeStopNearYou = ({ stop, relay, currentTime, currentMode }) => {
const CityVehicleStopNearYou = ({ stop, relay, currentTime, currentMode }) => {
useEffect(() => {
const { stationId } = stop;
if (currentMode === 'CITYBIKE') {
Expand Down Expand Up @@ -50,45 +50,45 @@ const CityBikeStopNearYou = ({ stop, relay, currentTime, currentMode }) => {
/>
</div>
</div>
<FavouriteBikeRentalStationContainer
bikeRentalStation={stop}
<FavouriteVehicleRentalStationContainer
vehicleRentalStation={stop}
className="bike-rental-favourite-container"
/>
</div>
<CityBikeStopContent bikeRentalStation={stop} />
<CityVehicleStopContent vehicleRentalStation={stop} />
</div>
</span>
);
};
CityBikeStopNearYou.propTypes = {
CityVehicleStopNearYou.propTypes = {
stop: PropTypes.object.isRequired,
currentTime: PropTypes.number.isRequired,
currentMode: PropTypes.string.isRequired,
relay: PropTypes.any,
};

const containerComponent = createRefetchContainer(
CityBikeStopNearYou,
CityVehicleStopNearYou,
{
stop: graphql`
fragment CityBikeStopNearYou_stop on BikeRentalStation {
fragment CityVehicleStopNearYou_stop on VehicleRentalStation {
stationId
name
bikesAvailable
vehiclesAvailable
spacesAvailable
capacity
networks
state
network
operative
}
`,
},
graphql`
query CityBikeStopNearYouRefetchQuery($stopId: String!) {
bikeRentalStation(id: $stopId) {
...CityBikeStopNearYou_stop
query CityVehicleStopNearYouRefetchQuery($stopId: String!) {
vehicleRentalStation(id: $stopId) {
...CityVehicleStopNearYou_stop
}
}
`,
);

export { containerComponent as default, CityBikeStopNearYou as Component };
export { containerComponent as default, CityVehicleStopNearYou as Component };
Loading

0 comments on commit cf5f1d3

Please sign in to comment.