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'
|
2016-06-14 10:45:03 +09:00
|
|
|
|
2017-08-16 16:18:40 +09:00
|
|
|
const Flash = ({message, type}) => {
|
2016-06-14 10:45:03 +09:00
|
|
|
|
|
|
|
type = type === "error" ? "danger" : type; // if type is "error", use "danger" instead
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Alert className="flash-message" bsStyle={type}>
|
2017-08-16 16:18:40 +09:00
|
|
|
{Array.isArray(message) ?
|
|
|
|
<ul>
|
|
|
|
{message.map((message, index) =>
|
|
|
|
<li key={index}>{message.content}</li>
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
: <span>message.content</span>
|
|
|
|
}
|
2016-06-14 10:45:03 +09:00
|
|
|
</Alert>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
Flash.propTypes = {
|
2017-08-16 16:18:40 +09:00
|
|
|
message: PropTypes.oneOfType([PropTypes.object.isRequired, PropTypes.array.isRequired])
|
2016-06-14 10:45:03 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
export default Flash;
|