import React, { useState } from 'react';
import { Upload, Button, Icon } from '@btri-ui/base';
import { UploadFile, UploadProps } from 'antd';

export default () => {
  const [fileList, setFileList] = useState<UploadFile[]>([]);

  const handleChange: UploadProps['onChange'] = ({
    fileList: newFileList,
    event,
  }) => {
    setFileList(newFileList);
  };

  return (
    <>
      <Upload
        action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
        fileList={fileList}
        onChange={handleChange}
        listType="picture"
        showUploadList={{
          showPreviewIcon: true,
          showRemoveIcon: true,
          showDownloadIcon: true,
        }}
        onDownload={() => {
          window.open(
            'https://static-dist-pub.oss-cn-hangzhou.aliyuncs.com/ibuilding-ui/static/images/ImageDemoPic1.png',
          );
        }}
      >
        <Button type="primary" icon={<Icon iconName="Export"></Icon>}>
          点击上传
        </Button>
      </Upload>
    </>
  );
};
