From 53f1ddb2f8449e00059a3168132c56ed4508148a Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Sun, 12 Aug 2018 11:22:32 -0400 Subject: [PATCH] display transaction validated confirmation --- app/components/toaster.js | 57 +++++++++++++++++++++++++++++++++++++++ app/dapp.js | 20 ++++++++++++-- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 app/components/toaster.js diff --git a/app/components/toaster.js b/app/components/toaster.js new file mode 100644 index 0000000..97460b2 --- /dev/null +++ b/app/components/toaster.js @@ -0,0 +1,57 @@ +import React, { Fragment } from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from '@material-ui/core/styles'; +import Button from '@material-ui/core/Button'; +import Snackbar from '@material-ui/core/Snackbar'; +import IconButton from '@material-ui/core/IconButton'; +import CloseIcon from '@material-ui/icons/Close'; + +const styles = theme => ({ + close: { + width: theme.spacing.unit * 4, + height: theme.spacing.unit * 4, + }, +}); + +class SimpleSnackbar extends React.Component { + render() { + const { classes, open, handleClose } = this.props; + return ( + + Transaction Validated} + action={[ + , + + + , + ]} + /> + + ); + } +} + +SimpleSnackbar.propTypes = { + classes: PropTypes.object.isRequired, +}; + +export default withStyles(styles)(SimpleSnackbar); diff --git a/app/dapp.js b/app/dapp.js index 380d616..f42eaff 100644 --- a/app/dapp.js +++ b/app/dapp.js @@ -8,6 +8,7 @@ import DrawField from './components/draw/DrawField'; //import ContractClient, { createContract } from './contract_client' import ContractClient from './client_contractgo'; import Events from './chain_client/events'; +import Toaster from './components/toaster'; window['SNT'] = SNT; import './dapp.css'; @@ -45,6 +46,7 @@ class App extends React.Component { tileStateUpdateHandler = tileData => { console.log('tile state update event received'); + this.showValidatedToast(); this.setState({ canvasState: tileData }); } @@ -73,12 +75,26 @@ class App extends React.Component { }) } + showValidatedToast = () => { + this.setState({ validationToast: true }) + } + + closeValidationToast = (event, reason) => { + if (reason === 'clickaway') { + return; + } + this.setState({ validationToast: false }); + } + + + render(){ - const { setTileMapState } = this; - const { web3Provider, loading, canvasState } = this.state; + const { setTileMapState, closeValidationToast } = this; + const { web3Provider, loading, canvasState, validationToast } = this.state; return ( + ); }