diff --git a/app/(authenticated)/transactions/_columns/index.tsx b/app/(authenticated)/transactions/_columns/index.tsx index 070296d..4757591 100644 --- a/app/(authenticated)/transactions/_columns/index.tsx +++ b/app/(authenticated)/transactions/_columns/index.tsx @@ -3,6 +3,26 @@ import { ColumnDef } from "@tanstack/react-table"; import { Transactions } from "@prisma/client"; import TransactionTypeBadge from "../_components/type-badge"; +import { Button } from "@/app/_components/ui/button"; +import { EditIcon, TrashIcon } from "lucide-react"; + +export const TRANSACTION_CATEGORY_MAP: Record = { + EDUCATION: "Educação", + FOOD: "Alimentação", + HEALTH: "Saúde", + ENTERTAINMENT: "Entretenimento", + HOUSING: "Moradia", + TRANSPORTATION: "Transporte", + SALARY: "Salário", + UTILITY: "Utilidade", +}; + +export const TRANSACTION_PAYMENT_METHOD_MAP: Record = { + CREDIT_CARD: "Cartão de crédito", + DEBIT_CARD: "Cartão de débito", + PIX: "PIX", + BANK_TRANSFER: "Transferência bancária", +}; export const transactionsColumns: ColumnDef[] = [ { @@ -20,34 +40,59 @@ export const transactionsColumns: ColumnDef[] = [ accessorKey: "category", header: "Categoria", cell: ({ row: { original: transaction } }) => { - const categoryMap: Record = { - EDUCATION: "Educação", - FOOD: "Alimentação", - HEALTH: "Saúde", - ENTERTAINMENT: "Entretenimento", - HOUSING: "Moradia", - TRANSPORTATION: "Transporte", - SALARY: "Salário", - UTILITY: "Utilidade", - }; - - return

{categoryMap[transaction.category] || "Outro"}

; + return

{TRANSACTION_CATEGORY_MAP[transaction.category] || "Outro"}

; }, }, { accessorKey: "paymentMethod", header: "Método de pagamento", + cell: ({ row: { original: transaction } }) => { + return ( +

+ {TRANSACTION_PAYMENT_METHOD_MAP[transaction.paymentMethod] || "Outro"} +

+ ); + }, }, { accessorKey: "date", header: "Data", + cell: ({ row: { original: transaction } }) => { + return ( +

+ {new Date(transaction.date).toLocaleDateString("pt-BR", { + day: "2-digit", + month: "long", + year: "numeric", + })} +

+ ); + }, }, { accessorKey: "amount", header: "Valor", + cell: ({ row: { original: transaction } }) => { + return new Intl.NumberFormat("pt-BR", { + style: "currency", + currency: "BRL", + }).format(Number(transaction.amount)); + }, }, { accessorKey: "actions", header: "", + cell: () => { + return ( +
+ + +
+ ); + }, }, ];