Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { makeStyles } from '@material-ui/core/styles';
  4. import Button from '@material-ui/core/Button';
  5. import LinearProgress from '@material-ui/core/LinearProgress';
  6. import Typography from '@material-ui/core/Typography';
  7. const useStyles = makeStyles(theme => ({
  8. loadingSettings: {
  9. margin: theme.spacing(0.5),
  10. },
  11. loadingSettingsDetails: {
  12. margin: theme.spacing(4),
  13. textAlign: "center"
  14. },
  15. button: {
  16. marginRight: theme.spacing(2),
  17. marginTop: theme.spacing(2),
  18. }
  19. }));
  20. export default function LoadingNotification(props) {
  21. const classes = useStyles();
  22. const { fetched, errorMessage, onReset, render } = props;
  23. return (
  24. <div>
  25. {
  26. fetched ?
  27. errorMessage ?
  28. <div className={classes.loadingSettings}>
  29. <Typography variant="h6" className={classes.loadingSettingsDetails}>
  30. {errorMessage}
  31. </Typography>
  32. <Button variant="contained" color="secondary" className={classes.button} onClick={onReset}>
  33. Reset
  34. </Button>
  35. </div>
  36. :
  37. render()
  38. :
  39. <div className={classes.loadingSettings}>
  40. <LinearProgress className={classes.loadingSettingsDetails} />
  41. <Typography variant="h6" className={classes.loadingSettingsDetails}>
  42. Loading...
  43. </Typography>
  44. </div>
  45. }
  46. </div>
  47. );
  48. }
  49. LoadingNotification.propTypes = {
  50. fetched: PropTypes.bool.isRequired,
  51. onReset: PropTypes.func.isRequired,
  52. errorMessage: PropTypes.string,
  53. render: PropTypes.func.isRequired
  54. };