import React from "react" import { useState } from "react" import uploadFile from "../functions/uploadFile" import { useOpenDirQuery } from "../generated/graphql" import Breadcrum from "./Breadcrum" import DragAndDrop from "./DragAndDrop" import FileBrowserElement from "./FileBrowserElement" import FileOpen from "./FileOpen" const FileBrowser: React.FC = () => { const [path,setPath] = useState("/") const [openFileId, setOpenFileId] = useState("") const [showFile, setShowFile] = useState(false) const { data, loading } = useOpenDirQuery({ variables:{ path } }) async function handleDrop(files:FileList) { const wait: Promise[] = [] for (let i = 0; i < files.length; i++) { const file = files[i] wait.push(uploadFile(file, path + file.name)) } await Promise.all(wait) } return (
{ await handleDrop(files) }} > { setPath(newPath) }}/>
{loading &&
// TODO: center } { data?.directorys.map(v => ({ setPath(dir.id) }} />))} { data?.files.map(v => ({ setOpenFileId(file.id) setShowFile(true) }} />))}
Name Size
{{ setShowFile(false) }} />}
) } export default FileBrowser