| 
									
										
										
										
											2019-12-02 15:48:53 +03:00
										 |  |  | import React, { Fragment, Component } from 'react'; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:36:47 +05:30
										 |  |  | import PropTypes from 'prop-types'; | 
					
						
							| 
									
										
										
										
											2019-12-02 15:48:53 +03:00
										 |  |  | import { connect } from 'react-redux'; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:36:47 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-04 08:43:56 +03:00
										 |  |  | import { fetchUser, isSignedInSelector, executeGA } from '../../redux'; | 
					
						
							| 
									
										
										
										
											2019-12-02 15:48:53 +03:00
										 |  |  | import { createSelector } from 'reselect'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const mapStateToProps = createSelector( | 
					
						
							|  |  |  |   isSignedInSelector, | 
					
						
							|  |  |  |   isSignedIn => ({ | 
					
						
							|  |  |  |     isSignedIn | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-04 08:43:56 +03:00
										 |  |  | const mapDispatchToProps = { fetchUser, executeGA }; | 
					
						
							| 
									
										
										
										
											2019-12-02 15:48:53 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | class CertificationLayout extends Component { | 
					
						
							|  |  |  |   componentDidMount() { | 
					
						
							|  |  |  |     const { isSignedIn, fetchUser, pathname } = this.props; | 
					
						
							|  |  |  |     if (!isSignedIn) { | 
					
						
							|  |  |  |       fetchUser(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-02-04 08:43:56 +03:00
										 |  |  |     this.props.executeGA({ type: 'page', data: pathname }); | 
					
						
							| 
									
										
										
										
											2019-12-02 15:48:53 +03:00
										 |  |  |   } | 
					
						
							|  |  |  |   render() { | 
					
						
							|  |  |  |     return <Fragment>{this.props.children}</Fragment>; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-02-22 20:36:47 +05:30
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CertificationLayout.displayName = 'CertificationLayout'; | 
					
						
							| 
									
										
										
										
											2019-12-02 15:48:53 +03:00
										 |  |  | CertificationLayout.propTypes = { | 
					
						
							|  |  |  |   children: PropTypes.any, | 
					
						
							| 
									
										
										
										
											2020-02-04 08:43:56 +03:00
										 |  |  |   executeGA: PropTypes.func, | 
					
						
							| 
									
										
										
										
											2019-12-02 15:48:53 +03:00
										 |  |  |   fetchUser: PropTypes.func.isRequired, | 
					
						
							|  |  |  |   isSignedIn: PropTypes.bool, | 
					
						
							|  |  |  |   pathname: PropTypes.string.isRequired | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-02-22 20:36:47 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-02 15:48:53 +03:00
										 |  |  | export default connect( | 
					
						
							|  |  |  |   mapStateToProps, | 
					
						
							|  |  |  |   mapDispatchToProps | 
					
						
							|  |  |  | )(CertificationLayout); |