mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 18:18:27 -05:00
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
import React, { Fragment, Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { connect } from 'react-redux';
|
|
|
|
import { fetchUser, isSignedInSelector, executeGA } from '../../redux';
|
|
import { createSelector } from 'reselect';
|
|
import Helmet from 'react-helmet';
|
|
|
|
const mapStateToProps = createSelector(isSignedInSelector, isSignedIn => ({
|
|
isSignedIn
|
|
}));
|
|
|
|
const mapDispatchToProps = { fetchUser, executeGA };
|
|
|
|
class CertificationLayout extends Component {
|
|
componentDidMount() {
|
|
const { isSignedIn, fetchUser, pathname } = this.props;
|
|
if (!isSignedIn) {
|
|
fetchUser();
|
|
}
|
|
this.props.executeGA({ type: 'page', data: pathname });
|
|
}
|
|
|
|
render() {
|
|
const { children } = this.props;
|
|
|
|
return (
|
|
<Fragment>
|
|
<Helmet bodyAttributes={{ class: 'light-palette' }} />
|
|
{children}
|
|
</Fragment>
|
|
);
|
|
}
|
|
}
|
|
|
|
CertificationLayout.displayName = 'CertificationLayout';
|
|
CertificationLayout.propTypes = {
|
|
children: PropTypes.any,
|
|
executeGA: PropTypes.func,
|
|
fetchUser: PropTypes.func.isRequired,
|
|
isSignedIn: PropTypes.bool,
|
|
pathname: PropTypes.string.isRequired
|
|
};
|
|
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps
|
|
)(CertificationLayout);
|