You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.6 KiB

6 years ago
import React, { Component } from 'react'
import styled from 'styled-components'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom'
import { getCalendar } from '../actions/calendar'
import store from '../store'
const StyledBox = styled.div`
padding: 1rem;
background: #fafafa;
`
const GapBox = styled.span`
margin-right: 5px;
color: ${props => props.checked ? 'green' : 'gray'};;
`
const FakeRow = styled.nav`
padding-top: 5px;
padding-bottom: 5px;
background: white;
margin-bottom: 1rem;
`
const CheckboxIcon = (props) => (
<GapBox checked={props.checked}>
{props.checked === true && <span><i className="fas fa-check-square"></i></span>}
{props.checked !== true && <span><i className="fas fa-square"></i></span>}
</GapBox>
)
class FareList extends Component {
componentWillMount() {
6 years ago
const { count } = this.props.fareattr
6 years ago
if (count === 0)
store.dispatch(getCalendar())
}
render() {
6 years ago
const { results } = this.props.fareattr
6 years ago
const { match } = this.props
return (
<StyledBox>
6 years ago
<h1 className="title">Fare</h1>
6 years ago
<div className="columns">
<div className="column is-12">
<nav className="level is-mobile">
<p className="level-item has-text-centered">
<Link className="link is-info" to={`${match.url}/new`}>
6 years ago
<i className="fas fa-plus" /> New fare
6 years ago
</Link>
</p>
</nav>
{results && Object.keys(results).map(i => (
6 years ago
<FakeRow className="level panel" key={results[i].fare_id}>
6 years ago
<div className="level-item has-text-centered">
<div>
6 years ago
<p className="heading">Fare ID</p>
<p className="title"><Link to={`${match.url}/${results[i].fare_id}`}>{results[i].fare_id}</Link></p>
6 years ago
</div>
</div>
<div className="level-item has-text-centered">
<div>
<p className="heading">Start</p>
<p className="title">{results[i].start_date}</p>
</div>
</div>
<div className="level-item has-text-centered">
<div>
<p className="heading">End</p>
<p className="title">{results[i].end_date}</p>
</div>
</div>
</FakeRow>
))}
</div>
</div>
</StyledBox>
)
}
}
const mapStateToProps = state => ({
6 years ago
farerule: state.farerule,
fareattr: state.fareattr,
6 years ago
})
const connectFareList = connect(
mapStateToProps,
{},
)(FareList)
export default styled(connectFareList)`
color: palevioletred;
font-weight: bold;
`