import { SUPPORTED_TRANSACTION_QUERY_PARAMS } from '@config' ; import { IQueryResults , TxQueryTypes } from '@types' ; import { isQueryValid } from '@utils' ; import { Query } from './Query' ; interface Props { displayQueryMessage ( id ? ) : JSX . Element | null ; } export const WhenQueryExists = ( { displayQueryMessage } ) => { const deriveSendFormQueryWarning = ( queries ) => { if ( ! Object . values ( queries ) . some ( ( v ) => ! ! v ) ) return null ; if ( isQueryValid ( queries ) ) { return displayQueryMessage ( 'WARN_SEND_UNDETECTED_NETWORK_OR_ACCOUNT' ) ; } if ( queries . type && [ TxQueryTypes . SPEEDUP , TxQueryTypes . CANCEL ] . includes ( queries . type ) ) { return displayQueryMessage ( 'WARN_SEND_INCORRECT_PROPS' ) ; } return displayQueryMessage ( ) ; } ; return ( < Query params = { SUPPORTED_TRANSACTION_QUERY_PARAMS } withQuery = { deriveSendFormQueryWarning } / > ) ; } ;