-
-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathAlert.component.jsx
More file actions
35 lines (30 loc) · 841 Bytes
/
Alert.component.jsx
File metadata and controls
35 lines (30 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import './Alert.styles.scss';
const Alert = ({ alerts }) => {
return alerts.length > 0 &&
alerts.map((alert, index) => {
if (alert.alertType === 'success') {
return (
<aside key={index} className="alert s-notice s-notice__success s-notice__important" role="alert">
{alert.msg}
</aside>
)
} else {
return (
<aside key={index} className="alert s-notice s-notice__danger s-notice__important" role="alert">
{alert.msg}
</aside>
)
}
}
)
}
Alert.propTypes = {
alerts: PropTypes.array.isRequired,
};
const mapStateToProps = (state) => ({
alerts: state.alert,
});
export default connect(mapStateToProps)(Alert);