From aaff3638bc1dcce6108c236dd151cb53ce0ba51a Mon Sep 17 00:00:00 2001 From: Erik Silva Date: Wed, 4 Feb 2026 19:43:21 -0300 Subject: [PATCH] refactor: move financial sub-menus to sidebar and simplify dashboard header --- .../(dashboard)/dashboard/financial/page.tsx | 8 +- src/components/FinancialDashboard.tsx | 149 ++++++++---------- src/components/Sidebar.tsx | 62 ++++++-- 3 files changed, 116 insertions(+), 103 deletions(-) diff --git a/src/app/(dashboard)/dashboard/financial/page.tsx b/src/app/(dashboard)/dashboard/financial/page.tsx index 4d0b263..dee029b 100644 --- a/src/app/(dashboard)/dashboard/financial/page.tsx +++ b/src/app/(dashboard)/dashboard/financial/page.tsx @@ -2,7 +2,12 @@ import { getActiveGroup } from '@/lib/auth' import { getFinancialEvents, getTransactions } from '@/actions/finance' import { FinancialDashboard } from '@/components/FinancialDashboard' -export default async function FinancialPage() { +interface FinancialPageProps { + searchParams: Promise<{ tab?: string }> +} + +export default async function FinancialPage({ searchParams }: FinancialPageProps) { + const { tab } = await searchParams const group = await getActiveGroup() if (!group) return null @@ -24,6 +29,7 @@ export default async function FinancialPage() { transactions={transactions} players={group.players} group={group} + initialTab={(tab as any) || 'EVENTS'} /> ) diff --git a/src/components/FinancialDashboard.tsx b/src/components/FinancialDashboard.tsx index 9fd14fd..e53d7ea 100644 --- a/src/components/FinancialDashboard.tsx +++ b/src/components/FinancialDashboard.tsx @@ -19,9 +19,10 @@ interface FinancialPageProps { transactions: any[] players: any[] group: any + initialTab: 'EVENTS' | 'TRANSACTIONS' | 'REPORTS' } -export function FinancialDashboard({ events, transactions, players, group }: FinancialPageProps) { +export function FinancialDashboard({ events, transactions, players, group, initialTab }: FinancialPageProps) { const router = useRouter() const [mounted, setMounted] = React.useState(false) const [isCreateModalOpen, setIsCreateModalOpen] = useState(false) @@ -47,7 +48,12 @@ export function FinancialDashboard({ events, transactions, players, group }: Fin const [privacyPendingId, setPrivacyPendingId] = useState(null) // Filter & View State - const [mainTab, setMainTab] = useState<'EVENTS' | 'TRANSACTIONS' | 'REPORTS'>('EVENTS') + const [mainTab, setMainTab] = useState<'EVENTS' | 'TRANSACTIONS' | 'REPORTS'>(initialTab) + + // Sync state when prop changes (from sidebar clicks) + React.useEffect(() => { + setMainTab(initialTab) + }, [initialTab]) const [searchQuery, setSearchQuery] = useState('') const [activeTab, setActiveTab] = useState<'ALL' | 'MONTHLY_FEE' | 'EXTRA_EVENT' | 'INCOME' | 'EXPENSE'>('ALL') const [viewMode, setViewMode] = useState<'grid' | 'list'>('grid') @@ -328,56 +334,25 @@ export function FinancialDashboard({ events, transactions, players, group }: Fin
-
- - - -
- -
- {selectedIds.size > 0 && ( +
+ {selectedIds.size > 0 ? (
-
+
{selectedIds.size} {selectedIds.size === 1 ? 'SELECIONADO' : 'SELECIONADOS'}
- )} - {selectedIds.size === 0 && ( - <> + ) : ( +
{mainTab !== 'REPORTS' && ( -
+
)} -
- - -
+
+
+ + +
-
- + + {mainTab === 'EVENTS' && ( + )} - title="Filtros" - > - - - {mainTab === 'EVENTS' && ( - - )} - - {mainTab !== 'REPORTS' && ( - - )} + {mainTab !== 'REPORTS' && ( + + )} +
- +
)}
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 4c5eb69..4a42df9 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -11,7 +11,10 @@ import { Search, Banknote, LogOut, - Eye + Eye, + History, + Receipt, + Sparkles } from 'lucide-react' import { clsx } from 'clsx' @@ -23,7 +26,16 @@ export function Sidebar({ group }: { group: any }) { { name: 'Início', href: '/dashboard', icon: Home }, { name: 'Partidas', href: '/dashboard/matches', icon: Calendar }, { name: 'Jogadores', href: '/dashboard/players', icon: Users }, - { name: 'Financeiro', href: '/dashboard/financial', icon: Banknote }, + { + name: 'Financeiro', + href: '/dashboard/financial', + icon: Banknote, + subItems: [ + { name: 'Eventos', href: '/dashboard/financial?tab=EVENTS', icon: History }, + { name: 'Caixa', href: '/dashboard/financial?tab=TRANSACTIONS', icon: Receipt }, + { name: 'Relatórios', href: '/dashboard/financial?tab=REPORTS', icon: Sparkles }, + ] + }, { name: 'Agenda Pública', href: '/agenda', icon: Eye }, { name: 'Configurações', href: '/dashboard/settings', icon: Settings }, ] @@ -58,21 +70,40 @@ export function Sidebar({ group }: { group: any }) {
) })} @@ -106,4 +137,3 @@ export function Sidebar({ group }: { group: any }) { ) } -