Files
WealthySmart/frontend/src/components/ui/data-table-column-header.tsx
Carlos Escalante 2cd0d3b2e1
All checks were successful
Deploy to VPS / deploy (push) Successful in 28s
Migrate all components and pages to shadcn/ui with DataTable
Replace custom markup across all pages and components with shadcn/ui
primitives (Dialog, Sheet, Select, Card, Tabs, etc.). Add reusable
DataTable component powered by @tanstack/react-table with sortable
column headers and client-side pagination. Introduce TransactionList
with responsive mobile cards and desktop DataTable, dashboard section
customization (DashboardSection, SectionConfigDialog), and settings
API types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 14:45:44 -06:00

42 lines
1.0 KiB
TypeScript

import { type Column } from '@tanstack/react-table';
import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
interface DataTableColumnHeaderProps<TData, TValue> {
column: Column<TData, TValue>;
title: string;
className?: string;
}
export function DataTableColumnHeader<TData, TValue>({
column,
title,
className,
}: DataTableColumnHeaderProps<TData, TValue>) {
if (!column.getCanSort()) {
return <div className={cn(className)}>{title}</div>;
}
const sorted = column.getIsSorted();
return (
<Button
variant="ghost"
size="sm"
className={cn('-ml-3 h-8', className)}
onClick={() => column.toggleSorting(sorted === 'asc')}
>
{title}
{sorted === 'desc' ? (
<ArrowDown className="ml-1 h-3.5 w-3.5" />
) : sorted === 'asc' ? (
<ArrowUp className="ml-1 h-3.5 w-3.5" />
) : (
<ArrowUpDown className="ml-1 h-3.5 w-3.5 text-muted-foreground/50" />
)}
</Button>
);
}