import React from 'react';
import './AlertModal.css';

const ICON = { success: '✓', error: '✕', warning: '!', info: 'i' };

export default function AlertModal({ visible = false, type = 'info', title = '提示', content = '', okText = '知道了', onOk }) {
  if (!visible) return null;
  return (
    <div className="kole-modal-mask" onClick={e => { if (e.target === e.currentTarget) onOk && onOk(); }}>
      <div className={`kole-alert is-${type}`}>
        <div className="kole-alert-head">
          <span className="kole-alert-icon">{ICON[type] || 'i'}</span>
          <div className="kole-alert-title">{title}</div>
        </div>
        <div className="kole-alert-content">{content}</div>
        <div className="kole-alert-footer">
          <button className="kole-alert-btn" onClick={onOk}>{okText}</button>
        </div>
      </div>
    </div>
  );
}
