| 
									
										
										
										
											2018-01-04 09:18:20 -08:00
										 |  |  | import React from 'react'; | 
					
						
							| 
									
										
										
										
											2018-01-04 16:24:03 -08:00
										 |  |  | import PropTypes from 'prop-types'; | 
					
						
							| 
									
										
										
										
											2018-01-04 09:18:20 -08:00
										 |  |  | import { CloseButton } from 'react-bootstrap'; | 
					
						
							| 
									
										
										
										
											2018-01-04 16:24:03 -08:00
										 |  |  | import { connect } from 'react-redux'; | 
					
						
							| 
									
										
										
										
											2018-01-04 09:18:20 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | import ns from './ns.json'; | 
					
						
							| 
									
										
										
										
											2018-01-29 11:34:44 -08:00
										 |  |  | import { alertTypes } from '../../utils/flash.js'; | 
					
						
							| 
									
										
										
										
											2018-01-04 16:39:43 -08:00
										 |  |  | import { | 
					
						
							|  |  |  |   latestMessageSelector, | 
					
						
							|  |  |  |   clickOnClose | 
					
						
							|  |  |  | } from './redux'; | 
					
						
							| 
									
										
										
										
											2018-01-04 09:18:20 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-04 16:24:03 -08:00
										 |  |  | const propTypes = { | 
					
						
							| 
									
										
										
										
											2018-01-04 16:39:43 -08:00
										 |  |  |   clickOnClose: PropTypes.func.isRequired, | 
					
						
							| 
									
										
										
										
											2018-01-26 19:15:23 -08:00
										 |  |  |   message: PropTypes.string, | 
					
						
							|  |  |  |   type: PropTypes.oneOf(Object.keys(alertTypes)) | 
					
						
							| 
									
										
										
										
											2018-01-04 16:24:03 -08:00
										 |  |  | }; | 
					
						
							|  |  |  | const mapStateToProps = latestMessageSelector; | 
					
						
							| 
									
										
										
										
											2018-01-04 16:39:43 -08:00
										 |  |  | const mapDispatchToProps = { clickOnClose }; | 
					
						
							| 
									
										
										
										
											2018-01-04 16:24:03 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-26 19:15:23 -08:00
										 |  |  | export function Flash({ type, clickOnClose, message }) { | 
					
						
							| 
									
										
										
										
											2018-01-04 16:24:03 -08:00
										 |  |  |   if (!message) { | 
					
						
							|  |  |  |     return null; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-01-04 09:18:20 -08:00
										 |  |  |   return ( | 
					
						
							| 
									
										
										
										
											2018-01-26 19:15:23 -08:00
										 |  |  |     <div className={`${ns}-container bg-${type}`}> | 
					
						
							| 
									
										
										
										
											2018-01-04 09:18:20 -08:00
										 |  |  |       <div className={`${ns}-content`}> | 
					
						
							| 
									
										
										
										
											2018-01-09 14:17:43 -08:00
										 |  |  |         <p className={ `${ns}-message` }> | 
					
						
							| 
									
										
										
										
											2018-01-04 16:24:03 -08:00
										 |  |  |           { message } | 
					
						
							| 
									
										
										
										
											2018-01-09 14:17:43 -08:00
										 |  |  |         </p> | 
					
						
							| 
									
										
										
										
											2018-01-04 16:39:43 -08:00
										 |  |  |         <CloseButton onClick={ clickOnClose }/> | 
					
						
							| 
									
										
										
										
											2018-01-04 09:18:20 -08:00
										 |  |  |       </div> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Flash.displayName = 'Flash'; | 
					
						
							|  |  |  | Flash.propTypes = propTypes; | 
					
						
							| 
									
										
										
										
											2018-01-04 16:24:03 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default connect( | 
					
						
							|  |  |  |   mapStateToProps, | 
					
						
							|  |  |  |   mapDispatchToProps | 
					
						
							|  |  |  | )(Flash); |