import React from 'react';
import ConfirmModal from 'components/ConfirmModal';
import EasyvButton from 'components/EasyvButton';
import styles from './index.less';

function CsvModal({
  visible,
  onClose,
  value,
  onUpdate,
}: {
  visible: boolean;
  onClose: () => void;
  value: any;
  onUpdate: (param) => void;
}) {
  const hideModal = () => {
    onClose && onClose();
  };

  const handleSubmit = () => {
    onUpdate(value);
    onClose && onClose();
  };

  const footer = (
    <div style={{ textAlign: 'center' }}>
      <EasyvButton onClick={handleSubmit} theme="primary">
        完成
      </EasyvButton>
    </div>
  );

  return (
    <ConfirmModal
      visible={visible}
      title="修改数据"
      width={1000}
      destroyOnClose
      footer={false}
      onClose={hideModal}
      onCancel={hideModal}>
      <>
        <div className={styles.csvContent}>{value}</div>
        {footer}
      </>
    </ConfirmModal>
  );
}

export default CsvModal;
