diff --git a/src/app/DRE/teste.tsx b/src/app/DRE/teste.tsx index 9eff842..d6b605c 100644 --- a/src/app/DRE/teste.tsx +++ b/src/app/DRE/teste.tsx @@ -1,6 +1,6 @@ "use client"; -import { LoaderPinwheel, ChevronDown, ChevronRight, Filter } from "lucide-react"; +import { LoaderPinwheel, ChevronDown, ChevronRight, Filter, Maximize2, Minimize2 } from "lucide-react"; import { useEffect, useState } from "react"; import AnaliticoComponent from "./analitico"; import { Button } from "@/components/ui/button"; @@ -103,6 +103,7 @@ export default function Teste() { linhaSelecionada: "", // Adicionar informação da linha selecionada }); const [linhaSelecionada, setLinhaSelecionada] = useState(null); + const [isAllExpanded, setIsAllExpanded] = useState(false); useEffect(() => { // Carregar períodos disponíveis da API @@ -350,6 +351,29 @@ export default function Teste() { setContasSelecionadas([]); }; + const toggleExpandAll = () => { + if (isAllExpanded) { + // Recolher tudo + setExpandedGroups(new Set()); + setExpandedSubgrupos(new Set()); + setExpandedCentros(new Set()); + setIsAllExpanded(false); + } else { + // Expandir todos os grupos usando dados originais + const todosGrupos = [...new Set(data.map(item => item.grupo))]; + setExpandedGroups(new Set(todosGrupos)); + + // Expandir todos os subgrupos usando dados originais + const todosSubgrupos = [...new Set(data.map(item => `${item.grupo}-${item.subgrupo}`))]; + setExpandedSubgrupos(new Set(todosSubgrupos)); + + // Expandir todos os centros de custo usando dados originais (isso também expande as contas automaticamente) + const todosCentros = [...new Set(data.map(item => `${item.grupo}-${item.subgrupo}-${item.centro_custo}`))]; + setExpandedCentros(new Set(todosCentros)); + setIsAllExpanded(true); + } + }; + const limparFiltros = () => { const agora = new Date(); const anoAtual = agora.getFullYear(); @@ -377,6 +401,7 @@ export default function Teste() { setDadosFiltrados([]); setFiltrosAplicados(false); setMesesDisponiveis([]); + setIsAllExpanded(false); // Recarregar opções e selecionar todos novamente carregarPeriodosDisponiveis(); @@ -888,8 +913,31 @@ export default function Teste() { - {/* Botão de Filtro */} - + {/* Controles */} +
+ {/* Botão de Expandir/Recolher */} + + + {/* Botão de Filtro */} +
- +
{opcoesContas.map(conta => (
@@ -1126,6 +1174,7 @@ export default function Teste() { +
@@ -1208,49 +1257,6 @@ export default function Teste() { ))}
Total
- - {/* Botões de controle */} -
- - -