Skip to content

Commit

Permalink
refactor(DateTimeModal): Remove routing profile content.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Mar 11, 2020
1 parent cf83afd commit defce4f
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions lib/components/form/date-time-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { Button, ButtonGroup } from 'react-bootstrap'
import styled from 'styled-components'
import { getTimeFormat, getDateFormat } from '@opentripplanner/core-utils/lib/time'
import { DateTimeSelector } from '@opentripplanner/trip-form'
Expand Down Expand Up @@ -84,51 +83,16 @@ const StyledDateTimeSelector = styled(DateTimeSelector)`
}
`

// Define default routingType labels and components
const rtDefaults = [
{
key: 'ITINERARY',
text: 'Itinerary'
}, {
key: 'PROFILE',
text: 'Profile'
}
]

class DateTimeModal extends Component {
static propTypes = {
routingType: PropTypes.string,
setQueryParam: PropTypes.func
}

render () {
const { config, date, dateFormatLegacy, departArrive, routingType, setQueryParam, time, timeFormatLegacy } = this.props
const { date, dateFormatLegacy, departArrive, setQueryParam, time, timeFormatLegacy } = this.props

return (
<div className='date-time-modal'>
{/* The routing-type selection button row. Only show if more than one configured */}
{config.routingTypes.length > 1 && (
<div className='button-row'>
<ButtonGroup justified>
{config.routingTypes.map(rtConfig => {
return (
<ButtonGroup key={rtConfig.key}>
<Button
className={rtConfig.key === routingType ? 'selected' : ''}
onClick={() => {
setQueryParam({ routingType: rtConfig.key })
}}
>
{rtConfig.text || rtDefaults.find(d => d.key === rtConfig.key).text}
</Button>
</ButtonGroup>
)
})}
</ButtonGroup>
</div>
)}

{/* The main panel for the selected routing type */}
<div className='main-panel'>
<StyledDateTimeSelector
className='date-time-selector'
Expand All @@ -146,13 +110,12 @@ class DateTimeModal extends Component {
}

const mapStateToProps = (state, ownProps) => {
const {departArrive, date, time, routingType} = state.otp.currentQuery
const { departArrive, date, time } = state.otp.currentQuery
return {
config: state.otp.config,
departArrive,
date,
time,
routingType,
// These props below are for Safari on MacOS, and old browsers
// that don't support `<input type="time|date">`.
// In modern browsers, `<input type="time|date">` already
Expand Down

0 comments on commit defce4f

Please sign in to comment.