forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlashMessageRender.tsx
More file actions
38 lines (33 loc) · 1.16 KB
/
FlashMessageRender.tsx
File metadata and controls
38 lines (33 loc) · 1.16 KB
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
36
37
38
import * as React from 'react';
import { FlashMessage, ReduxState } from '@/redux/types';
import { connect } from 'react-redux';
import MessageBox from '@/components/MessageBox';
type Props = Readonly<{
spacerClass?: string;
flashes: FlashMessage[];
}>;
class FlashMessageRender extends React.PureComponent<Props> {
render () {
if (this.props.flashes.length === 0) {
return null;
}
return (
<React.Fragment>
{
this.props.flashes.map((flash, index) => (
<React.Fragment key={flash.id || flash.type + flash.message}>
{index > 0 && <div className={this.props.spacerClass || 'mt-2'}></div>}
<MessageBox type={flash.type} title={flash.title}>
{flash.message}
</MessageBox>
</React.Fragment>
))
}
</React.Fragment>
);
}
}
const mapStateToProps = (state: ReduxState) => ({
flashes: state.flashes,
});
export default connect(mapStateToProps)(FlashMessageRender);