import { FC } from 'react';

import Alert from '@material-hu/mui/Alert';
import Snackbar from '@material-hu/mui/Snackbar';

export type AlertSnackbarProps = {
  open: boolean;
  onClose: () => void;
  message: string;
  alertType?: any;
};

export const AlertSnackbar: FC<AlertSnackbarProps> = props => {
  const { open, onClose, message, alertType = 'error' } = props;

  return (
    <Snackbar
      open={open}
      autoHideDuration={4000}
      onClose={onClose}
    >
      <Alert
        onClose={onClose}
        severity={alertType}
        sx={{ width: '100%' }}
      >
        {message}
      </Alert>
    </Snackbar>
  );
};

export default AlertSnackbar;
