import { DataInput } from './DataInputFactory'; import { Query } from 'components/renderCbs'; import { inputData, TInputData } from 'actions/transaction'; import React from 'react'; import { connect } from 'react-redux'; import { isEtherTransaction } from 'selectors/transaction'; import { AppState } from 'reducers'; export interface CallBackProps { data: AppState['transaction']['fields']['data']; validData: boolean; readOnly: boolean; onChange(ev: React.FormEvent): void; } interface DispatchProps { isEtherTransaction: boolean; inputData: TInputData; } interface OwnProps { data: string | null; withProps(props: CallBackProps): React.ReactElement | null; } interface StateProps { isEtherTransaction: boolean; } type Props = DispatchProps & OwnProps & StateProps; class DataFieldClass extends React.Component { public componentDidMount() { const { data } = this.props; if (data) { this.props.inputData(data); } } public render() { return this.props.isEtherTransaction ? ( ) : null; } private setData = (ev: React.FormEvent) => { const { value } = ev.currentTarget; this.props.inputData(value); }; } const DataField = connect( (state: AppState) => ({ isEtherTransaction: isEtherTransaction(state) }), { inputData } )(DataFieldClass); interface DefaultDataFieldProps { withProps(props: CallBackProps): React.ReactElement | null; } const DefaultDataField: React.SFC = ({ withProps }) => ( /* TODO: check query param of tokens too */ } /> ); export { DefaultDataField as DataFieldFactory };