Skip to content

Commit

Permalink
fix(PatternSTopCard.js): Fixed prop bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Gregg committed Jul 2, 2021
1 parent 826088d commit 4039af7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/editor/components/pattern/PatternStopCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type Props = {
rowStyle: {[string]: number | string},
saveActiveGtfsEntity: typeof activeActions.saveActiveGtfsEntity,
selectType: string,
selectValue: string,
setActiveEntity: typeof activeActions.setActiveEntity,
setActiveStop: typeof tripPatternActions.setActiveStop,
shouldHaveDisabledOption: boolean,
Expand All @@ -53,7 +52,8 @@ type Props = {
stopIsActive: boolean,
title: string,
updateActiveGtfsEntity: typeof activeActions.updateActiveGtfsEntity,
updatePatternStops: typeof tripPatternActions.updatePatternStops
updatePatternStops: typeof tripPatternActions.updatePatternStops,
value: string
}

type State = {
Expand Down Expand Up @@ -83,7 +83,7 @@ const pickupDropoffOptions = [

// renders the form control drop downs for dropOff/Pick up and also continuous
const PickupDropoffSelect = (props: Props) => {
const {activePattern, controlLabel, selectType, shouldHaveDisabledOption, title, onChange, selectValue} = props
const {activePattern, controlLabel, selectType, shouldHaveDisabledOption, title, onChange, value} = props
const hasShapeId = activePattern.shapeId === null
return (
<FormGroup
Expand All @@ -99,7 +99,7 @@ const PickupDropoffSelect = (props: Props) => {
disabled={shouldHaveDisabledOption && hasShapeId}
componentClass='select'
onChange={onChange}
value={selectValue}
value={value}
placeholder='select'>
{pickupDropoffOptions.map(o => (
<option key={o.value} value={o.value}>{o.text}</option>
Expand Down Expand Up @@ -307,14 +307,15 @@ class PatternStopContents extends Component<Props, State> {
updatePatternStops(activePattern, patternStops)
}

onChange = (evt: SyntheticInputEvent<HTMLInputElement>) => {
_onPickupOrDropOffChange = (evt: SyntheticInputEvent<HTMLInputElement>) => {
const selectedOptionValue: number = parseInt(evt.target.value, 10)
const {activePattern, index, updatePatternStops} = this.props
const patternStops = [...activePattern.patternStops]

patternStops[index][evt.target.id] = selectedOptionValue
this.setState({update: true})
updatePatternStops(activePattern, patternStops)
console.log('made it to here')
}

render () {
Expand Down Expand Up @@ -383,7 +384,7 @@ class PatternStopContents extends Component<Props, State> {
title='Define the pickup method/availability at this stop.'
controlLabel='Pickup'
value={patternStop.pickupType || ''}
onChange={this.onChange}
onChange={this._onPickupOrDropOffChange}
/>
</Col>
<Col xs={6}>
Expand All @@ -394,7 +395,7 @@ class PatternStopContents extends Component<Props, State> {
title='Define the dropff method/availability at this stop.'
controlLabel='Drop-off'
value={patternStop.dropOffType || ''}
onChange={this.onChange}
onChange={this._onPickupOrDropOffChange}
/>
</Col>
</Row>
Expand All @@ -407,7 +408,7 @@ class PatternStopContents extends Component<Props, State> {
title='Indicates whether a rider can board the transit vehicle anywhere along the vehicle’s travel path.'
controlLabel='Continuous pickup'
value={patternStop.continuousPickup || ''}
onChange={this.onChange}
onChange={this._onPickupOrDropOffChange}
/>
</Col>
<Col xs={6}>
Expand All @@ -418,7 +419,7 @@ class PatternStopContents extends Component<Props, State> {
title='Indicates whether a rider can alight from the transit vehicle at any point along the vehicle’s travel path.'
controlLabel='Continuous drop-off'
value={patternStop.continuousDropOff || ''}
onChange={this.onChange}
onChange={this._onPickupOrDropOffChange}
/>
</Col>
</Row>
Expand Down

0 comments on commit 4039af7

Please sign in to comment.