import React from 'react';
export default function withReduxForm(WrappedComponent) {
    return (props) => {
        const { meta, error, input, ...rest } = props;
        const getErrorMessage = () => {
            if (meta) {
                const { touched, submitFailed, error: metaError } = meta;
                if ((touched || submitFailed) && metaError) {
                    return metaError;
                }
            }
            return error;
        };
        return <WrappedComponent {...rest} {...input} error={getErrorMessage()}/>;
    };
}
