fix: make challenge links on profile page work (#36701)
* fix: make challenge links on profile page work * fix: filter out certs from displaying * fix: add suggested changes
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import { Observable } from 'rx';
|
import { Observable } from 'rx';
|
||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
|
import { dasherize } from '../utils';
|
||||||
|
|
||||||
export default function(Challenge) {
|
export default function(Challenge) {
|
||||||
let challengeIdToNameMap;
|
let challengeIdToNameMap;
|
||||||
@ -20,8 +21,11 @@ export default function(Challenge) {
|
|||||||
throw Error(err);
|
throw Error(err);
|
||||||
}
|
}
|
||||||
challengeIdToNameMap = challenges.reduce((map, challenge) => {
|
challengeIdToNameMap = challenges.reduce((map, challenge) => {
|
||||||
const { id, title } = challenge;
|
const { id, block, dashedName, title, superBlock } = challenge;
|
||||||
map[id] = title;
|
map[id] = {
|
||||||
|
challengeTitle: title,
|
||||||
|
challengePath: `${superBlock}/${dasherize(block)}/${dashedName}`
|
||||||
|
};
|
||||||
return map;
|
return map;
|
||||||
}, {});
|
}, {});
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,6 @@ import {
|
|||||||
challengeIdToNameMapSelector,
|
challengeIdToNameMapSelector,
|
||||||
fetchIdToNameMap
|
fetchIdToNameMap
|
||||||
} from '../../../templates/Challenges/redux';
|
} from '../../../templates/Challenges/redux';
|
||||||
import { blockNameify } from '../../../../utils/blockNameify';
|
|
||||||
import { FullWidthRow } from '../../helpers';
|
import { FullWidthRow } from '../../helpers';
|
||||||
import SolutionViewer from '../../settings/SolutionViewer';
|
import SolutionViewer from '../../settings/SolutionViewer';
|
||||||
|
|
||||||
@ -42,7 +41,12 @@ const propTypes = {
|
|||||||
})
|
})
|
||||||
),
|
),
|
||||||
fetchIdToNameMap: PropTypes.func.isRequired,
|
fetchIdToNameMap: PropTypes.func.isRequired,
|
||||||
idToNameMap: PropTypes.objectOf(PropTypes.string),
|
idToNameMap: PropTypes.objectOf(
|
||||||
|
PropTypes.shape({
|
||||||
|
challengePath: PropTypes.string,
|
||||||
|
challengeTitle: PropTypes.string
|
||||||
|
})
|
||||||
|
),
|
||||||
username: PropTypes.string
|
username: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,13 +74,11 @@ class Timeline extends Component {
|
|||||||
renderCompletion(completed) {
|
renderCompletion(completed) {
|
||||||
const { idToNameMap } = this.props;
|
const { idToNameMap } = this.props;
|
||||||
const { id, completedDate } = completed;
|
const { id, completedDate } = completed;
|
||||||
const challengeDashedName = idToNameMap[id];
|
const { challengeTitle, challengePath } = idToNameMap[id];
|
||||||
return (
|
return (
|
||||||
<tr key={id}>
|
<tr key={id}>
|
||||||
<td>
|
<td>
|
||||||
<a href={`/challenges/${challengeDashedName}`}>
|
<Link to={`/learn/${challengePath}`}>{challengeTitle}</Link>
|
||||||
{blockNameify(challengeDashedName)}
|
|
||||||
</a>
|
|
||||||
</td>
|
</td>
|
||||||
<td className='text-center'>
|
<td className='text-center'>
|
||||||
<time dateTime={format(completedDate, 'YYYY-MM-DDTHH:MM:SSZ')}>
|
<time dateTime={format(completedDate, 'YYYY-MM-DDTHH:MM:SSZ')}>
|
||||||
@ -128,9 +130,11 @@ class Timeline extends Component {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{reverse(
|
{reverse(
|
||||||
sortBy(completedMap, ['completedDate']).filter(
|
sortBy(completedMap, ['completedDate']).filter(challenge => {
|
||||||
({ id }) => id in idToNameMap
|
return (
|
||||||
)
|
challenge.challengeType !== 7 && idToNameMap[challenge.id]
|
||||||
|
);
|
||||||
|
})
|
||||||
).map(this.renderCompletion)}
|
).map(this.renderCompletion)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</Table>
|
</Table>
|
||||||
@ -143,7 +147,7 @@ class Timeline extends Component {
|
|||||||
>
|
>
|
||||||
<Modal.Header closeButton={true}>
|
<Modal.Header closeButton={true}>
|
||||||
<Modal.Title id='contained-modal-title'>
|
<Modal.Title id='contained-modal-title'>
|
||||||
{`${username}'s Solution to ${blockNameify(idToNameMap[id])}`}
|
{`${username}'s Solution to ${idToNameMap[id].challengeTitle}`}
|
||||||
</Modal.Title>
|
</Modal.Title>
|
||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
<Modal.Body>
|
<Modal.Body>
|
||||||
|
Reference in New Issue
Block a user