import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import clsx from 'clsx'; import { withRouter, Link } from 'react-router-dom'; import { fade } from '@material-ui/core/styles/colorManipulator'; import { withStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; import List from '@material-ui/core/List'; import Tooltip from '@material-ui/core/Tooltip'; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCheck, faTimes } from "@fortawesome/free-solid-svg-icons"; const styles = theme => ({ outerDiv: { width: '50px', height: '50px', position: 'absolute', color: fade(theme.palette.secondary.main, 0.6) }, outerDivError: { stroke: fade(theme.palette.error.dark, 0.6), color: fade(theme.palette.error.dark, 0.6) }, outerDivSuccess: { stroke: fade(theme.palette.primary.main, 0.6), color: fade(theme.palette.primary.main, 0.6) }, outerDivOther: { stroke: fade(theme.palette.secondary.main, 0.6) }, innerDiv: { width: 'inherit', height: 'inherit', display: 'table-cell', verticalAlign: 'middle', textAlign: 'center' }, link: { color: theme.palette.text.primary, position: 'relative', height: '50px', display: 'flex', margin: '5px 0 5px 10px', textDecoration: 'none' }, hoverLink: { '&:hover': { background: fade(theme.palette.secondary.main, 0.5), borderRadius: '0 25px 25px 0 ' } } }); class Requirement extends Component { render() { var tutorialIds = this.props.tutorialIds; return (
Bevor du mit diesem Tutorial fortfährst solltest du folgende Tutorials erfolgreich abgeschlossen haben: {tutorialIds.map((tutorialId, i) => { // title must be provided together with ids // var title = tutorials.filter(tutorial => tutorial.id === tutorialId)[0].title; var status = this.props.status.filter(status => status.id === tutorialId)[0]; var tasks = status.tasks; var error = status.tasks.filter(task => task.type === 'error').length > 0; var success = status.tasks.filter(task => task.type === 'success').length / tasks.length var tutorialStatus = success === 1 ? 'Success' : error ? 'Error' : 'Other'; return (
{error || success === 1 ? : } {success < 1 && !error ? : null}
{error || success === 1 ? : 0 ? this.props.classes.outerDivSuccess : {}}>{Math.round(success * 100)}% }
{/*title*/}Name hinzufügen über Datenbankeintrag
) } )}
); }; } Requirement.propTypes = { status: PropTypes.array.isRequired, change: PropTypes.number.isRequired, }; const mapStateToProps = state => ({ change: state.tutorial.change, status: state.tutorial.status }); export default connect(mapStateToProps, null)(withStyles(styles, { withTheme: true })(withRouter(Requirement)));