2018-01-30 11:53:12 -05:00
|
|
|
const Formsy = require('formsy-react');
|
|
|
|
const PropTypes = require('prop-types');
|
|
|
|
const React = require('react');
|
2016-06-06 10:10:27 -04:00
|
|
|
|
2016-07-05 12:03:27 -04:00
|
|
|
require('./general-error.scss');
|
|
|
|
|
2016-06-13 12:49:17 -04:00
|
|
|
/*
|
|
|
|
* A special formsy-react component that only outputs
|
|
|
|
* error messages. If you want to display errors that
|
|
|
|
* don't apply to a specific field, insert one of these,
|
|
|
|
* give it a name, and apply your validation error to
|
|
|
|
* the name of the GeneralError component.
|
|
|
|
*/
|
2018-03-30 11:21:41 -04:00
|
|
|
const GeneralError = ({
|
|
|
|
showError,
|
|
|
|
getErrorMessage
|
|
|
|
}) => {
|
|
|
|
if (!showError()) return null;
|
|
|
|
return (
|
|
|
|
<p className="general-error">
|
|
|
|
{getErrorMessage()}
|
|
|
|
</p>
|
|
|
|
);
|
|
|
|
};
|
2018-01-30 11:53:12 -05:00
|
|
|
|
|
|
|
GeneralError.propTypes = {
|
|
|
|
getErrorMessage: PropTypes.func,
|
|
|
|
showError: PropTypes.func
|
|
|
|
};
|
|
|
|
|
2018-03-08 10:04:58 -05:00
|
|
|
module.exports = Formsy.withFormsy(GeneralError);
|