import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { createSelector } from 'reselect'; import { connect } from 'react-redux'; import format from 'date-fns/format'; import { find, reverse, sortBy } from 'lodash'; import { Button, Modal, Table } from 'react-bootstrap'; import { challengeIdToNameMapSelector } from '../../../entities'; import { userByNameSelector } from '../../../redux'; import { homeURL } from '../../../../utils/constantStrings.json'; import blockNameify from '../../../utils/blockNameify'; import { Link } from '../../../Router'; import { FullWidthRow } from '../../../helperComponents'; import SolutionViewer from '../../Settings/components/SolutionViewer.jsx'; const mapStateToProps = createSelector( challengeIdToNameMapSelector, userByNameSelector, ( idToNameMap, { completedChallenges: completedMap = [], username } ) => ({ completedMap, idToNameMap, username }) ); const propTypes = { completedMap: PropTypes.arrayOf( PropTypes.shape({ id: PropTypes.string, completedDate: PropTypes.number, challengeType: PropTypes.number, solution: PropTypes.string, files: PropTypes.shape({ ext: PropTypes.string, contents: PropTypes.string }) }) ), idToNameMap: PropTypes.objectOf(PropTypes.string), username: PropTypes.string }; class Timeline extends PureComponent { constructor(props) { super(props); this.state = { solutionToView: null, solutionOpen: false }; this.closeSolution = this.closeSolution.bind(this); this.renderCompletion = this.renderCompletion.bind(this); this.viewSolution = this.viewSolution.bind(this); } renderCompletion(completed) { const { idToNameMap } = this.props; const { id, completedDate, solution, files } = completed; const challengeDashedName = idToNameMap[id]; return (
No challenges have been completed yet. Get started here.
:| Challenge | First Completed |
|---|