NEW_CPM/resources/js/components/data-table-column-header-simple-sort.tsx
2025-04-02 17:49:09 +05:45

26 lines
672 B
TypeScript

import { ArrowUpDown } from "lucide-react"
import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
import { DataTableColumnHeaderProps } from "@/types"
export function DataTableColumnHeaderSimple<TData, TValue>({
column,
title,
className,
}: DataTableColumnHeaderProps<TData, TValue>) {
if (!column.getCanSort()) {
return <div className={cn(className)}>{title}</div>
}
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
{title}
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
)
}