import React, { Component } from 'react' import styled from 'styled-components' import { connect } from 'react-redux' import { Link } from 'react-router-dom' import { getFareAttr, getFareRule } from '../actions/fare' import { getItemFromList } from '../utils' import { PaymentMethodChoices, TransferChoices } from '../constants/choices' import store from '../store' const StyledBox = styled.div` padding: 1rem; background: #fafafa; ` const FakeRow = styled.nav` padding-top: 5px; padding-bottom: 5px; background: white; margin-bottom: 1rem; ` class FareList extends Component { componentWillMount() { const { fareattr, farerule } = this.props if (fareattr.count === 0) store.dispatch(getFareAttr()) if (farerule.count === 0) store.dispatch(getFareRule()) } render() { const { fareattr, farerule } = this.props const { match } = this.props return (

Fare

{fareattr.results && Object.keys(fareattr.results).map(i => (

Fare ID

{fareattr.results[i].fare_id}

Price

{fareattr.results[i].price} {fareattr.results[i].currency_type}
{getItemFromList(fareattr.results[i].payment_method, PaymentMethodChoices, '') && getItemFromList(fareattr.results[i].payment_method, PaymentMethodChoices, '').label}

Transfer / sec

{getItemFromList(fareattr.results[i].transfer, TransferChoices, '') && getItemFromList(fareattr.results[i].transfer, TransferChoices, '').label} / {fareattr.results[i].transfer_duration}

Agency

{fareattr.results[i].agency.name}

))}
{farerule.results && Object.keys(farerule.results).map(i => (

Fare ID

{farerule.results[i].fare.fare_id}

Origin ID

{farerule.results[i].origin_id}

Destination ID (or contains)

{farerule.results[i].destination_id} {farerule.results[i].contains_id}

Route ID

{farerule.results[i].route_id}

))}
) } } const mapStateToProps = state => ({ farerule: state.farerule, fareattr: state.fareattr, }) const connectFareList = connect( mapStateToProps, {}, )(FareList) export default styled(connectFareList)` color: palevioletred; font-weight: bold; `