Vulcan/packages/vulcan-forms/lib/components/Flash.jsx

27 lines
673 B
React
Raw Normal View History

2017-05-19 14:42:43 -06:00
import React from 'react';
import PropTypes from 'prop-types';
2017-06-02 07:19:39 +09:00
import Alert from 'react-bootstrap/lib/Alert'
const Flash = ({message, type}) => {
type = type === "error" ? "danger" : type; // if type is "error", use "danger" instead
return (
<Alert className="flash-message" bsStyle={type}>
{Array.isArray(message) ?
<ul>
{message.map((message, index) =>
<li key={index}>{message.content}</li>
)}
</ul>
: <span>message.content</span>
}
</Alert>
)
}
Flash.propTypes = {
message: PropTypes.oneOfType([PropTypes.object.isRequired, PropTypes.array.isRequired])
}
export default Flash;