1 import React from 'react'
2 import styles from './Flash.scss'
10 'CREATE_REGISTER_ACCOUNT',
15 class Flash extends React.Component {
18 Object.keys(props.messages).forEach(key => {
19 const item = props.messages[key]
20 if (!item.displayed) {
21 this.props.markFlashDisplayed(key)
23 this.props.dismissFlash(key)
29 componentWillReceiveProps(nextProps) {
30 Object.keys(nextProps.messages).forEach(key => {
31 const item = nextProps.messages[key]
32 if (!item.displayed) {
33 this.props.markFlashDisplayed(key)
35 this.props.dismissFlash(key)
43 if (!this.props.messages || this.props.hideFlash) {
47 const t = this.props.t
49 // Flash messages are stored in an objecty key with a random UUID. If
50 // multiple messages are displayed, we rely on the browser maintaining
51 // object inerstion order of keys to display messages in the order they
53 Object.keys(this.props.messages).forEach(key => {
54 const item = this.props.messages[key]
55 const messageKey = (messageLabel).filter(key => key === item.message)
56 const messageContent = messageKey.length === 0? item.message: <p>{t(`message.${messageKey}`)}</p>
58 <div className={`${styles.alert} ${styles[item.type]} ${styles.main}`} key={key}>
59 <div className={styles.content}>
60 {item.title && <div><strong>{item.title}</strong></div>}
64 <button type='button' className='close' onClick={() => this.props.dismissFlash(key)}>
71 <div className={this.props.className}>
78 import { connect } from 'react-redux'
79 import {withNamespaces} from 'react-i18next'
81 const mapStateToProps = (state) => ({
82 // hideFlash: state.tutorial.isShowing && state.routing.locationBeforeTransitions.pathname.includes(state.tutorial.route)
86 export default connect(
88 )(withNamespaces('translations') (Flash))