import { IListArticles_Response_DTO } from "@shared/contexts";
import { ColumnDef } from "@tanstack/react-table";

import { DataTablaRowActionFunction, DataTableRowActions } from "@/components";
import { Badge } from "@/ui";
import { useMemo } from "react";

export const useCustomerInvoiceDataTableColumns = (
  actions: DataTablaRowActionFunction<IListArticles_Response_DTO>
): ColumnDef<IListArticles_Response_DTO>[] => {
  const customerColumns: ColumnDef<IListArticles_Response_DTO>[] = useMemo(
    () => [
      /*{
      id: "complete_name",
      header: "Nombre",
      accessorFn: (row) => (
        <div className="flex items-center justify-between space-x-4">
          <div className="flex items-center space-x-4">
            <Avatar>
              <AvatarImage src={row.photo_url} />
              <AvatarFallback>
                {acronym(`${row.first_name} ${row.last_name}`)}
              </AvatarFallback>
            </Avatar>
            <div>
              <p className="text-base font-semibold">{`${row.first_name} ${row.last_name}`}</p>
              <p className="mt-1">{row.job_title}</p>
            </div>
          </div>
        </div>
      ),
      enableSorting: true,
      sortingFn: "alphanumeric",
      enableHiding: false,

      cell: ({ renderValue }) => (
        <span className="w-full">
          <>{renderValue()}</>
        </span>
      ),
    },*/
      {
        id: "company",
        accessorKey: "company_name",
        header: "Compañía",
        enableSorting: true,
        sortingFn: "alphanumeric",
      },
      {
        id: "state",
        accessorKey: "state",
        header: "Estado",
        cell: ({ renderValue }) => (
          <Badge variant={"destructive"}>
            <>{renderValue()}</>
          </Badge>
        ),
      },
      {
        id: "phone",
        accessorKey: "phone",
        header: "Phone",
        enableSorting: true,
        sortingFn: "alphanumeric",
      },
      {
        id: "actions",
        header: "Acciones",
        cell: (context) => {
          return <DataTableRowActions rowContext={context} actions={actions} />;
        },
      },
    ],
    [actions]
  );
  return customerColumns;
};
