CHORE: migrate intro component (#43784)
* migrate intro component * Update client/src/components/Intro/index.tsx Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com> * Update client/src/components/Intro/index.tsx Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com> Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
This commit is contained in:
@ -3,11 +3,11 @@ import { Provider } from 'react-redux';
|
|||||||
import renderer from 'react-test-renderer';
|
import renderer from 'react-test-renderer';
|
||||||
import { createStore } from '../../redux/createStore';
|
import { createStore } from '../../redux/createStore';
|
||||||
|
|
||||||
import Intro from './';
|
import Intro from '.';
|
||||||
|
|
||||||
jest.mock('../../analytics');
|
jest.mock('../../analytics');
|
||||||
|
|
||||||
function rendererCreateWithRedux(ui) {
|
function rendererCreateWithRedux(ui: JSX.Element) {
|
||||||
return renderer.create(<Provider store={createStore()}>{ui}</Provider>);
|
return renderer.create(<Provider store={createStore()}>{ui}</Provider>);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ const loggedInProps = {
|
|||||||
complete: true,
|
complete: true,
|
||||||
isSignedIn: true,
|
isSignedIn: true,
|
||||||
name: 'Development User',
|
name: 'Development User',
|
||||||
navigate: () => {},
|
navigate: () => jest.fn(),
|
||||||
pending: false,
|
pending: false,
|
||||||
slug: '/',
|
slug: '/',
|
||||||
username: 'DevelopmentUser'
|
username: 'DevelopmentUser'
|
||||||
@ -67,7 +67,7 @@ const loggedOutProps = {
|
|||||||
complete: true,
|
complete: true,
|
||||||
isSignedIn: false,
|
isSignedIn: false,
|
||||||
name: '',
|
name: '',
|
||||||
navigate: () => {},
|
navigate: () => jest.fn(),
|
||||||
pending: false,
|
pending: false,
|
||||||
slug: '/',
|
slug: '/',
|
||||||
username: ''
|
username: ''
|
@ -1,4 +1,3 @@
|
|||||||
import PropTypes from 'prop-types';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import { randomQuote } from '../../utils/get-words';
|
import { randomQuote } from '../../utils/get-words';
|
||||||
@ -9,24 +8,24 @@ import IntroDescription from './components/IntroDescription';
|
|||||||
|
|
||||||
import './intro.css';
|
import './intro.css';
|
||||||
|
|
||||||
const propTypes = {
|
interface IntroProps {
|
||||||
complete: PropTypes.bool,
|
complete?: boolean;
|
||||||
completedChallengeCount: PropTypes.number,
|
completedChallengeCount?: number;
|
||||||
isSignedIn: PropTypes.bool,
|
isSignedIn?: boolean;
|
||||||
name: PropTypes.string,
|
name?: string;
|
||||||
pending: PropTypes.bool,
|
pending?: boolean;
|
||||||
slug: PropTypes.string,
|
slug?: string;
|
||||||
username: PropTypes.string
|
username?: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
function Intro({
|
const Intro = ({
|
||||||
isSignedIn,
|
isSignedIn,
|
||||||
name,
|
name,
|
||||||
pending,
|
pending,
|
||||||
complete,
|
complete,
|
||||||
completedChallengeCount,
|
completedChallengeCount,
|
||||||
slug
|
slug
|
||||||
}) {
|
}: IntroProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
if (pending && !complete) {
|
if (pending && !complete) {
|
||||||
return (
|
return (
|
||||||
@ -48,7 +47,7 @@ function Intro({
|
|||||||
</h1>
|
</h1>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<FullWidthRow>
|
<FullWidthRow>
|
||||||
{completedChallengeCount > 0 ? (
|
{completedChallengeCount && completedChallengeCount > 0 ? (
|
||||||
<CurrentChallengeLink isLargeBtn={true}>
|
<CurrentChallengeLink isLargeBtn={true}>
|
||||||
{t('buttons.current-challenge')}
|
{t('buttons.current-challenge')}
|
||||||
</CurrentChallengeLink>
|
</CurrentChallengeLink>
|
||||||
@ -67,7 +66,7 @@ function Intro({
|
|||||||
</span>
|
</span>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</div>
|
</div>
|
||||||
{completedChallengeCount < 15 ? (
|
{completedChallengeCount && slug && completedChallengeCount < 15 ? (
|
||||||
<div className='intro-description'>
|
<div className='intro-description'>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<p>
|
<p>
|
||||||
@ -94,9 +93,8 @@ function Intro({
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
Intro.propTypes = propTypes;
|
|
||||||
Intro.displayName = 'Intro';
|
Intro.displayName = 'Intro';
|
||||||
|
|
||||||
export default Intro;
|
export default Intro;
|
Reference in New Issue
Block a user