"use client"; import React, { useState, useEffect } from 'react'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { // Select, // SelectContent, // SelectItem, // SelectTrigger, // SelectValue, } from '@/components/ui/select'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; import { Badge } from '@/components/ui/badge'; import { // Folder, FolderPlus, Palette, Tag, // Settings } from 'lucide-react'; export interface CreateFolderDialogProps { open: boolean; onOpenChange: (open: boolean) => void; onFolderCreate: (folderData: { name: string; parentFolderId?: string; metadata?: { description?: string; color?: string; icon?: string; tags?: string[]; }; }) => void; parentFolderId?: string | null; } const FOLDER_COLORS = [ { name: 'Blue', value: '#3B82F6', class: 'bg-blue-500' }, { name: 'Green', value: '#10B981', class: 'bg-green-500' }, { name: 'Yellow', value: '#F59E0B', class: 'bg-yellow-500' }, { name: 'Red', value: '#EF4444', class: 'bg-red-500' }, { name: 'Purple', value: '#8B5CF6', class: 'bg-purple-500' }, { name: 'Pink', value: '#EC4899', class: 'bg-pink-500' }, { name: 'Indigo', value: '#6366F1', class: 'bg-indigo-500' }, { name: 'Gray', value: '#6B7280', class: 'bg-gray-500' }, ]; const FOLDER_ICONS = [ '📁', '📂', '🗂️', '📋', '📊', '📈', '📉', '📦', '🎨', '🖼️', '🎵', '🎬', '📷', '🎮', '⚙️', '🔧', '💼', '🏠', '🌟', '❤️', '🔥', '⚡', '🚀', '💡' ]; const COMMON_FOLDER_NAMES = [ 'components', 'pages', 'styles', 'assets', 'images', 'scripts', 'utils', 'helpers', 'hooks', 'services', 'api', 'data', 'tests', 'docs', 'config', 'public', 'src', 'lib' ]; export function CreateFolderDialog({ open, onOpenChange, onFolderCreate, parentFolderId }: CreateFolderDialogProps) { const [folderName, setFolderName] = useState(''); const [description, setDescription] = useState(''); const [selectedColor, setSelectedColor] = useState(FOLDER_COLORS[0].value); const [selectedIcon, setSelectedIcon] = useState('📁'); const [tags, setTags] = useState([]); const [tagInput, setTagInput] = useState(''); const [isCreating, setIsCreating] = useState(false); // Reset form when dialog opens useEffect(() => { if (open) { setFolderName(''); setDescription(''); setSelectedColor(FOLDER_COLORS[0].value); setSelectedIcon('📁'); setTags([]); setTagInput(''); } }, [open]); const handleCreate = async () => { if (!folderName.trim()) { return; } setIsCreating(true); try { onFolderCreate({ name: folderName.trim(), parentFolderId: parentFolderId || undefined, metadata: { description: description.trim() || undefined, color: selectedColor, icon: selectedIcon, tags: tags.length > 0 ? tags : undefined } }); onOpenChange(false); } catch (error) { console.error('Error creating folder:', error); } finally { setIsCreating(false); } }; const handleAddTag = () => { const tag = tagInput.trim().toLowerCase(); if (tag && !tags.includes(tag)) { setTags([...tags, tag]); setTagInput(''); } }; const handleRemoveTag = (tagToRemove: string) => { setTags(tags.filter(tag => tag !== tagToRemove)); }; const handleTagInputKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { e.preventDefault(); handleAddTag(); } }; const handleQuickName = (name: string) => { setFolderName(name); }; return ( Create New Folder Create a new folder to organize your files {parentFolderId && " in the selected folder"}.
{/* Folder Name */}
setFolderName(e.target.value)} /> {/* Quick Name Suggestions */}
{COMMON_FOLDER_NAMES.slice(0, 8).map(name => ( handleQuickName(name)} > {name} ))}
{/* Description */}