import _Upload from "antd/es/upload";
import _Icon from "@alifd/next/es/icon";
import * as React from 'react';
import { useState, useEffect } from 'react';
var RcImgUpload = function RcImgUpload(props) {
  var _useState = useState(''),
    baseURL = _useState[0],
    setBaseURL = _useState[1];
  var _useState2 = useState(''),
    identitytoken = _useState2[0],
    setIdentitytoken = _useState2[1];
  var onChange = props.onChange,
    disabled = props.disabled,
    uploadUrl = props.uploadUrl,
    fileName = props.fileName;
  useEffect(function () {
    setBaseURL(getApiPath());
    var token = localStorage.getItem('identitytoken');
    token && setIdentitytoken(token);
  }, []);
  var getApiPath = function getApiPath() {
    var origin = window.location.origin;
    if (origin.includes('localhost') || origin.includes('127.0.0.1')) {
      return 'http://120.77.47.73:8080';
    } else {
      return origin;
    }
  };
  return /*#__PURE__*/React.createElement(_Upload, {
    onChange: onChange,
    action: uploadUrl || baseURL + "/restcloud/rest/bpm/form/import",
    listType: "picture-card",
    headers: {
      identitytoken: identitytoken
    },
    withCredentials: true,
    name: fileName,
    disabled: disabled
  }, /*#__PURE__*/React.createElement(_Icon, {
    type: "add"
  }));
};
export default RcImgUpload;