From 1726a81b320e92ce412c0fa2b2b05f73798cc4ee Mon Sep 17 00:00:00 2001
From: Jules Laplace <julescarbon@gmail.com>
Date: Thu, 29 Jun 2017 03:09:00 +0200
Subject: folder browser

---
 client/components/Folders/Folders.jsx | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

(limited to 'client/components/Folders/Folders.jsx')

diff --git a/client/components/Folders/Folders.jsx b/client/components/Folders/Folders.jsx
index 7c27311..e5d5d76 100644
--- a/client/components/Folders/Folders.jsx
+++ b/client/components/Folders/Folders.jsx
@@ -4,6 +4,8 @@ import { Link } from 'react-router-dom'
 import Modal from '../Modal.jsx'
 import FolderForm from './FolderForm.jsx'
 
+import client from '../../client.js'
+
 export default class Folders extends Component {
   constructor(props) {
     super()
@@ -17,10 +19,27 @@ export default class Folders extends Component {
   closeModal() {
     this.setState({ adding: false })
   }
+  toggle(folder) {
+    folder.open = ! folder.open
+    if (folder.open && ! folder.files) {
+      client.file.index({ 'folder_id': folder.id }).then( files => {
+        this.props.openFolder(folder)
+      })
+    }
+  }
   render() {
+    console.log(this.props)
+    const folders = (this.props.folders || []).map( (folder,i) => {
+      return (
+        <div key={i} onClick={() => this.toggle(folder)}>
+          {folder.name}
+        </div>
+      )
+    })
     return (
       <div class='folders'>
-        <button onClick={() => this.openModal()}>+</button>
+        <b>folders</b> <button onClick={() => this.openModal()}>+ folder</button>
+        {folders}
         <Modal visible={this.state.adding} onClose={() => this.closeModal()}>
           <FolderForm />
         </Modal>
-- 
cgit v1.2.3-70-g09d2

