import React, { useState } from 'react';
import { notification } from 'antd';
import SiteModal from '@/components/Modal/SiteModa';
import { deleteStation } from '@/services/userCenter/siteManage/api';
const DelModal = props => {
  const { confirmModal, stationId } = props;
  const [loading, setLoading] = useState(false);
  const onSubmit = props => {
    setLoading(true);
    deleteStation({
      stationID: stationId,
      _version: 9999,
      _dc: new Date().getTime(),
    })
      .then(res => {
        setLoading(false);
        if (res.success) {
          notification.success({
            message: '通知',
            duration: 3,
            description: '删除成功',
          });
          confirmModal();
        } else {
          notification.error({
            message: '提示',
            duration: 3,
            description: res.message,
          });
        }
      })
      .catch(err => {
        setLoading(false);
        notification.error({
          message: '提示',
          duration: 3,
          description: err,
        });
      });
  };
  return (
    <SiteModal
      {...props}
      title="删除站点"
      bodyStyle={{ width: '100%', minHeight: '50px' }}
      style={{ top: 200 }}
      width="400px"
      destroyOnClose
      cancelText="取消"
      okText="确认"
      onOk={() => onSubmit()}
      confirmLoading={loading}
    >
      是否删除该站点?
    </SiteModal>
  );
};

export default DelModal;