import { ReactElement } from 'react' ; import queryString from 'query-string' ; import { RouteComponentProps , withRouter } from 'react-router-dom' ; import { TxParam } from '@features/SendAssets/preFillTx' ; import { IQueryResults } from '@types' ; import { getParam } from '@utils' ; const parse = ( location ) : Query => { const searchStr = location . search ; const query = queryString . parse ( searchStr ) ; return query ; } ; interface Props { params : TxParam [ ] ; withQuery ( query ) : ReactElement < any > | null ; } interface Query { [ key ] : string ; } export const Query = withRouter ( ( { withQuery , params , location } ) => { const query = parse ( location ) ; const res = params . reduce ( ( acc , param ) => ( { ... acc , [ param ] : getParam ( query , param ) } ) , { } ) ; return withQuery ( res ) ; } ) ;