import React, { Component } from "react"; import PropTypes from "prop-types"; import { connect } from "react-redux"; import Dialog from "./Dialog"; import { withStyles } from "@material-ui/core/styles"; import Checkbox from "@material-ui/core/Checkbox"; import FormControlLabel from "@material-ui/core/FormControlLabel"; import * as Blockly from "blockly"; import { IconButton, Grid, Avatar, Typography } from "@material-ui/core"; import { setBoard } from "../actions/boardAction"; const styles = (theme) => ({ link: { color: theme.palette.primary.main, textDecoration: "none", "&:hover": { color: theme.palette.primary.main, textDecoration: `underline`, }, }, label: { fontSize: "0.9rem", color: "grey", }, }); class DeviceSeclection extends Component { constructor(props) { var previousPageWasAnotherDomain = props.pageVisits === 0; var userWantToKeepBoard = window.localStorage.getItem("board") ? true : false; super(props); this.state = { open: userWantToKeepBoard ? !userWantToKeepBoard : previousPageWasAnotherDomain, selectedBoard : "", saveSettings: false, }; } toggleDialog = () => { this.setState({ open: !this.state }); if(this.state.saveSettings){ window.localStorage.setItem("board", this.state.selectedBoard) } this.props.setBoard(this.state.selectedBoard) }; onChange = (e) => { if (e.target.checked) { this.setState({ saveSettings: true}); } else { this.setState({ saveSettings: false}); } }; onclick = (e, value) => { console.log(e, value) this.setState({selectedBoard: value}) }; render() { return (
this.onclick(e, "mcu")}>

senseBox MCU

{/* this.onclick(e, "esp")}>

Sensebox ESP

*/} this.onclick(e, "mini")}>

senseBox MCU:mini

this.onChange(e)} name="dialog" color="primary" /> } label={Blockly.Msg.deviceselection_keep_selection} /> {Blockly.Msg.deviceselection_footnote} Arduino UNO {Blockly.Msg.deviceselection_footnote_02} senseBox MCU
); } } DeviceSeclection.propTypes = { pageVisits: PropTypes.number.isRequired, }; const mapStateToProps = (state) => ({ pageVisits: state.general.pageVisits, selectedBoard: state.board.board }); export default connect( mapStateToProps, {setBoard} )(withStyles(styles, { withTheme: true })(DeviceSeclection));