From c5843ec25247ce6c80d30275cd09271180cd920a Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Thu, 5 Nov 2015 14:52:04 -0800 Subject: [PATCH] Add new message when camper is certified --- common/app/routes/Jobs/components/Show.jsx | 53 +++++++++++++++---- common/app/routes/Jobs/components/ShowJob.jsx | 20 +++---- 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/common/app/routes/Jobs/components/Show.jsx b/common/app/routes/Jobs/components/Show.jsx index b15a6b154d..85034e3242 100644 --- a/common/app/routes/Jobs/components/Show.jsx +++ b/common/app/routes/Jobs/components/Show.jsx @@ -1,4 +1,4 @@ -import React, { createClass } from 'react'; +import React, { PropTypes } from 'react'; import { History } from 'react-router'; import { contain } from 'thundercats-react'; @@ -6,7 +6,7 @@ import ShowJob from './ShowJob.jsx'; import JobNotFound from './JobNotFound.jsx'; import { isJobValid } from '../utils'; -function shouldShowJob( +function shouldShowApply( { isFrontEndCert: isFrontEndCertReq = false, isFullStackCert: isFullStackCertReq = false @@ -22,9 +22,12 @@ function shouldShowJob( function generateMessage( { - isFrontEndCert: isFrontEndCertReq = false - }, { + isFrontEndCert: isFrontEndCertReq = false, + isFullStackCert: isFullStackCertReq = false + }, + { isFrontEndCert = false, + isFullStackCert = false, isSignedIn = false } ) { @@ -33,9 +36,19 @@ function generateMessage( return 'Must be signed in to apply'; } if (isFrontEndCertReq && !isFrontEndCert) { - return 'You must earn your Full Stack Certification to apply'; + return 'This employer requires Free Code Camp’s Front ' + + 'End Development Certification in order to apply'; } - return 'You must earn your Front End Certification to apply'; + if (isFullStackCertReq && !isFullStackCert) { + return 'This employer requires Free Code Camp’s Full ' + + 'Stack Development Certification in order to apply'; + } + if (isFrontEndCertReq && isFrontEndCertReq) { + return 'This employer requires the Front End Development Certification. ' + + "You've earned it, so feel free to apply."; + } + return 'This employer requires the Full Stack Development Certification. ' + + "You've earned it, so feel free to apply."; } export default contain( @@ -66,9 +79,16 @@ export default contain( return job.id !== id; } }, - createClass({ + React.createClass({ displayName: 'Show', + propTypes: { + job: PropTypes.object, + isFullStackCert: PropTypes.bool, + isFrontEndCert: PropTypes.bool, + username: PropTypes.string + }, + mixins: [History], componentDidMount() { @@ -86,15 +106,28 @@ export default contain( job, username } = this.props; - const isSignedIn = !!username; if (!isJobValid(job)) { return ; } + + const isSignedIn = !!username; + + const showApply = shouldShowApply( + job, + { isFrontEndCert, isFullStackCert } + ); + + const message = generateMessage( + job, + { isFrontEndCert, isFullStackCert, isSignedIn } + ); + return ( ); } diff --git a/common/app/routes/Jobs/components/ShowJob.jsx b/common/app/routes/Jobs/components/ShowJob.jsx index ca1fd6565a..db9cf511e5 100644 --- a/common/app/routes/Jobs/components/ShowJob.jsx +++ b/common/app/routes/Jobs/components/ShowJob.jsx @@ -24,6 +24,7 @@ export default React.createClass({ job: PropTypes.object, params: PropTypes.object, showApply: PropTypes.bool, + preview: PropTypes.bool, message: PropTypes.string }, @@ -40,39 +41,42 @@ export default React.createClass({ ); }, - renderHowToApply(showApply, message, howToApply) { + renderHowToApply(showApply, preview, message, howToApply) { if (!showApply) { return ( -

{ message }

+

{ message }

); } return ( - + - How do I apply? + + { preview ? 'How do I apply?' : message }

+
-
+
); }, render() { const { - showApply, + showApply = true, message, + preview = true, job = {} } = this.props; @@ -129,9 +133,7 @@ export default React.createClass({

{ description }

- - { this.renderHowToApply(showApply, message, howToApply) } - + { this.renderHowToApply(showApply, preview, message, howToApply) }