import React, { useEffect, useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { FolderKanban, Plus, Search, Building2, ArrowRight, Loader2, X, Target, Rocket, ShieldCheck, ExternalLink, ChevronRight } from "lucide-react"; import { useAuth } from "../contexts/AuthContext"; import { projectService, type Project } from "../services/projectService"; import { cn } from "../lib/utils"; export const ProjectsPage: React.FC = () => { const { activeOrg } = useAuth(); const [projects, setProjects] = useState([]); const [isLoading, setIsLoading] = useState(true); const [isCreating, setIsCreating] = useState(false); const [showCreateForm, setShowCreateForm] = useState(false); const [newProjectName, setNewProjectName] = useState(""); const [searchQuery, setSearchQuery] = useState(""); const [error, setError] = useState(null); const fetchProjects = async () => { if (!activeOrg) return; setIsLoading(true); try { const data = await projectService.listByOrganization(activeOrg.id); setProjects(data); } catch (err) { console.error("Failed to fetch projects", err); setError("Não foi possível carregar os projetos."); } finally { setIsLoading(false); } }; useEffect(() => { fetchProjects(); }, [activeOrg]); const handleCreateProject = async (e: React.FormEvent) => { e.preventDefault(); if (!activeOrg || !newProjectName.trim()) return; setIsCreating(true); setError(null); try { const newProject = await projectService.create( activeOrg.id, newProjectName, ); setProjects((prev) => [...prev, newProject]); setNewProjectName(""); setShowCreateForm(false); } catch (err) { console.error("Failed to create project", err); setError("Falha ao criar o projeto."); } finally { setIsCreating(false); } }; const filteredProjects = projects.filter((p) => p.name.toLowerCase().includes(searchQuery.toLowerCase()), ); return (
{/* Header Section */}
Workspace

Projetos em {activeOrg.name}

Organize suas tarefas em fluxos de trabalho específicos.

setSearchQuery(e.target.value)} className="pl-10 pr-4 py-2.5 bg-surface border border-border-soft rounded-xl text-sm outline-none focus:border-brand focus:ring-4 focus:ring-brand/5 transition-all w-48 font-medium" />
{/* Projects Grid */}

Todos os Projetos

{filteredProjects.map((project, index) => (
{project.name.substring(0, 2).toUpperCase()}

{project.name}

ID #{project.id} Ativo
{[1, 2, 3].map(i => (
U{i}
))}
{/* Decorations */}
))} {/* Quick Create Card */}
{filteredProjects.length === 0 && !isLoading && (

Nenhum projeto encontrado

Sua organização ainda não possui projetos para exibir.

)}
{/* Discovery Section */}

Acelere sua Produtividade

Projetos ajudam a categorizar tarefas e manter o foco no que realmente importa. Defina metas e acompanhe o progresso em tempo real.

{/* Abstract shapes */}
{/* Info Section */}

Foco em Objetivos

Cada projeto pode ser encarado como um objetivo específico. Use-os para separar demandas de diferentes clientes ou departamentos da sua organização.

Melhores práticas de organização

Colaboração Segura

Projetos herdam as permissões da organização. Apenas membros autorizados podem visualizar e interagir com as tarefas de cada projeto.

Ver detalhes de visibilidade
{/* Create Project Modal */} {showCreateForm && (

Novo Projeto

Dê um nome ao seu novo espaço de trabalho em {activeOrg.name}.

setNewProjectName(e.target.value)} className="block w-full px-5 py-4 bg-surface-muted/50 border border-border-soft rounded-2xl text-text-main placeholder-text-muted/60 focus:outline-none focus:ring-4 focus:ring-brand/10 focus:border-brand transition-all font-bold" placeholder="Ex: Redesign Mobile, Q4 Marketing..." />
{error && (
{error}
)}
)}
); };