|
|
|
@ -6,6 +6,7 @@ import { connect } from 'react-redux'
|
|
|
|
|
import Spinner from './Spinner' |
|
|
|
|
import { getRoute, polygonUpdate } from '../actions' |
|
|
|
|
import { getStopTime } from '../actions/stoptime' |
|
|
|
|
import { getTrip } from '../actions/trip' |
|
|
|
|
import store from '../store' |
|
|
|
|
|
|
|
|
|
const StyledTripDesc = styled.div` |
|
|
|
@ -14,7 +15,6 @@ line-height: 0.85rem;
|
|
|
|
|
margin-left: 10px; |
|
|
|
|
` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const RouteDesc = (props) => ( |
|
|
|
|
<div> |
|
|
|
|
<span className="panel-block"> |
|
|
|
@ -60,7 +60,15 @@ const TripList = (props) => (
|
|
|
|
|
{ele.stoptime.count > 0 && <div> |
|
|
|
|
<b>Stop</b> #{ele.stoptime.count} |
|
|
|
|
<br /> |
|
|
|
|
<b>Time period</b> {ele.stoptime.period[0]} - {ele.stoptime.period[1]} |
|
|
|
|
<b>Time period</b> |
|
|
|
|
<br /> |
|
|
|
|
{ele.stoptime.period[0]} - {ele.stoptime.period[1]} |
|
|
|
|
<br /> |
|
|
|
|
{ele.frequency_set.length > 0 && <b>Frequency</b>} |
|
|
|
|
{ele.frequency_set.map(freq => ( |
|
|
|
|
<span key={`freq-${freq.id}`}><br /> {freq.start_time} -{freq.end_time} |
|
|
|
|
<br /> รอบละ {freq.headway_secs/60} นาที</span> |
|
|
|
|
))} |
|
|
|
|
</div>} |
|
|
|
|
</StyledTripDesc> |
|
|
|
|
</span> |
|
|
|
@ -97,6 +105,8 @@ class RouteDetail extends Component {
|
|
|
|
|
componentDidMount() { |
|
|
|
|
const { updateBreadcrumb, match } = this.props |
|
|
|
|
updateBreadcrumb(match.params) |
|
|
|
|
// fetch related trips
|
|
|
|
|
store.dispatch(getTrip(`route=${match.params.routeId}`)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
componentWillMount() { |
|
|
|
@ -111,7 +121,6 @@ class RouteDetail extends Component {
|
|
|
|
|
componentWillReceiveProps(newProps) { |
|
|
|
|
if (this.props.route.count < newProps.route.count) { |
|
|
|
|
this.pushShapeToStore(this.props.match, newProps.route) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -128,7 +137,7 @@ class RouteDetail extends Component {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { route, match } = this.props |
|
|
|
|
const { route, match, trip } = this.props |
|
|
|
|
const { routeId, agencyId, routeParams } = match.params |
|
|
|
|
const tRoute = route.results.filter(ele => ele.route_id === routeId) |
|
|
|
|
if (tRoute.length === 0) { |
|
|
|
@ -139,7 +148,6 @@ class RouteDetail extends Component {
|
|
|
|
|
} |
|
|
|
|
const item = tRoute[0] |
|
|
|
|
const baseUrl = `/map/${agencyId}/route/${routeId}` |
|
|
|
|
// TODO: change TripList to use from store.trip (when update will change automatically)
|
|
|
|
|
return ( |
|
|
|
|
<nav className="panel"> |
|
|
|
|
<p className="panel-heading"> |
|
|
|
@ -156,7 +164,7 @@ class RouteDetail extends Component {
|
|
|
|
|
<Route exact path={`${baseUrl}/fare`} render={(props) => ( |
|
|
|
|
<FareRuleList farerules={item.farerule_set} {...props} />)} /> |
|
|
|
|
<Route exact path={`${baseUrl}/trip`} render={(props) => ( |
|
|
|
|
<TripList trips={item.trip_set} routeId={routeId} agencyId={agencyId} {...props} />)} /> |
|
|
|
|
<TripList trips={trip.results} routeId={routeId} agencyId={agencyId} {...props} />)} /> |
|
|
|
|
</nav> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
@ -164,6 +172,7 @@ class RouteDetail extends Component {
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({ |
|
|
|
|
route: state.route, |
|
|
|
|
trip: state.trip, |
|
|
|
|
}) |
|
|
|
|
export default connect( |
|
|
|
|
mapStateToProps |
|
|
|
|