From a7465a66cd49a943b725f0a3ef45d0b1511b48db Mon Sep 17 00:00:00 2001
From: Jules Laplace <julescarbon@gmail.com>
Date: Thu, 29 Jun 2017 04:03:58 +0200
Subject: upload files

---
 client/components/Folder/FileUploadButton.jsx | 44 +++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 client/components/Folder/FileUploadButton.jsx

(limited to 'client/components/Folder/FileUploadButton.jsx')

diff --git a/client/components/Folder/FileUploadButton.jsx b/client/components/Folder/FileUploadButton.jsx
new file mode 100644
index 0000000..8c7d170
--- /dev/null
+++ b/client/components/Folder/FileUploadButton.jsx
@@ -0,0 +1,44 @@
+import { h, Component } from 'preact'
+import { Link } from 'react-router-dom'
+
+import Modal from '../Modal.jsx'
+
+import client from '../../client.js'
+
+import FileUploadButton from './FileUploadButton.jsx'
+
+export default class Folder extends Component {
+  constructor(props) {
+    super()
+    this.state = {
+    }
+    this.updateFiles = this.updateFiles.bind(this)
+  }
+  updateFiles(event){
+    const name = event.target.name
+    const files = event.target.files
+    console.log(name, files)
+
+    client.upload(this.props.folder.id, files).then( got_files => {
+      console.log(got_files)
+      this.props.addFiles(got_files)
+    })
+  }
+
+  render() {
+    console.log(this.props)
+    const files = (this.props.folder.files || []).map( (file, i) => {
+      return (
+        <div key={i}>
+          {file.name}
+        </div>
+      )
+    })
+    return (
+      <div class='fileUploadButton'>
+        <input type='file' multiple name='files' onChange={this.updateFiles} />
+        <span>+ file</span>
+      </div>
+    )
+  }
+}
-- 
cgit v1.2.3-70-g09d2

