import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { withStyles } from '@material-ui/core/styles'; import CheckIcon from '@material-ui/icons/Check'; import SaveIcon from '@material-ui/icons/Save'; import { green } from '@material-ui/core/colors'; import { CircularProgress, Button, Fab } from '@material-ui/core'; const styles = theme => ({ root: { display: 'flex', alignItems: 'center', }, wrapper: { margin: theme.spacing(1), position: 'relative', }, buttonSuccess: { backgroundColor: green[500], '&:hover': { backgroundColor: green[700], }, }, fabProgress: { color: green[500], position: 'absolute', top: -6, left: -6, zIndex: 1, }, buttonProgress: { color: green[500], position: 'absolute', top: '50%', left: '50%', marginTop: -12, marginLeft: -12, }, }); class CircularIntegration extends React.Component { state = { loading: false, success: false, }; componentWillUnmount() { clearTimeout(this.timer); } handleButtonClick = () => { if (!this.state.loading) { this.setState( { success: false, loading: true, }, () => { this.timer = setTimeout(() => { this.setState({ loading: false, success: true, }); }, 2000); }, ); } }; timer = undefined; render() { const { loading, success } = this.state; const { classes } = this.props; const buttonClassname = classNames({ [classes.buttonSuccess]: success, }); return (