import { useEffect, useState } from 'react'; import { FolderPlus } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { IconTile } from '@/components/ui/icon-tile'; import { toast } from 'sonner'; interface CreateDirectoryDialogProps { open: boolean; onOpenChange: (open: boolean) => void; currentPath: string; onCreateDirectory: (name: string) => Promise; } export function CreateDirectoryDialog({ open, onOpenChange, currentPath, onCreateDirectory }: CreateDirectoryDialogProps) { const [dirName, setDirName] = useState(''); useEffect(() => { if (!open) setDirName(''); }, [open]); const handleCreate = async () => { if (!dirName) { toast.error('Please enter a directory name'); return; } const success = await onCreateDirectory(dirName); if (success) { setDirName(''); onOpenChange(false); } }; return ( } tone="primary" size="md" />
Create Directory Create a new directory in {currentPath || 'the root'}
setDirName(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') { handleCreate(); } }} />
); }