diff --git a/frontend/app/all-customers/columns.tsx b/frontend/app/all-customers/columns.tsx index 5a3ebe6..3836b31 100644 --- a/frontend/app/all-customers/columns.tsx +++ b/frontend/app/all-customers/columns.tsx @@ -1,7 +1,7 @@ "use client"; import { ColumnDef } from "@tanstack/react-table"; -import { Ghost, MoreHorizontal } from "lucide-react"; +import { MoreHorizontal, ArrowUpDown } from "lucide-react"; import { Button } from "@/components/ui/button"; import { DropdownMenu, @@ -29,7 +29,19 @@ export const columns: ColumnDef[] = [ }, { accessorKey: "name", - header: "Name", + header: ({ column }) => { + return ( +
+ +
+ ); + }, }, { accessorKey: "occupation", @@ -46,7 +58,20 @@ export const columns: ColumnDef[] = [ }, { accessorKey: "balance", - header: () =>
Balance
, + // header: () =>
Balance
, + header: ({ column }) => { + return ( +
+ +
+ ); + }, cell: ({ row }) => { const amount = parseFloat(row.getValue("balance")); const formatted = new Intl.NumberFormat("en-IN", { diff --git a/frontend/app/all-customers/data-table.tsx b/frontend/app/all-customers/data-table.tsx index 4105c31..99e164c 100644 --- a/frontend/app/all-customers/data-table.tsx +++ b/frontend/app/all-customers/data-table.tsx @@ -1,11 +1,15 @@ "use client"; +import { useState } from "react"; + import { ColumnDef, flexRender, getCoreRowModel, getPaginationRowModel, useReactTable, + SortingState, + getSortedRowModel, } from "@tanstack/react-table"; import { @@ -35,11 +39,18 @@ export function DataTable({ columns, data, }: DataTableProps) { + const [sorting, setSorting] = useState([]); + const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), + onSortingChange: setSorting, + getSortedRowModel: getSortedRowModel(), + state: { + sorting, + }, }); return (