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 ReactMarkdown from "react-markdown"; 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 HintTutorialExists extends Component { constructor(props) { var previousPageWasAnotherDomain = props.pageVisits === 0; var userDoNotWantToSeeNews = window.localStorage.getItem("news") ? true : false; super(props); this.state = { open: userDoNotWantToSeeNews ? !userDoNotWantToSeeNews : previousPageWasAnotherDomain, }; } toggleDialog = () => { this.setState({ open: !this.state }); }; onChange = (e) => { if (e.target.checked) { window.localStorage.setItem("news", e.target.checked); } else { window.localStorage.removeItem("news"); } }; render() { return (
{Blockly.Msg.messages_newblockly_text}
this.onChange(e)} name="dialog" color="primary" /> } label={Blockly.Msg.labels_donotshowagain} />
); } } HintTutorialExists.propTypes = { pageVisits: PropTypes.number.isRequired, }; const mapStateToProps = (state) => ({ pageVisits: state.general.pageVisits, }); export default connect( mapStateToProps, null )(withStyles(styles, { withTheme: true })(HintTutorialExists));