diff --git a/.eslintrc.json b/.eslintrc.json index 13015d6..0149fec 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,8 @@ { "extends": "next/core-web-vitals", "rules": { - "@typescript-eslint/no-explicit-any": "off" + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/no-empty-object-type": "off" } } diff --git a/src/app/DRE/analitico.tsx b/src/app/DRE/analitico.tsx index 157458c..28bdd1b 100644 --- a/src/app/DRE/analitico.tsx +++ b/src/app/DRE/analitico.tsx @@ -114,7 +114,8 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { { accessorKey: "data_competencia", header: "Data Comp.", - cell: ({ getValue }: any) => { + filterFn: "advancedText", + cell: ({ getValue }: { getValue: () => string }) => { const value = getValue(); return new Date(value).toLocaleDateString('pt-BR'); } @@ -122,7 +123,8 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { { accessorKey: "data_vencimento", header: "Data Venc.", - cell: ({ getValue }: any) => { + filterFn: "advancedText", + cell: ({ getValue }: { getValue: () => string }) => { const value = getValue(); return new Date(value).toLocaleDateString('pt-BR'); } @@ -130,20 +132,22 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { { accessorKey: "data_caixa", header: "Data Caixa", - cell: ({ getValue }: any) => { + filterFn: "advancedText", + cell: ({ getValue }: { getValue: () => string }) => { const value = getValue(); return new Date(value).toLocaleDateString('pt-BR'); } }, - { accessorKey: "codigo_fornecedor", header: "Cód. Fornec." }, - { accessorKey: "nome_fornecedor", header: "Fornecedor" }, - { accessorKey: "codigo_centrocusto", header: "Cód. Centro" }, - { accessorKey: "codigo_conta", header: "Cód. Conta" }, - { accessorKey: "conta", header: "Conta" }, + { accessorKey: "codigo_fornecedor", header: "Cód. Fornec.", filterFn: "advancedText" }, + { accessorKey: "nome_fornecedor", header: "Fornecedor", filterFn: "advancedText" }, + { accessorKey: "codigo_centrocusto", header: "Cód. Centro", filterFn: "advancedText" }, + { accessorKey: "codigo_conta", header: "Cód. Conta", filterFn: "advancedText" }, + { accessorKey: "conta", header: "Conta", filterFn: "advancedText" }, { accessorKey: "valor", header: "Valor", - cell: ({ getValue }: any) => { + filterFn: "advancedText", + cell: ({ getValue }: { getValue: () => number }) => { const value = getValue(); const formatted = new Intl.NumberFormat('pt-BR', { style: 'currency', @@ -157,9 +161,9 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { ); } }, - { accessorKey: "historico", header: "Histórico" }, - { accessorKey: "historico2", header: "Histórico 2" }, - { accessorKey: "recnum", header: "Recnum" }, + { accessorKey: "historico", header: "Histórico", filterFn: "advancedText" }, + { accessorKey: "historico2", header: "Histórico 2", filterFn: "advancedText" }, + { accessorKey: "recnum", header: "Recnum", filterFn: "advancedText" }, ], [] ); @@ -228,9 +232,15 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { }, []); const applyFilters = () => { - const filters = conditions - .filter((c) => c.column && (c.operator === "empty" || c.operator === "notEmpty" || (c.value ?? "") !== "")) - .map((c) => ({ id: c.column, value: { operator: c.operator, value: c.value } })); + const validConditions = conditions.filter((c) => + c.column && (c.operator === "empty" || c.operator === "notEmpty" || (c.value ?? "") !== "") + ); + + const filters = validConditions.map((c) => ({ + id: c.column, + value: { operator: c.operator, value: c.value } + })); + setColumnFilters(filters); setOpen(false); }; @@ -336,16 +346,16 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { )} - +
- {table.getHeaderGroups().map((hg: any) => ( + {table.getHeaderGroups().map((hg) => ( - {hg.headers.map((header: any) => { + {hg.headers.map((header) => { const sorted = header.column.getIsSorted(); return ( ); })} @@ -389,7 +399,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
Carregando dados analíticos... -
+ ) : virtualRows.length === 0 ? ( @@ -400,13 +410,13 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { - + Nenhum dado analítico encontrado para os filtros aplicados. - + ) : ( - virtualRows.map((virtualRow: any) => { + virtualRows.map((virtualRow) => { const row = table.getRowModel().rows[virtualRow.index]; return ( - {row.getVisibleCells().map((cell: any, cellIndex: number) => ( + {row.getVisibleCells().map((cell, cellIndex) => ( ))} @@ -446,16 +456,16 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { - {data.length > 0 && ( + {data.length > 0 && (
-
+
-
-
+
+

Total de Registros: {table.getRowModel().rows.length}

@@ -469,13 +479,13 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { style: 'currency', currency: 'BRL', }).format(totalValor)} - - + +

Soma de todos os valores

-
- )} +
+ )} @@ -502,11 +512,11 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { - {columns.map((col: any) => ( - - {col.header} - - ))} + {columns.map((col) => ( + + {col.header} + + ))}
@@ -589,7 +599,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) { Adicionar condição - +
{flexRender(header.column.columnDef.header, header.getContext())} - +
{sorted === "asc" ? ( @@ -367,9 +377,9 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
- )} - - + )} + +
{flexRender(cell.column.columnDef.cell, cell.getContext())} -
+