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 ? (
<Fragment>
<Row key={cert.showURL}> <Row key={cert.showURL}>
<Col sm={10} smPush={1}> <Col sm={10} smPush={1}>
<Link to={`/certification/${username}/${cert.showURL}`}>
<Button <Button
block={true} block={true}
bsSize='lg' bsSize='lg'
bsStyle='primary' bsStyle='primary'
href={`/certification/${username}/${cert.showURL}`} className='btn-invert'
> >
View {cert.title} View {cert.title}
</Button> </Button>
</Link>
</Col> </Col>
</Row> </Row>
<ButtonSpacer />
</Fragment>
) : null; ) : null;
} }
@ -140,7 +147,7 @@ function Certificates({
<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
@ -151,7 +158,8 @@ function Certificates({
<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)}
<Spacer size={2} />
</div> </div>
) : null} ) : null}
<hr /> <hr />