Browse Source

Rewrote some logic to please flow

master
Thibaut Boustany 7 years ago
parent
commit
5fa882b6ed
  1. 39
      src/components/modals/Send/index.js

39
src/components/modals/Send/index.js

@ -175,26 +175,33 @@ class SendModal extends PureComponent<Props, State> {
return null
}
const { Comp } = step
const props = (predicate, props) => (predicate ? props : {})
const stepProps = {
...otherState,
t,
account: this._account,
...props(stepIndex === 1, {
accountName: this._account ? this._account.name : undefined,
deviceSelected,
onChangeDevice: this.handleChangeDevice,
onStatusChange: this.handleChangeStatus,
}),
...props(stepIndex === 2, {
device: deviceSelected,
onValidate: this.handleValidate,
}),
...props(stepIndex === 3, {
txValidated,
}),
}
switch (stepIndex) {
case 1:
stepProps.accountName = this._account ? this._account.name : undefined
stepProps.deviceSelected = deviceSelected
stepProps.onChangeDevice = this.handleChangeDevice
stepProps.onStatusChange = this.handleChangeStatus
break
case 2:
stepProps.device = deviceSelected
stepProps.onValidate = this.handleValidate
break
case 3:
if (txValidated !== null) {
stepProps.txValidated = txValidated
}
break
default:
break
}
return <Comp onChange={this.createChangeHandler} {...stepProps} />

Loading…
Cancel
Save