Web Developer Work - I
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.

35 lines
1.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3. import './AlertPopup.css';
  4. interface AlertPopupProps {
  5. type: 'success' | 'error';
  6. title?: string;
  7. message?: string;
  8. onClose: () => void;
  9. }
  10. const AlertPopup: React.FC<AlertPopupProps> = ({
  11. type,
  12. title = type === 'success' ? 'Success!' : 'Oh Snap!',
  13. message = type === 'success' ? 'Your operation completed successfully.' : 'Something went wrong. Please try again.',
  14. onClose
  15. }) => {
  16. const icon = type === 'success' ? '😄' : '😕';
  17. const buttonText = type === 'success' ? 'Close' : 'Close';
  18. return ReactDOM.createPortal(
  19. <div className="alert-overlay">
  20. <div className={`alert-box alert-${type}`}>
  21. {/* <button className="alert-close" onClick={onClose}>×</button> */}
  22. <div className="alert-icon">{icon}</div>
  23. <div className="alert-title">{title}</div>
  24. <div className="alert-message">{message}</div>
  25. <button className="alert-button" onClick={onClose}>{buttonText}</button>
  26. </div>
  27. </div>,
  28. document.body
  29. );
  30. };
  31. export default AlertPopup;