import { Query } from 'components/renderCbs'; import { setCurrentTo, TSetCurrentTo } from 'actions/transaction'; import { AddressInputFactory } from './AddressInputFactory'; import React from 'react'; import { connect } from 'react-redux'; import { ICurrentTo } from 'selectors/transaction'; interface DispatchProps { setCurrentTo: TSetCurrentTo; } interface OwnProps { to: string | null; withProps(props: CallbackProps): React.ReactElement | null; } export interface CallbackProps { isValid: boolean; readOnly: boolean; currentTo: ICurrentTo; errorMsg?: string | null; onChange(ev: React.FormEvent): void; } type Props = DispatchProps & DispatchProps & OwnProps; //TODO: add ens resolving class AddressFieldFactoryClass extends React.Component { public componentDidMount() { // this 'to' parameter can be either token or actual field related const { to } = this.props; if (to) { this.props.setCurrentTo(to); } } public render() { return ; } private setAddress = (ev: React.FormEvent) => { const { value } = ev.currentTarget; this.props.setCurrentTo(value); }; } const AddressField = connect(null, { setCurrentTo })(AddressFieldFactoryClass); interface DefaultAddressFieldProps { withProps(props: CallbackProps): React.ReactElement | null; } const DefaultAddressField: React.SFC = ({ withProps }) => ( } /> ); export { DefaultAddressField as AddressFieldFactory };