Skip to content

Commit

Permalink
feat: Add transaction type column to columns.tsx files
Browse files Browse the repository at this point in the history
  • Loading branch information
xDeFc0nx committed Jan 25, 2025
1 parent 99fe94a commit f87068f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
6 changes: 6 additions & 0 deletions client/src/components/transaction/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ export const columns: ColumnDef<Transaction>[] = [
accessorKey: 'Description',
header: 'Description',
},
{
accessorKey: 'type',
header: () => <div className="text-right">Type</div>,
cell: ({ row }) => <div className="text-right">{row.original.Type}</div>,
},

{
accessorKey: 'amount',
header: () => <div className="text-right">Amount</div>,
cell: ({ row }) => <div className="text-right">{row.original.Amount}</div>,
},

{
id: 'actions',
enableHiding: false,
Expand Down
23 changes: 5 additions & 18 deletions client/src/pages/(secure)/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,16 @@ import {
import { useUserData, type Transaction } from '@/components/context/userData';

export const columns: ColumnDef<Transaction>[] = [
{
accessorKey: 'CreatedAt',
header: 'Created At',
cell: ({ row }) => {
const rawDate = row.getValue('CreatedAt') as string;
const date = new Date(rawDate);

if (isNaN(date.getTime())) throw new Error('Invalid date');

return (
<div>
{date.toLocaleString('en-US', {
dateStyle: 'short',
timeStyle: 'medium',
})}
</div>
);
},
},
{
accessorKey: 'Description',
header: 'Description',
},
{
accessorKey: 'type',
header: () => <div className="text-right">Type</div>,
cell: ({ row }) => <div className="text-right">{row.original.Type}</div>,
},

{
accessorKey: 'amount',
Expand Down

0 comments on commit f87068f

Please sign in to comment.