diff --git a/src/app/DRE/analitico.tsx b/src/app/DRE/analitico.tsx index 7cfe582..9cebc5e 100644 --- a/src/app/DRE/analitico.tsx +++ b/src/app/DRE/analitico.tsx @@ -1,50 +1,63 @@ -"use client"; +'use client'; -import * as React from "react"; -import { DataGridPremium, GridToolbar, GridColDef, GridFilterModel } from "@mui/x-data-grid-premium"; +import { Button } from '@/components/ui/button'; +import { Card, CardContent } from '@/components/ui/card'; +import { Checkbox } from '@/components/ui/checkbox'; +import { + Dialog, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from '@/components/ui/dialog'; +import { + Drawer, + DrawerClose, + DrawerContent, + DrawerDescription, + DrawerHeader, + DrawerTitle, + DrawerTrigger, +} from '@/components/ui/drawer'; +import { Input } from '@/components/ui/input'; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '@/components/ui/select'; +import { + DataGridPremium, + GridColDef, + GridToolbar, +} from '@mui/x-data-grid-premium'; import { LicenseInfo } from '@mui/x-license-pro'; +import { + ArrowDown, + ArrowUp, + ArrowUpDown, + Download, + Maximize2, + Minimize2, + Search, + X, +} from 'lucide-react'; +import * as React from 'react'; +import * as XLSX from 'xlsx'; // Garantir que a licença seja aplicada no componente if (typeof window !== 'undefined') { try { - const PERPETUAL_LICENSE_KEY = 'e0d9bb8070ce0054c9d9ecb6e82cb58fTz0wLEU9MzI0NzIxNDQwMDAwMDAsUz1wcmVtaXVtLExNPXBlcnBldHVhbCxLVj0y'; + const PERPETUAL_LICENSE_KEY = + 'e0d9bb8070ce0054c9d9ecb6e82cb58fTz0wLEU9MzI0NzIxNDQwMDAwMDAsUz1wcmVtaXVtLExNPXBlcnBldHVhbCxLVj0y'; LicenseInfo.setLicenseKey(PERPETUAL_LICENSE_KEY); console.log('✅ Licença MUI X aplicada no componente Analítico'); } catch (error) { console.warn('⚠️ Erro ao aplicar licença no componente:', error); } } -import { Card, CardContent } from "@/components/ui/card"; -import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; -import { - Dialog, - DialogContent, - DialogHeader, - DialogTitle, - DialogFooter, - DialogTrigger, -} from "@/components/ui/dialog"; -import { - Select, - SelectTrigger, - SelectValue, - SelectContent, - SelectItem, -} from "@/components/ui/select"; -import { Checkbox } from "@/components/ui/checkbox"; -import { - Drawer, - DrawerClose, - DrawerContent, - DrawerDescription, - DrawerFooter, - DrawerHeader, - DrawerTitle, - DrawerTrigger, -} from "@/components/ui/drawer"; -import { Download, Filter, X, Search, ArrowUpDown, ArrowUp, ArrowDown, Maximize2, Minimize2 } from "lucide-react"; -import * as XLSX from "xlsx"; interface AnaliticoItem { codigo_grupo: string; @@ -119,8 +132,9 @@ const ExcelFilter: React.FC = ({ currentSort = null, }) => { const [isOpen, setIsOpen] = React.useState(false); - const [searchTerm, setSearchTerm] = React.useState(""); - const [selectedValues, setSelectedValues] = React.useState(currentFilter); + const [searchTerm, setSearchTerm] = React.useState(''); + const [selectedValues, setSelectedValues] = + React.useState(currentFilter); const [selectAll, setSelectAll] = React.useState(false); // Sincronizar selectedValues com currentFilter quando ele mudar @@ -133,10 +147,12 @@ const ExcelFilter: React.FC = ({ const values = filteredData .map((row) => { const value = row[column.field]; - if (value === null || value === undefined) return ""; + if (value === null || value === undefined) return ''; return String(value); }) - .filter((value, index, self) => self.indexOf(value) === index && value !== "") + .filter( + (value, index, self) => self.indexOf(value) === index && value !== '' + ) .sort(); return values; @@ -168,7 +184,9 @@ const ExcelFilter: React.FC = ({ newValues = selectedValues.filter((v) => v !== value); } setSelectedValues(newValues); - setSelectAll(newValues.length === filteredValues.length && filteredValues.length > 0); + setSelectAll( + newValues.length === filteredValues.length && filteredValues.length > 0 + ); }; const handleApply = () => { @@ -206,7 +224,7 @@ const ExcelFilter: React.FC = ({ Filtrar por "{column.headerName}" - +
{/* Opções de ordenação */}
@@ -218,8 +236,7 @@ const ExcelFilter: React.FC = ({ className="h-8 text-xs" onClick={() => handleSort('asc')} > - - A a Z + A a Z
@@ -269,13 +285,15 @@ const ExcelFilter: React.FC = ({ (Selecionar Tudo) - + {filteredValues.map((value) => (
handleValueToggle(value, checked)} + onCheckedChange={(checked: boolean) => + handleValueToggle(value, checked) + } />
- - + - - - {/* Conteúdo Principal - Versão Normal */} - {renderAnaliticoContent(false)} + {/* Conteúdo Principal - Versão Normal */} + {renderAnaliticoContent(false)} {/* Advanced Filters Dialog */} @@ -1310,7 +1350,8 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { Filtros Avançados

- Estes filtros são aplicados sobre os dados já filtrados pela tabela DRE Gerencial. + Estes filtros são aplicados sobre os dados já filtrados pela + tabela DRE Gerencial.

@@ -1337,10 +1378,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { {columns.map((col: any) => ( - + {col.headerName} ))} @@ -1357,8 +1395,8 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { onValueChange={(v: string) => { const next = [...conditions]; next[idx].operator = v; - if (v === "empty" || v === "notEmpty") - next[idx].value = ""; + if (v === 'empty' || v === 'notEmpty') + next[idx].value = ''; setConditions(next); }} > @@ -1376,7 +1414,9 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { - {!(cond.operator === "empty" || cond.operator === "notEmpty") && ( + {!( + cond.operator === 'empty' || cond.operator === 'notEmpty' + ) && (
+ )} {conditions.length > 1 && (
- + +
+ )} - )} - ))}
@@ -1418,7 +1458,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { onClick={() => setConditions((prev) => [ ...prev, - { column: "", operator: "contains", value: "" }, + { column: '', operator: 'contains', value: '' }, ]) } className="flex items-center gap-2 text-blue-600 hover:text-blue-700 hover:bg-blue-50 border-blue-200" @@ -1430,7 +1470,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
- - +