2021-08-02 15:39:40 +02:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import Helmet from 'react-helmet';
|
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 { createSelector } from 'reselect';
|
2021-08-02 15:39:40 +02:00
|
|
|
import { fetchUser, isSignedInSelector, executeGA } from '../../redux';
|
2019-12-02 15:48:53 +03:00
|
|
|
|
2021-09-23 00:15:16 -07:00
|
|
|
interface CertificationProps {
|
|
|
|
|
children?: React.ReactNode;
|
|
|
|
|
executeGA?: (args: { type: string; data: string }) => void;
|
|
|
|
|
fetchUser: () => void;
|
|
|
|
|
isSignedIn?: boolean;
|
|
|
|
|
pathname: string;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-11 00:31:46 +05:30
|
|
|
const mapStateToProps = createSelector(isSignedInSelector, isSignedIn => ({
|
|
|
|
|
isSignedIn
|
|
|
|
|
}));
|
2019-12-02 15:48:53 +03:00
|
|
|
|
2020-02-04 08:43:56 +03:00
|
|
|
const mapDispatchToProps = { fetchUser, executeGA };
|
2019-12-02 15:48:53 +03:00
|
|
|
|
2021-09-23 00:15:16 -07:00
|
|
|
class CertificationLayout extends Component<CertificationProps> {
|
|
|
|
|
static displayName = 'CertificationLayout';
|
2019-12-02 15:48:53 +03:00
|
|
|
componentDidMount() {
|
|
|
|
|
const { isSignedIn, fetchUser, pathname } = this.props;
|
|
|
|
|
if (!isSignedIn) {
|
|
|
|
|
fetchUser();
|
|
|
|
|
}
|
2021-09-23 00:15:16 -07:00
|
|
|
if (this.props.executeGA) {
|
|
|
|
|
this.props.executeGA({ type: 'page', data: pathname });
|
|
|
|
|
}
|
2019-12-02 15:48:53 +03:00
|
|
|
}
|
2020-09-24 07:03:11 -05:00
|
|
|
|
2021-09-23 00:15:16 -07:00
|
|
|
render(): JSX.Element {
|
2020-09-24 07:03:11 -05:00
|
|
|
const { children } = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
2021-07-09 10:50:11 +03:00
|
|
|
<>
|
2020-10-12 00:19:13 +05:30
|
|
|
<Helmet bodyAttributes={{ class: 'light-palette' }} />
|
2020-09-24 07:03:11 -05:00
|
|
|
{children}
|
2021-07-09 10:50:11 +03:00
|
|
|
</>
|
2020-09-24 07:03:11 -05:00
|
|
|
);
|
2019-12-02 15:48:53 +03:00
|
|
|
}
|
2019-02-22 20:36:47 +05:30
|
|
|
}
|
|
|
|
|
|
2019-12-02 15:48:53 +03:00
|
|
|
export default connect(
|
|
|
|
|
mapStateToProps,
|
|
|
|
|
mapDispatchToProps
|
|
|
|
|
)(CertificationLayout);
|