diff --git a/frontend/src/pages/OrganizationsPage.tsx b/frontend/src/pages/OrganizationsPage.tsx index 35a0867..50ba29c 100644 --- a/frontend/src/pages/OrganizationsPage.tsx +++ b/frontend/src/pages/OrganizationsPage.tsx @@ -1,4 +1,5 @@ -import { motion } from 'framer-motion' +import { useState } from 'react' +import { motion, AnimatePresence } from 'framer-motion' import { Building2, Plus, @@ -8,20 +9,58 @@ import { ArrowRight, ExternalLink, ShieldCheck, - UserPlus + UserPlus, + X, + Loader2, + Layout as LayoutIcon, + Globe, + Zap } from 'lucide-react' import { Link } from 'react-router-dom' import { useAuth } from '../contexts/AuthContext' import { cn } from '../lib/utils' +import { organizationService } from '../services/organizationService' export function OrganizationsPage() { - const { user, activeOrg, setActiveOrg } = useAuth() + const { user, activeOrg, setActiveOrg, refreshUser } = useAuth() + const [showCreateModal, setShowCreateModal] = useState(false) + const [newOrgName, setNewOrgName] = useState('') + const [isCreating, setIsCreating] = useState(false) + const [error, setError] = useState(null) + const [searchQuery, setSearchQuery] = useState('') + + const handleCreateOrganization = async (e: React.FormEvent) => { + e.preventDefault() + if (!newOrgName.trim()) return + + setIsCreating(true) + setError(null) + try { + await organizationService.create(newOrgName) + await refreshUser() + setNewOrgName('') + setShowCreateModal(false) + } catch (err) { + console.error('Failed to create organization', err) + setError('Erro ao criar organização. Tente outro nome.') + } finally { + setIsCreating(false) + } + } + + const filteredOrgs = user?.organizations.filter(org => + org.name.toLowerCase().includes(searchQuery.toLowerCase()) + ) || [] return (
{/* Header Section */}
+
+ + Hub Global +

Organizações

@@ -30,20 +69,30 @@ export function OrganizationsPage() {

+
+ + 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" + /> +
- Encontrar Organização + Encontrar - setShowCreateModal(true)} + className="inline-flex items-center justify-center gap-2 rounded-xl bg-brand px-6 py-3 text-sm font-bold text-white shadow-lg shadow-brand/20 transition-all hover:scale-[1.02] hover:bg-brand-dark active:scale-95" > - Nova Organização - + Nova Org +
@@ -55,96 +104,100 @@ export function OrganizationsPage() {
- {user?.organizations.map((org) => { - const isActive = org.id === activeOrg?.id - const isOwner = org.roles.includes('OWNER') - const isAdmin = org.roles.includes('ADMIN') + + {filteredOrgs.map((org, index) => { + const isActive = org.id === activeOrg?.id + const isOwner = org.roles.includes('OWNER') + const isAdmin = org.roles.includes('ADMIN') - return ( - - {/* Active Indicator */} - {isActive && ( -
-
- Ativa -
- )} + return ( + + {/* Active Indicator */} + {isActive && ( +
+
+ Ativa +
+ )} -
-
- {org.name.substring(0, 2).toUpperCase()} +
+
+ {org.name.substring(0, 2).toUpperCase()} +
+ +

+ {org.name} +

+ +
+ {org.roles.map(role => ( + + {role === 'OWNER' && } + {role === 'ADMIN' && } + {role} + + ))} +
+ +
+ {!isActive ? ( + + ) : ( +
+ Organização Atual +
+ )} + + {(isOwner || isAdmin) && ( + + + + )} +
-

- {org.name} -

+ {/* Decorations */} +
+ + ) + })} -
- {org.roles.map(role => ( - - {role === 'OWNER' && } - {role === 'ADMIN' && } - {role} - - ))} -
- -
- {!isActive ? ( - - ) : ( -
- Selecionada -
- )} - - {(isOwner || isAdmin) && ( - - - - )} -
-
- - {/* Decorations */} -
- - ) - })} - - {/* Quick Create Card */} - -
- -
-
-

Criar nova organização

-

Inicie um novo projeto com sua equipe.

-
- + {/* Quick Create Card */} + +
@@ -154,7 +207,7 @@ export function OrganizationsPage() {

Procurando uma equipe?

-

+

Explore organizações públicas ou use um código de convite para se juntar aos seus colegas de trabalho.

@@ -181,30 +234,101 @@ export function OrganizationsPage() {
-

Como funciona?

-

- Organizações são espaços isolados para seus projetos e tarefas. Você pode ser dono de várias ou participar como colaborador em outras. Toda a sua atividade é filtrada pela organização ativa. +

Gestão de Equipe

+

+ Organizações são espaços isolados para seus projetos e tarefas. Você pode alternar facilmente entre elas e gerenciar diferentes equipes.

- Saiba mais sobre permissões + Entender hierarquia
- +
-

Segurança & Funções

-

- Cada organização define seus próprios papéis (OWNER, ADMIN, MEMBER). Apenas administradores e donos podem gerenciar membros e configurações do espaço. +

Início Imediato

+

+ Crie uma organização em segundos e comece a convidar seus membros. O BeeTask facilita a colaboração desde o primeiro dia.

- Ver detalhes de segurança + Dicas de onboarding
+ + {/* Create Organization Modal */} + + {showCreateModal && ( +
+ + + +
+
+ +
+

Nova Organização

+

Inicie um novo workspace colaborativo agora mesmo.

+
+ +
+
+ +
+
+ +
+ setNewOrgName(e.target.value)} + className="block w-full pl-12 pr-4 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: Bee Tech, Creative Agency..." + /> +
+
+ + {error && ( +
+ + {error} +
+ )} + + +
+
+
+ )} +
) }