feat(client): ts-migrate (/client/src/components/layouts/Certification.js) (#42939)

* change name to certification.tsx

* migrate certification.js to ts

* update ceritification import in index and fix prettier errors

* Update client/src/components/layouts/certification.tsx

Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>

* Update client/src/components/layouts/certification.tsx

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* Update client/src/components/layouts/certification.tsx

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* Update client/src/components/layouts/certification.tsx

Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>

* fix: reorder imports

Co-authored-by: Raymen Deol <raymen.deol@outlook.com>
Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Raymen Deol
2021-09-23 00:15:16 -07:00
committed by GitHub
parent 5f93847770
commit 0036aa8969
2 changed files with 15 additions and 14 deletions

View File

@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
@ -6,22 +5,33 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { fetchUser, isSignedInSelector, executeGA } from '../../redux'; import { fetchUser, isSignedInSelector, executeGA } from '../../redux';
interface CertificationProps {
children?: React.ReactNode;
executeGA?: (args: { type: string; data: string }) => void;
fetchUser: () => void;
isSignedIn?: boolean;
pathname: string;
}
const mapStateToProps = createSelector(isSignedInSelector, isSignedIn => ({ const mapStateToProps = createSelector(isSignedInSelector, isSignedIn => ({
isSignedIn isSignedIn
})); }));
const mapDispatchToProps = { fetchUser, executeGA }; const mapDispatchToProps = { fetchUser, executeGA };
class CertificationLayout extends Component { class CertificationLayout extends Component<CertificationProps> {
static displayName = 'CertificationLayout';
componentDidMount() { componentDidMount() {
const { isSignedIn, fetchUser, pathname } = this.props; const { isSignedIn, fetchUser, pathname } = this.props;
if (!isSignedIn) { if (!isSignedIn) {
fetchUser(); fetchUser();
} }
this.props.executeGA({ type: 'page', data: pathname }); if (this.props.executeGA) {
this.props.executeGA({ type: 'page', data: pathname });
}
} }
render() { render(): JSX.Element {
const { children } = this.props; const { children } = this.props;
return ( return (
@ -33,15 +43,6 @@ class CertificationLayout extends Component {
} }
} }
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( export default connect(
mapStateToProps, mapStateToProps,
mapDispatchToProps mapDispatchToProps

View File

@ -1,3 +1,3 @@
export { default as CertificationLayout } from './Certification'; export { default as CertificationLayout } from './certification';
export { default as DefaultLayout } from './Default'; export { default as DefaultLayout } from './Default';
export { default as LearnLayout } from './learn'; export { default as LearnLayout } from './learn';