Add new message when camper is certified
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import React, { createClass } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import { History } from 'react-router';
|
import { History } from 'react-router';
|
||||||
import { contain } from 'thundercats-react';
|
import { contain } from 'thundercats-react';
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ import ShowJob from './ShowJob.jsx';
|
|||||||
import JobNotFound from './JobNotFound.jsx';
|
import JobNotFound from './JobNotFound.jsx';
|
||||||
import { isJobValid } from '../utils';
|
import { isJobValid } from '../utils';
|
||||||
|
|
||||||
function shouldShowJob(
|
function shouldShowApply(
|
||||||
{
|
{
|
||||||
isFrontEndCert: isFrontEndCertReq = false,
|
isFrontEndCert: isFrontEndCertReq = false,
|
||||||
isFullStackCert: isFullStackCertReq = false
|
isFullStackCert: isFullStackCertReq = false
|
||||||
@ -22,9 +22,12 @@ function shouldShowJob(
|
|||||||
|
|
||||||
function generateMessage(
|
function generateMessage(
|
||||||
{
|
{
|
||||||
isFrontEndCert: isFrontEndCertReq = false
|
isFrontEndCert: isFrontEndCertReq = false,
|
||||||
}, {
|
isFullStackCert: isFullStackCertReq = false
|
||||||
|
},
|
||||||
|
{
|
||||||
isFrontEndCert = false,
|
isFrontEndCert = false,
|
||||||
|
isFullStackCert = false,
|
||||||
isSignedIn = false
|
isSignedIn = false
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
@ -33,9 +36,19 @@ function generateMessage(
|
|||||||
return 'Must be signed in to apply';
|
return 'Must be signed in to apply';
|
||||||
}
|
}
|
||||||
if (isFrontEndCertReq && !isFrontEndCert) {
|
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(
|
export default contain(
|
||||||
@ -66,9 +79,16 @@ export default contain(
|
|||||||
return job.id !== id;
|
return job.id !== id;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createClass({
|
React.createClass({
|
||||||
displayName: 'Show',
|
displayName: 'Show',
|
||||||
|
|
||||||
|
propTypes: {
|
||||||
|
job: PropTypes.object,
|
||||||
|
isFullStackCert: PropTypes.bool,
|
||||||
|
isFrontEndCert: PropTypes.bool,
|
||||||
|
username: PropTypes.string
|
||||||
|
},
|
||||||
|
|
||||||
mixins: [History],
|
mixins: [History],
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -86,15 +106,28 @@ export default contain(
|
|||||||
job,
|
job,
|
||||||
username
|
username
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const isSignedIn = !!username;
|
|
||||||
|
|
||||||
if (!isJobValid(job)) {
|
if (!isJobValid(job)) {
|
||||||
return <JobNotFound />;
|
return <JobNotFound />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isSignedIn = !!username;
|
||||||
|
|
||||||
|
const showApply = shouldShowApply(
|
||||||
|
job,
|
||||||
|
{ isFrontEndCert, isFullStackCert }
|
||||||
|
);
|
||||||
|
|
||||||
|
const message = generateMessage(
|
||||||
|
job,
|
||||||
|
{ isFrontEndCert, isFullStackCert, isSignedIn }
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ShowJob
|
<ShowJob
|
||||||
message={ generateMessage(job, { isFrontEndCert, isSignedIn }) }
|
message={ message }
|
||||||
showApply={ shouldShowJob(job, { isFrontEndCert, isFullStackCert }) }
|
preview={ false }
|
||||||
|
showApply={ showApply }
|
||||||
{ ...this.props }/>
|
{ ...this.props }/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ export default React.createClass({
|
|||||||
job: PropTypes.object,
|
job: PropTypes.object,
|
||||||
params: PropTypes.object,
|
params: PropTypes.object,
|
||||||
showApply: PropTypes.bool,
|
showApply: PropTypes.bool,
|
||||||
|
preview: PropTypes.bool,
|
||||||
message: PropTypes.string
|
message: PropTypes.string
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -40,14 +41,14 @@ export default React.createClass({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
renderHowToApply(showApply, message, howToApply) {
|
renderHowToApply(showApply, preview, message, howToApply) {
|
||||||
if (!showApply) {
|
if (!showApply) {
|
||||||
return (
|
return (
|
||||||
<Row>
|
<Row>
|
||||||
<Col
|
<Col
|
||||||
md={ 6 }
|
md={ 6 }
|
||||||
mdOffset={ 3 }>
|
mdOffset={ 3 }>
|
||||||
<h4 className='bg-danger text-center'>{ message }</h4>
|
<h4 className='bg-info text-center'>{ message }</h4>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
@ -58,12 +59,14 @@ export default React.createClass({
|
|||||||
<Col
|
<Col
|
||||||
md={ 6 }
|
md={ 6 }
|
||||||
mdOffset={ 3 }>
|
mdOffset={ 3 }>
|
||||||
<bold>How do I apply?</bold>
|
<Well>
|
||||||
|
<bold>{ preview ? 'How do I apply?' : message }</bold>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<span dangerouslySetInnerHTML={{
|
<span dangerouslySetInnerHTML={{
|
||||||
__html: addATags(howToApply)
|
__html: addATags(howToApply)
|
||||||
}} />
|
}} />
|
||||||
|
</Well>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
@ -71,8 +74,9 @@ export default React.createClass({
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
showApply,
|
showApply = true,
|
||||||
message,
|
message,
|
||||||
|
preview = true,
|
||||||
job = {}
|
job = {}
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
@ -129,9 +133,7 @@ export default React.createClass({
|
|||||||
<p>{ description }</p>
|
<p>{ description }</p>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Well>
|
{ this.renderHowToApply(showApply, preview, message, howToApply) }
|
||||||
{ this.renderHowToApply(showApply, message, howToApply) }
|
|
||||||
</Well>
|
|
||||||
</Panel>
|
</Panel>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
Reference in New Issue
Block a user