"use client" import { FilePlus, FolderPlus, Loader2, Search } from "lucide-react" import SidebarFile from "./file" import SidebarFolder from "./folder" import { TFile, TFolder, TTab } from "./types" import { useState } from "react" import New from "./new" import { Socket } from "socket.io-client" export default function Sidebar({ files, selectFile, handleRename, handleDeleteFile, handleDeleteFolder, socket, addNew, }: { files: (TFile | TFolder)[] selectFile: (tab: TTab) => void handleRename: ( id: string, newName: string, oldName: string, type: "file" | "folder" ) => boolean handleDeleteFile: (file: TFile) => void handleDeleteFolder: (folder: TFolder) => void socket: Socket addNew: (name: string, type: "file" | "folder") => void }) { const [creatingNew, setCreatingNew] = useState<"file" | "folder" | null>(null) return (
Explorer
{/* Todo: Implement file searching */} {/* */}
{files.length === 0 ? (
) : ( <> {files.map((child) => child.type === "file" ? ( ) : ( ) )} {creatingNew !== null ? ( { console.log("stopped editing") setCreatingNew(null) }} addNew={addNew} /> ) : null} )}
{/*
{connected ? "Connected" : "Not connected"}
*/}
) }