Browse Source

Fare on route page

dev
sipp11 6 years ago
parent
commit
0cfcac439d
  1. 15
      src/components/RouteDetail.js

15
src/components/RouteDetail.js

@ -7,6 +7,7 @@ import Spinner from './Spinner'
import { getRoute, polygonUpdate } from '../actions' import { getRoute, polygonUpdate } from '../actions'
import { getStopTime } from '../actions/stoptime' import { getStopTime } from '../actions/stoptime'
import { getTrip } from '../actions/trip' import { getTrip } from '../actions/trip'
import { getFareAttr } from '../actions/fare'
import store from '../store' import store from '../store'
const StyledTripDesc = styled.div` const StyledTripDesc = styled.div`
@ -83,14 +84,14 @@ const TripList = (props) => (
</div> </div>
) )
const FareRuleList = (props) => ( const FareAttrList = (props) => (
<div> <div>
{props.farerules.map(ele => ( {props.fareattrItems && props.fareattrItems.map(ele => (
<span key={ele.id} className="panel-block"> <span key={ele.id} className="panel-block">
{ele.fare.fare_id} - {ele.fare.price} {ele.fare_id} - {ele.price} {ele.currency_type}
</span> </span>
))} ))}
{props.farerules.length === 0 && <span key="empty-farerule" className="panel-block"> {props.fareattrItems && props.fareattrItems.length === 0 && <span key="empty-farerule" className="panel-block">
No fare rule set No fare rule set
</span>} </span>}
</div> </div>
@ -116,6 +117,7 @@ class RouteDetail extends Component {
} else { } else {
this.pushShapeToStore(match, route) this.pushShapeToStore(match, route)
} }
store.dispatch(getFareAttr(`agency=${match.params.agencyId}`))
} }
componentWillReceiveProps(newProps) { componentWillReceiveProps(newProps) {
@ -137,7 +139,7 @@ class RouteDetail extends Component {
} }
render() { render() {
const { route, match, trip } = this.props const { route, match, trip, fareattr } = this.props
const { routeId, agencyId, routeParams } = match.params const { routeId, agencyId, routeParams } = match.params
const tRoute = route.results.filter(ele => ele.route_id === routeId) const tRoute = route.results.filter(ele => ele.route_id === routeId)
if (tRoute.length === 0) { if (tRoute.length === 0) {
@ -162,7 +164,7 @@ class RouteDetail extends Component {
<Route exact path={`${baseUrl}`} render={(props) => ( <Route exact path={`${baseUrl}`} render={(props) => (
<RouteDesc route={item} {...props} />)} /> <RouteDesc route={item} {...props} />)} />
<Route exact path={`${baseUrl}/fare`} render={(props) => ( <Route exact path={`${baseUrl}/fare`} render={(props) => (
<FareRuleList farerules={item.farerule_set} {...props} />)} /> <FareAttrList fareattrItems={fareattr.results} {...props} />)} />
<Route exact path={`${baseUrl}/trip`} render={(props) => ( <Route exact path={`${baseUrl}/trip`} render={(props) => (
<TripList trips={trip.results} routeId={routeId} agencyId={agencyId} {...props} />)} /> <TripList trips={trip.results} routeId={routeId} agencyId={agencyId} {...props} />)} />
</nav> </nav>
@ -173,6 +175,7 @@ class RouteDetail extends Component {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
route: state.route, route: state.route,
trip: state.trip, trip: state.trip,
fareattr: state.fareattr,
}) })
export default connect( export default connect(
mapStateToProps mapStateToProps

Loading…
Cancel
Save