fix(learn): remove cta and add current challenge button (#38807)
This commit is contained in:
@ -4,11 +4,13 @@ import { Link, Spacer, Loader, FullWidthRow } from '../helpers';
|
|||||||
import { Row, Col } from '@freecodecamp/react-bootstrap';
|
import { Row, Col } from '@freecodecamp/react-bootstrap';
|
||||||
import { apiLocation } from '../../../config/env.json';
|
import { apiLocation } from '../../../config/env.json';
|
||||||
import { randomQuote } from '../../utils/get-words';
|
import { randomQuote } from '../../utils/get-words';
|
||||||
|
import CurrentChallengeLink from '../helpers/CurrentChallengeLink';
|
||||||
|
|
||||||
import './intro.css';
|
import './intro.css';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
complete: PropTypes.bool,
|
complete: PropTypes.bool,
|
||||||
|
completedChallengeCount: PropTypes.number,
|
||||||
isSignedIn: PropTypes.bool,
|
isSignedIn: PropTypes.bool,
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
navigate: PropTypes.func,
|
navigate: PropTypes.func,
|
||||||
@ -24,6 +26,7 @@ function Intro({
|
|||||||
navigate,
|
navigate,
|
||||||
pending,
|
pending,
|
||||||
complete,
|
complete,
|
||||||
|
completedChallengeCount,
|
||||||
slug
|
slug
|
||||||
}) {
|
}) {
|
||||||
if (pending && !complete) {
|
if (pending && !complete) {
|
||||||
@ -57,6 +60,13 @@ function Intro({
|
|||||||
<Link className='btn btn-lg btn-primary btn-block' to='/settings'>
|
<Link className='btn btn-lg btn-primary btn-block' to='/settings'>
|
||||||
Update my account settings
|
Update my account settings
|
||||||
</Link>
|
</Link>
|
||||||
|
{completedChallengeCount > 0 ? (
|
||||||
|
<CurrentChallengeLink isLargeBtn={true}>
|
||||||
|
Go to current challenge
|
||||||
|
</CurrentChallengeLink>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
</FullWidthRow>
|
</FullWidthRow>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<Row className='text-center quote-partial'>
|
<Row className='text-center quote-partial'>
|
||||||
@ -72,6 +82,7 @@ function Intro({
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
|
{completedChallengeCount < 15 ? (
|
||||||
<Col sm={10} smOffset={1} xs={12}>
|
<Col sm={10} smOffset={1} xs={12}>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<h4>
|
<h4>
|
||||||
@ -79,6 +90,9 @@ function Intro({
|
|||||||
<Link to={slug}>start at the beginning</Link>.
|
<Link to={slug}>start at the beginning</Link>.
|
||||||
</h4>
|
</h4>
|
||||||
</Col>
|
</Col>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -11,7 +11,8 @@ const currentChallengeApi = '/challenges/current-challenge';
|
|||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
children: PropTypes.any,
|
children: PropTypes.any,
|
||||||
hardGoTo: PropTypes.func.isRequired
|
hardGoTo: PropTypes.func.isRequired,
|
||||||
|
isLargeBtn: PropTypes.bool
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = () => ({});
|
const mapStateToProps = () => ({});
|
||||||
@ -23,10 +24,16 @@ const createClickHandler = hardGoTo => e => {
|
|||||||
return hardGoTo(`${apiLocation}${currentChallengeApi}`);
|
return hardGoTo(`${apiLocation}${currentChallengeApi}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
function CurrentChallengeLink({ children, hardGoTo }) {
|
function CurrentChallengeLink({ children, hardGoTo, isLargeBtn }) {
|
||||||
|
let classNames;
|
||||||
|
if (isLargeBtn) {
|
||||||
|
classNames = 'btn btn-lg btn-primary btn-block';
|
||||||
|
} else {
|
||||||
|
classNames = 'btn btn-cta-big btn-primary btn-block';
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
className='btn-cta-big btn btn-primary btn-block'
|
className={classNames}
|
||||||
href={currentChallengeApi}
|
href={currentChallengeApi}
|
||||||
onClick={createClickHandler(hardGoTo)}
|
onClick={createClickHandler(hardGoTo)}
|
||||||
>
|
>
|
||||||
|
@ -51,7 +51,8 @@ const propTypes = {
|
|||||||
state: PropTypes.object,
|
state: PropTypes.object,
|
||||||
user: PropTypes.shape({
|
user: PropTypes.shape({
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
username: PropTypes.string
|
username: PropTypes.string,
|
||||||
|
completedChallengeCount: PropTypes.number
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ export const LearnPage = ({
|
|||||||
isSignedIn,
|
isSignedIn,
|
||||||
navigate,
|
navigate,
|
||||||
fetchState: { pending, complete },
|
fetchState: { pending, complete },
|
||||||
user: { name = '', username = '' },
|
user: { name = '', username = '', completedChallengeCount = 0 },
|
||||||
data: {
|
data: {
|
||||||
challengeNode: {
|
challengeNode: {
|
||||||
fields: { slug }
|
fields: { slug }
|
||||||
@ -86,6 +87,7 @@ export const LearnPage = ({
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Intro
|
<Intro
|
||||||
complete={complete}
|
complete={complete}
|
||||||
|
completedChallengeCount={completedChallengeCount}
|
||||||
isSignedIn={isSignedIn}
|
isSignedIn={isSignedIn}
|
||||||
name={name}
|
name={name}
|
||||||
navigate={navigate}
|
navigate={navigate}
|
||||||
|
Reference in New Issue
Block a user