
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 { useDeleteCategory } from "../../api/category";

function fnDelete(props :any ){}

const useTableColumns :any = () => {
  const [t] = useTranslation();
  const navigate = useNavigate();
  const deleteMutation = useDeleteCategory();
  return useMemo(
    () => [
      {
        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("parent_id"), 
      //   sortable: false,
      //   center: "true",
      //   cell: (row:any) => row?.parent_id == null ? "there is no parent id" : row?.parent_id 
      // },
      {
        name: t("image"),
        center: "true",
        cell: (row: any) => {          
          return (
            <ColumnsImage src={row?.image} />
          )
        }
      },
     
      {
        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}
              onView={()=>{navigate('/')}}
              objectToEdit={row}
              showEdit={true}
              showView={false}
              onDelete={() => deleteMutation.mutate({ id: row.id })}
            />
        ),
      },
    ],
    [t]
  );
};

export default useTableColumns;

