import { ColumnDef } from "@tanstack/react-table";
import { Checkbox } from "@/app/shadcn_components/ui/checkbox";
import { formatNumber } from "@/app/utils";
import { Recommendation } from "@/app/db/schema/recommendations";

const uvalueColumns: ColumnDef<Recommendation>[] = [
  {
    accessorKey: "description",
    header: "Description",
  },
  {
    accessorKey: "estimatedCost",
    header: "Estimated Cost",
    cell: ({ row }) => {
      return <div>£{formatNumber(row.getValue("estimatedCost"))}</div>;
    },
  },
  {
    accessorKey: "newUValue",
    header: "New U-Value",
  },
  {
    accessorKey: "default",
    id: "default",
    header: "Selected?",
    cell: ({ row }) => (
      <Checkbox
        checked={row.getIsSelected()}
        onCheckedChange={(value) => {
          if (value === true && !row.getIsSelected()) {
            row.toggleSelected(true);
          }
        }}
        aria-label="Select row"
      />
    ),
    enableSorting: false,
    enableHiding: false,
  },
];

export default uvalueColumns;
