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
|
|
|
|
2019-12-02 15:48:53 +03:00
|
|
|
import ga from '../../analytics';
|
|
|
|
|
import { fetchUser, isSignedInSelector } from '../../redux';
|
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = createSelector(
|
|
|
|
|
isSignedInSelector,
|
|
|
|
|
isSignedIn => ({
|
|
|
|
|
isSignedIn
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { fetchUser };
|
|
|
|
|
|
|
|
|
|
class CertificationLayout extends Component {
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
const { isSignedIn, fetchUser, pathname } = this.props;
|
|
|
|
|
if (!isSignedIn) {
|
|
|
|
|
fetchUser();
|
|
|
|
|
}
|
|
|
|
|
ga.pageview(pathname);
|
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
|
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);
|