
import React, { useMemo } from "react";
import { useTranslation } from "react-i18next";
import Actions from "../../Components/Ui/tables/Actions";
import ColumnsImage from "../../Components/Columns/ColumnsImage";
import { useNavigate } from "react-router-dom";
import { useDeleteProduct } from "../../api/product";

function fnDelete(props :any ){}

const useTableColumns :any = () => {
  const [t] = useTranslation();
  const navigate = useNavigate();
  const deleteMutation = useDeleteProduct();
  return useMemo(
    () => [
 
      {
        name: t("category name"),
        center: "true",
        cell: (row: any) => row?.category?.name
      },
      {
        name: t("id"),
        sortable: false,
        center: "true",
        cell: (row:any) => row?.id
      },
      {
        name: t("name"),
        sortable: false,
        center: "true",
        cell: (row:any) => row?.name
      },
      {
        name: t("description"),
        sortable: false,
        center: "true",
        cell: (row:any) => row?.description
      },
      {
        name: t("model"),
        sortable: false,
        center: "true",
        cell: (row:any) => row?.model
      },
      {
        name: t("image"),
        center: "true",
        cell: (row: any) => {
          return (
            <ColumnsImage src={row?.file} />
          )
        }
      },
      {
        name: "#",
        sortable: false,
        center: "true",
        cell: (row) => (
            <Actions

            // importnat to return the row in on Edit Function to store in objectToEdit That Upper in Edit Modal 
              onEdit={() => row}
              objectToEdit={row}
              showEdit={true}
              showView={false}
              showDelete={true}
              onDelete={() => deleteMutation.mutate({ id: row.id })}
            />
        ),
      },
    ],
    [t]
  );
};

export default useTableColumns;

