From 1deaa80f48f485c1c69504a4210305422689591a Mon Sep 17 00:00:00 2001 From: Felipe Coutinho Date: Thu, 22 Jan 2026 12:38:52 +0000 Subject: [PATCH] refactor(lancamentos): melhora layout e UX da tabela MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Adiciona coluna de categoria com ícone - Move data de compra para dentro da célula de nome - Simplifica exibição de pagador removendo Badge - Refatora coluna conta/cartão com tooltips informativos - Adiciona suporte a liquidação para Transferência bancária e Pré-Pago - Remove imports não utilizados (RiBankCard2Line, RiBankLine) Co-Authored-By: Claude Opus 4.5 --- .../lancamentos/table/lancamentos-table.tsx | 171 ++++++++++-------- 1 file changed, 100 insertions(+), 71 deletions(-) diff --git a/components/lancamentos/table/lancamentos-table.tsx b/components/lancamentos/table/lancamentos-table.tsx index f107c16..c57f924 100644 --- a/components/lancamentos/table/lancamentos-table.tsx +++ b/components/lancamentos/table/lancamentos-table.tsx @@ -1,4 +1,5 @@ "use client"; +import { CategoryIcon } from "@/components/categorias/category-icon"; import { EmptyState } from "@/components/empty-state"; import MoneyValues from "@/components/money-values"; import { TypeBadge } from "@/components/type-badge"; @@ -45,8 +46,6 @@ import { RiAddCircleFill, RiAddCircleLine, RiArrowLeftRightLine, - RiBankCard2Line, - RiBankLine, RiChat1Line, RiCheckLine, RiDeleteBin5Line, @@ -69,6 +68,7 @@ import { RowSelectionState, SortingState, useReactTable, + VisibilityState, } from "@tanstack/react-table"; import Image from "next/image"; import Link from "next/link"; @@ -152,13 +152,10 @@ const buildColumns = ({ enableHiding: false, }, { + id: "purchaseDate", accessorKey: "purchaseDate", - header: "Data", - cell: ({ row }) => ( - - {formatDate(row.original.purchaseDate)} - - ), + header: () => null, + cell: () => null, }, { accessorKey: "name", @@ -166,6 +163,7 @@ const buildColumns = ({ cell: ({ row }) => { const { name, + purchaseDate, installmentCount, currentInstallment, paymentMethod, @@ -192,16 +190,21 @@ const buildColumns = ({ return ( - - - + + + {formatDate(purchaseDate)} + + + + + {name} + + + {name} - - - - {name} - - + + + {isDivided && ( @@ -359,23 +362,37 @@ const buildColumns = ({ ); }, }, + { + accessorKey: "categoriaName", + header: "Categoria", + cell: ({ row }) => { + const { categoriaName, categoriaIcon } = row.original; + + if (!categoriaName) { + return ; + } + + return ( + + + {categoriaName} + + ); + }, + }, { accessorKey: "pagadorName", header: "Pagador", cell: ({ row }) => { const { pagadorId, pagadorName, pagadorAvatar } = row.original; - if (!pagadorName) { - return ; - } - const label = pagadorName.trim() || "Sem pagador"; const displayName = label.split(/\s+/)[0] ?? label; const avatarSrc = getAvatarSrc(pagadorAvatar); const initial = displayName.charAt(0).toUpperCase() || "?"; const content = ( <> - + {initial} @@ -387,30 +404,18 @@ const buildColumns = ({ if (!pagadorId) { return ( - - {content} - + {content} ); } return ( - - - {content} - - + {content} + ); }, }, @@ -427,6 +432,7 @@ const buildColumns = ({ contaId, userId, } = row.original; + const isCartao = Boolean(cartaoName); const label = cartaoName ?? contaName; const logoSrc = resolveLogoSrc(cartaoLogo ?? contaLogo); const href = cartaoId @@ -434,46 +440,57 @@ const buildColumns = ({ : contaId ? `/contas/${contaId}/extrato` : null; - const Icon = cartaoId ? RiBankCard2Line : contaId ? RiBankLine : null; const isOwnData = userId === currentUserId; - if (!label) { - return "—"; - } - const content = ( - <> - {logoSrc ? ( + + {logoSrc && ( {`Logo - ) : null} + )} {label} - {Icon ? ( - - ) : null} - + ); - if (!isOwnData) { - return
{content}
; + if (!isOwnData || !href) { + return ( + + {content} + + {isCartao ? "Cartão" : "Conta"}: {label} + + + ); } return ( - - {content} - + + + + {logoSrc && ( + {`Logo + )} + {label} + + + + {isCartao ? "Cartão" : "Conta"}: {label} + + ); }, }, @@ -494,6 +511,8 @@ const buildColumns = ({ "Cartão de crédito", "Dinheiro", "Cartão de débito", + "Transferência bancária", + "Pré-Pago | VR/VA", ].includes(paymentMethod); if (!showSettlementButton) { @@ -504,7 +523,9 @@ const buildColumns = ({ paymentMethod === "Pix" || paymentMethod === "Boleto" || paymentMethod === "Dinheiro" || - paymentMethod === "Cartão de débito"; + paymentMethod === "Cartão de débito" || + paymentMethod === "Transferência bancária" || + paymentMethod === "Pré-Pago | VR/VA"; const readOnly = row.original.readonly; const loading = isSettlementLoading(row.original.id); const settled = Boolean(row.original.isSettled); @@ -512,11 +533,15 @@ const buildColumns = ({ return (