diff --git a/.eslintrc.js b/.eslintrc.js
index 6422ba86..f5bb36c2 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -19,5 +19,8 @@ module.exports = {
"import/no-named-as-default": 0,
"import/no-extraneous-dependencies": 0,
"no-underscore-dangle": 0,
+ "@typescript-eslint/no-shadow": 0,
+ "no-shadow": 0,
},
+
};
diff --git a/.github/workflows/react-component-ci.yml b/.github/workflows/react-component-ci.yml
index 432a3fb3..bcde914c 100644
--- a/.github/workflows/react-component-ci.yml
+++ b/.github/workflows/react-component-ci.yml
@@ -2,9 +2,11 @@ name: CI
on:
push:
- branches: [ master ]
+ branches: [ master,ChowSengFung ]
+ paths-ignore:
+ - './src/FileInput.js'
pull_request:
- branches: [ master ]
+ branches: [ master,ChowSengFung ]
jobs:
setup:
diff --git a/package.json b/package.json
index a23df483..dc4a49d3 100644
--- a/package.json
+++ b/package.json
@@ -42,6 +42,7 @@
"@types/react": "^16.9.2",
"@types/react-dom": "^16.9.0",
"@umijs/fabric": "^2.0.0",
+ "antd": "^4.16.13",
"axios": "^0.20.0",
"co-busboy": "^1.3.0",
"coveralls": "^3.0.3",
diff --git a/src/FileInput.tsx b/src/FileInput.tsx
new file mode 100644
index 00000000..b3f1e50f
--- /dev/null
+++ b/src/FileInput.tsx
@@ -0,0 +1,47 @@
+import React, { useState } from "react";
+
+function FileInput({ value, FileContent, ...rest }) {
+ const [filePresent, setFilePresent] = useState(false);
+ const [Files, setFiles] = useState([]);
+
+ function noop(filePresent) {
+ setFilePresent(true);
+ }
+
+ return (
+
+
+
+ {Boolean(filePresent) && (
+
+ Selected files: {Files.map((f) => f.name).join(", ")}
+
+ )}
+
+ );
+}
+
+export default FileInput;
diff --git a/src/UploadAlt.tsx b/src/UploadAlt.tsx
new file mode 100644
index 00000000..0f79a48c
--- /dev/null
+++ b/src/UploadAlt.tsx
@@ -0,0 +1,83 @@
+import React, { useState, useEffect } from "react";
+import "antd/dist/antd.css";
+import axios from "axios";
+import { Card, Button, Modal } from "antd";
+import FileInput from './FileInput'
+
+
+function UploadAlt() {
+
+ const [fileData, setfileData] = useState();
+ const [isModalVisible, setIsModalVisible] = useState(false);
+ const [fileDataContent, setfileDataContent] = useState(" ");
+
+ function fileContent(file) {
+ setfileData(file[0]);
+ // console.log(file[0]);
+ }
+
+ const showModal = () => {
+ setIsModalVisible(true);
+ };
+
+ const handleCancel = () => {
+ setIsModalVisible(false);
+ };
+
+ const handleSubmit = (e) => {
+ const fr = new FileReader();
+ fr.onload = function (e) {
+ // e.target.result should contain the text
+ const text = e.target.result;
+ setfileDataContent(text);
+ console.log(fileDataContent);
+ };
+
+ fr.readAsText(fileData);
+ axios({
+ method: "post",
+ url: "",
+ // database table with the columns Name, content
+ data: [{ Name: fileData.name, content: fileDataContent }]
+ })
+ .then(function (response) {
+ // handle success
+ console.log(response.data);
+ })
+ .catch(function (error) {
+ // handle error
+ console.log(error);
+ });
+ };
+
+ return (
+
+
+
+
+
+ style={{
+ overflow: 'auto',
+ borderRadius: '10px',
+ backgroundColor: '#1890ff',
+ }}
+ Are you sure to upload the following file?
+ {fileData && File: {fileData.name}
}
+
+
+
+ );
+ }
+ export default UploadAlt;
\ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
index 1cbbd3ef..140e31dd 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,6 +1,8 @@
import Upload from './Upload';
import { UploadProps } from './interface';
+import FileInput from './FileInput';
+import UploadAlt from './UploadAlt';
-export { UploadProps };
+export { UploadProps,FileInput, UploadAlt };
export default Upload;