From d01ce3bbc11fb0736ed3ad81e8565c6d23c342b9 Mon Sep 17 00:00:00 2001 From: Twaha Rahman <39026437+Twaha-Rahman@users.noreply.github.com> Date: Thu, 21 May 2020 18:39:48 +0600 Subject: [PATCH] fix(learn): remove cta and add current challenge button (#38807) --- client/src/components/Intro/index.js | 28 ++++++++++++++----- .../helpers/CurrentChallengeLink.js | 13 +++++++-- client/src/pages/learn.js | 6 ++-- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/client/src/components/Intro/index.js b/client/src/components/Intro/index.js index bd72c727fc..4187db4444 100644 --- a/client/src/components/Intro/index.js +++ b/client/src/components/Intro/index.js @@ -4,11 +4,13 @@ import { Link, Spacer, Loader, FullWidthRow } from '../helpers'; import { Row, Col } from '@freecodecamp/react-bootstrap'; import { apiLocation } from '../../../config/env.json'; import { randomQuote } from '../../utils/get-words'; +import CurrentChallengeLink from '../helpers/CurrentChallengeLink'; import './intro.css'; const propTypes = { complete: PropTypes.bool, + completedChallengeCount: PropTypes.number, isSignedIn: PropTypes.bool, name: PropTypes.string, navigate: PropTypes.func, @@ -24,6 +26,7 @@ function Intro({ navigate, pending, complete, + completedChallengeCount, slug }) { if (pending && !complete) { @@ -57,6 +60,13 @@ function Intro({ Update my account settings + {completedChallengeCount > 0 ? ( + + Go to current challenge + + ) : ( + '' + )} @@ -72,13 +82,17 @@ function Intro({ - - -

- If you are new to coding, we recommend you{' '} - start at the beginning. -

- + {completedChallengeCount < 15 ? ( + + +

+ If you are new to coding, we recommend you{' '} + start at the beginning. +

+ + ) : ( + '' + )}
); diff --git a/client/src/components/helpers/CurrentChallengeLink.js b/client/src/components/helpers/CurrentChallengeLink.js index f1869e578b..cbd3dabc2c 100644 --- a/client/src/components/helpers/CurrentChallengeLink.js +++ b/client/src/components/helpers/CurrentChallengeLink.js @@ -11,7 +11,8 @@ const currentChallengeApi = '/challenges/current-challenge'; const propTypes = { children: PropTypes.any, - hardGoTo: PropTypes.func.isRequired + hardGoTo: PropTypes.func.isRequired, + isLargeBtn: PropTypes.bool }; const mapStateToProps = () => ({}); @@ -23,10 +24,16 @@ const createClickHandler = hardGoTo => e => { 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 ( diff --git a/client/src/pages/learn.js b/client/src/pages/learn.js index 561f9fa685..2daebc5af8 100644 --- a/client/src/pages/learn.js +++ b/client/src/pages/learn.js @@ -51,7 +51,8 @@ const propTypes = { state: PropTypes.object, user: PropTypes.shape({ name: PropTypes.string, - username: PropTypes.string + username: PropTypes.string, + completedChallengeCount: PropTypes.number }) }; @@ -70,7 +71,7 @@ export const LearnPage = ({ isSignedIn, navigate, fetchState: { pending, complete }, - user: { name = '', username = '' }, + user: { name = '', username = '', completedChallengeCount = 0 }, data: { challengeNode: { fields: { slug } @@ -86,6 +87,7 @@ export const LearnPage = ({