fix: correção dos valores da coluna

This commit is contained in:
Alessandro Gonçaalves 2025-10-22 18:40:38 -03:00
parent 0d7d3986f4
commit b0a40fcc16
1 changed files with 22 additions and 28 deletions

View File

@ -251,22 +251,20 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
width: 130, width: 130,
sortable: true, sortable: true,
resizable: true, resizable: true,
valueFormatter: (params: any) => { renderCell: (params: any) => {
const value = params.value; const value = params.value;
if (value === null || value === undefined || value === "" || value === 0) return "-"; if (value === null || value === undefined || value === "" || value === 0) return "-";
const numValue = typeof value === "string" ? parseFloat(value) : Number(value); const numValue = typeof value === "string" ? parseFloat(value) : Number(value);
if (isNaN(numValue)) return "-"; if (isNaN(numValue)) return "-";
return new Intl.NumberFormat("pt-BR", { const formatted = new Intl.NumberFormat("pt-BR", {
style: "currency", style: "currency",
currency: "BRL", currency: "BRL",
}).format(numValue); }).format(numValue);
}, return (
cellClassName: (params: any) => { <span className={numValue < 0 ? "text-red-600" : "text-gray-900"}>
const value = params.value; {formatted}
if (value === null || value === undefined || value === "" || value === 0) return "text-gray-500"; </span>
const numValue = typeof value === "string" ? parseFloat(value) : Number(value); );
if (isNaN(numValue)) return "text-gray-500";
return numValue < 0 ? "text-red-600" : "text-gray-900";
}, },
}, },
{ {
@ -276,22 +274,20 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
width: 140, width: 140,
sortable: true, sortable: true,
resizable: true, resizable: true,
valueFormatter: (params: any) => { renderCell: (params: any) => {
const value = params.value; const value = params.value;
if (value === null || value === undefined || value === "" || value === 0) return "-"; if (value === null || value === undefined || value === "" || value === 0) return "-";
const numValue = typeof value === "string" ? parseFloat(value) : Number(value); const numValue = typeof value === "string" ? parseFloat(value) : Number(value);
if (isNaN(numValue)) return "-"; if (isNaN(numValue)) return "-";
return new Intl.NumberFormat("pt-BR", { const formatted = new Intl.NumberFormat("pt-BR", {
style: "currency", style: "currency",
currency: "BRL", currency: "BRL",
}).format(numValue); }).format(numValue);
}, return (
cellClassName: (params: any) => { <span className={numValue < 0 ? "text-red-600" : "text-gray-900"}>
const value = params.value; {formatted}
if (value === null || value === undefined || value === "" || value === 0) return "text-gray-500"; </span>
const numValue = typeof value === "string" ? parseFloat(value) : Number(value); );
if (isNaN(numValue)) return "text-gray-500";
return numValue < 0 ? "text-red-600" : "text-gray-900";
}, },
}, },
{ {
@ -301,22 +297,20 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
width: 130, width: 130,
sortable: true, sortable: true,
resizable: true, resizable: true,
valueFormatter: (params: any) => { renderCell: (params: any) => {
const value = params.value; const value = params.value;
if (value === null || value === undefined || value === "" || value === 0) return "-"; if (value === null || value === undefined || value === "" || value === 0) return "-";
const numValue = typeof value === "string" ? parseFloat(value) : Number(value); const numValue = typeof value === "string" ? parseFloat(value) : Number(value);
if (isNaN(numValue)) return "-"; if (isNaN(numValue)) return "-";
return new Intl.NumberFormat("pt-BR", { const formatted = new Intl.NumberFormat("pt-BR", {
style: "currency", style: "currency",
currency: "BRL", currency: "BRL",
}).format(numValue); }).format(numValue);
}, return (
cellClassName: (params: any) => { <span className={numValue < 0 ? "text-red-600" : "text-gray-900"}>
const value = params.value; {formatted}
if (value === null || value === undefined || value === "" || value === 0) return "text-gray-500"; </span>
const numValue = typeof value === "string" ? parseFloat(value) : Number(value); );
if (isNaN(numValue)) return "text-gray-500";
return numValue < 0 ? "text-red-600" : "text-gray-900";
}, },
}, },
{ {
@ -341,7 +335,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
width: 80, width: 80,
sortable: true, sortable: true,
resizable: true, resizable: true,
valueFormatter: (params: any) => params.value || "-", renderCell: (params: any) => params.value || "-",
}, },
] as any, []); ] as any, []);