import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { workspaceName } from '../../actions/workspaceActions'; import BlocklyWindow from '../Blockly/BlocklyWindow'; import CodeViewer from '../CodeViewer'; import WorkspaceFunc from '../WorkspaceFunc'; import withWidth, { isWidthDown } from '@material-ui/core/withWidth'; import Grid from '@material-ui/core/Grid'; import Card from '@material-ui/core/Card'; import Typography from '@material-ui/core/Typography'; class Assessment extends Component { componentDidMount() { // alert(this.props.name); this.props.workspaceName(this.props.name); } componentDidUpdate(props) { if (props.name !== this.props.name) { // alert(this.props.name); this.props.workspaceName(this.props.name); } } render() { var tutorialId = this.props.currentTutorialId; var currentTask = this.props.step; var status = this.props.status.filter(status => status.id === tutorialId)[0]; var taskIndex = status.tasks.findIndex(task => task.id === currentTask.id); var statusTask = status.tasks[taskIndex]; return (
{currentTask.headline}
Arbeitsauftrag {currentTask.text}
); }; } Assessment.propTypes = { currentTutorialId: PropTypes.number, status: PropTypes.array.isRequired, change: PropTypes.number.isRequired, workspaceName: PropTypes.func.isRequired }; const mapStateToProps = state => ({ change: state.tutorial.change, status: state.tutorial.status, currentTutorialId: state.tutorial.currentId }); export default connect(mapStateToProps, { workspaceName })(withWidth()(Assessment));