import { faFile, faFolder } from "@fortawesome/free-solid-svg-icons" import { CloudUpload } from "@mui/icons-material" import { IconButton, Link as MuiLink } from "@mui/material" import Head from 'next/head' import Link from 'next/link' import { useEffect, useState } from 'react' import { useCookies } from 'react-cookie' import { resolve as pathResolve } from 'path' import api from '../../api_utils' import Icon from "../../components/other/icon" import Table from "../../components/user/table" import UploadModal from "../../components/user/modals/upload" export default function Files() { const [cookies] = useCookies(["token"]) const [path, setPath] = useState("") const [files, setFiles] = useState([{ name: "", size: "", modified: "" }]) const [folders, setFolders] = useState([{ name: "", size: "", modified: "" }]) const refresh = (path: string) => { api.list(path, cookies.token) .then(data => { setPath(path) setFolders(data.dirs) setFiles(data.files) }) .catch(err => console.error(err)) } const refreshFolder = () => refresh(path) useEffect(() => { const params = new URLSearchParams(window.location.search) const path = params.get("path") || "" api.list(path, cookies.token) .then(data => { setPath(path) setFolders(data.dirs) setFiles(data.files) }) .catch(err => console.error(err)) }, [cookies]) // modals const [uploadModal, setUploadModal] = useState(false) return ( <>
Name | Size | Modified |
|