fix: Pass username to Certifications to get user details

This commit is contained in:
Bouncey
2018-11-08 14:15:28 +00:00
committed by mrugesh mohapatra
parent d686b32d9d
commit 602065be0b
2 changed files with 42 additions and 34 deletions

View File

@ -157,7 +157,7 @@ function Profile({ user, isSessionUser }) {
/> />
</Grid> </Grid>
{showHeatMap ? <HeatMap calendar={calendar} streak={streak} /> : null} {showHeatMap ? <HeatMap calendar={calendar} streak={streak} /> : null}
{showCerts ? <Certifications /> : null} {showCerts ? <Certifications username={username} /> : null}
{showPortfolio ? <Portfolio portfolio={portfolio} /> : null} {showPortfolio ? <Portfolio portfolio={portfolio} /> : null}
{showTimeLine ? ( {showTimeLine ? (
<Timeline <Timeline

View File

@ -1,5 +1,6 @@
import React from 'react'; import React, { Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Link } from 'gatsby';
import { curry } from 'lodash'; import { curry } from 'lodash';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
@ -7,6 +8,7 @@ import { Button, Row, Col } from '@freecodecamp/react-bootstrap';
import { userByNameSelector } from '../../../redux'; import { userByNameSelector } from '../../../redux';
import FullWidthRow from '../../helpers/FullWidthRow'; import FullWidthRow from '../../helpers/FullWidthRow';
import { ButtonSpacer, Spacer } from '../../helpers';
const mapStateToProps = (state, props) => const mapStateToProps = (state, props) =>
createSelector( createSelector(
@ -112,18 +114,23 @@ const propTypes = {
function renderCertShow(username, cert) { function renderCertShow(username, cert) {
return cert.show ? ( return cert.show ? (
<Row key={cert.showURL}> <Fragment>
<Col sm={10} smPush={1}> <Row key={cert.showURL}>
<Button <Col sm={10} smPush={1}>
block={true} <Link to={`/certification/${username}/${cert.showURL}`}>
bsSize='lg' <Button
bsStyle='primary' block={true}
href={`/certification/${username}/${cert.showURL}`} bsSize='lg'
> bsStyle='primary'
View {cert.title} className='btn-invert'
</Button> >
</Col> View {cert.title}
</Row> </Button>
</Link>
</Col>
</Row>
<ButtonSpacer />
</Fragment>
) : null; ) : null;
} }
@ -136,26 +143,27 @@ function Certificates({
}) { }) {
const renderCertShowWithUsername = curry(renderCertShow)(username); const renderCertShowWithUsername = curry(renderCertShow)(username);
return ( return (
<FullWidthRow> <FullWidthRow>
<h2 className='text-center'>freeCodeCamp Certifications</h2> <h2 className='text-center'>freeCodeCamp Certifications</h2>
<br /> <br />
{hasModernCert ? ( {hasModernCert ? (
currentCerts.map(renderCertShowWithUsername) currentCerts.map(renderCertShowWithUsername).filter(Boolean)
) : ( ) : (
<p className='text-center'> <p className='text-center'>
No certifications have been earned under the current curriculum No certifications have been earned under the current curriculum
</p> </p>
)} )}
{hasLegacyCert ? ( {hasLegacyCert ? (
<div> <div>
<br /> <br />
<h3 className='text-center'>Legacy Certifications</h3> <h3 className='text-center'>Legacy Certifications</h3>
<br /> <br />
{legacyCerts.map(renderCertShowWithUsername)} {legacyCerts.map(renderCertShowWithUsername).filter(Boolean)}
</div> <Spacer size={2} />
) : null} </div>
<hr /> ) : null}
</FullWidthRow> <hr />
</FullWidthRow>
); );
} }