import { useState, useEffect } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { FaFolder, FaFolderOpen, FaFile, FaFileCode, FaFileAlt, FaImage, FaVideo, FaMusic, FaArchive, FaDatabase, FaCloud, FaGitAlt, FaPlus, FaMinus, FaEdit, FaTrash, FaCopy, FaMove, FaDownload, FaUpload, FaSearch, FaFilter, FaSort, FaSortAmountDown, FaSortAmountUp, FaEye, FaEyeSlash, FaLock, FaUnlock, FaShare, FaLink, FaStar, FaRegStar, FaClock, FaCalendar, FaUser, FaUsers, FaTag, FaTags, FaFlag, FaBookmark, FaCheck, FaTimes, FaInfo, FaWarning, FaExclamationTriangle, FaCheckCircle, FaTimesCircle, FaPlay, FaPause, FaStop, FaRedo, FaUndo, FaSave, FaPrint, FaSync, FaRefresh, FaSpinner, FaCog, Fa wrench, FaTools, FaMagic, FaRocket, FaCode, FaDatabase, FaServer, FaCloud, FaShieldAlt, FaChartLine, FaProjectDiagram, FaBug, FaTest, FaFlask, FaBook, FaGraduationCap, FaLightbulb, FaLightbulbAlt, FaFire, FaBolt, FaZap, FaAtom, FaDna, FaMicroscope, FaTelescope, FaSatellite, FaRocket, FaSpace, FaGlobe, FaMap, FaMapMarked, FaMapMarkedAlt, FaCompass, FaRoute, FaNavigator, FaSailboat, FaShip, FaAnchor, FaBuoy, FaWater, FaWind, FaCloudRain, FaCloudSun, FaSun, FaMoon, FaStar, FaRegStar, FaStarHalf, FaStarAndCrescent, FaMeteor, FaComet, FaPlanet, FaRing, FaOrbital, FaBlackHole, FaGalaxy, FaNebula, FaConstellation, FaAstronomy } from 'react-icons/fa' import toast from 'react-hot-toast' export default function ProjectManager({ language, theme }) { const [projects, setProjects] = useState([]) const [selectedProject, setSelectedProject] = useState(null) const [files, setFiles] = useState([]) const [viewMode, setViewMode] = useState('grid') const [sortBy, setSortBy] = useState('name') const [sortOrder, setSortOrder] = useState('asc') const [searchQuery, setSearchQuery] = useState('') const [showHidden, setShowHidden] = useState(false) const [selectedFiles, setSelectedFiles] = useState(new Set()) useEffect(() => { // Initialize with sample projects setProjects([ { id: 1, name: 'E-Commerce Platform', type: 'web', status: 'active', progress: 75, lastModified: new Date(), size: '125 MB', files: 234, stars: 5, tags: ['react', 'nodejs', 'mongodb'], description: 'Full-stack e-commerce solution' }, { id: 2, name: 'Mobile Banking App', type: 'mobile', status: 'development', progress: 45, lastModified: new Date(), size: '89 MB', files: 156, stars: 4, tags: ['react-native', 'firebase', 'typescript'], description: 'Secure mobile banking application' }, { id: 3, name: 'AI Data Pipeline', type: 'data', status: 'testing', progress: 90, lastModified: new Date(), size: '2.3 GB', files: 412, stars: 5, tags: ['python', 'tensorflow', 'aws'], description: 'Machine learning data processing pipeline' } ]) }, []) const createProject = () => { const newProject = { id: Date.now(), name: `New Project ${projects.length + 1}`, type: 'web', status: 'planning', progress: 0, lastModified: new Date(), size: '0 MB', files: 0, stars: 0, tags: [], description: 'New project description' } setProjects([...projects, newProject]) setSelectedProject(newProject) toast.success(language === 'fa' ? 'پروژه ایجاد شد' : 'Project created') } const deleteProject = (id) => { setProjects(projects.filter(p => p.id !== id)) if (selectedProject?.id === id) { setSelectedProject(null) } toast.success(language === 'fa' ? 'پروژه حذف شد' : 'Project deleted') } const duplicateProject = (project) => { const duplicate = { ...project, id: Date.now(), name: `${project.name} (Copy)`, lastModified: new Date() } setProjects([...projects, duplicate]) toast.success(language === 'fa' ? 'پروژه کپی شد' : 'Project duplicated') } const getFileIcon = (fileName) => { const ext = fileName.split('.').pop().toLowerCase() if (['js', 'jsx', 'ts', 'tsx', 'py', 'java', 'cpp', 'c'].includes(ext)) return FaFileCode if (['txt', 'md', 'doc', 'docx', 'pdf'].includes(ext)) return FaFileAlt if (['jpg', 'jpeg', 'png', 'gif', 'svg', 'webp'].includes(ext)) return FaImage if (['mp4', 'avi', 'mov', 'webm'].includes(ext)) return FaVideo if (['mp3', 'wav', 'ogg', 'm4a'].includes(ext)) return FaMusic if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext)) return FaArchive if (['sql', 'db', 'sqlite'].includes(ext)) return FaDatabase return FaFile } const getStatusColor = (status) => { switch (status) { case 'active': return 'text-green-400' case 'development': return 'text-blue-400' case 'testing': return 'text-yellow-400' case 'planning': return 'text-purple-400' case 'completed': return 'text-emerald-400' default: return 'text-gray-400' } } const sortProjects = (projects) => { return [...projects].sort((a, b) => { let comparison = 0 switch (sortBy) { case 'name': comparison = a.name.localeCompare(b.name) break case 'date': comparison = a.lastModified - b.lastModified break case 'size': comparison = parseFloat(a.size) - parseFloat(b.size) break case 'progress': comparison = a.progress - b.progress break case 'files': comparison = a.files - b.files break default: comparison = 0 } return sortOrder === 'asc' ? comparison : -comparison }) } const filteredProjects = sortProjects(projects).filter(project => project.name.toLowerCase().includes(searchQuery.toLowerCase()) || project.description.toLowerCase().includes(searchQuery.toLowerCase()) || project.tags.some(tag => tag.toLowerCase().includes(searchQuery.toLowerCase())) ) return (
{project.description}