
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 { useDeleteOffer } from "../../api/Offer";
import { MdEmail } from "react-icons/md";
import { useModalState } from "../../zustand/Modal";

function fnDelete(props :any ){}

const useTableColumns :any = () => {
  const [t] = useTranslation();
  const deleteMutation = useDeleteOffer()
  const navigate = useNavigate()
  const {setIsOpen} = useModalState(state=>state)
    return useMemo(
    () => [
 
      {
        name: t("id"),
        sortable: true, // Enable sorting for id column
        center: true,
        selector: (row: any) => row.id, // Specify selector function for sorting
      },      {
        name: t("name"),
        sortable: false,
        center: "true",
        cell: (row:any) => row?.name
      },
      {
        name: t("image"),
        sortable: false,
        center: "true",
        cell: (row:any) =>  {
          let str = row?.images?.[0]?.url;
          return <ColumnsImage src={str} />
        }
        
      },

      {
        name: t("description"),
        sortable: false,
        center: "true",
        cell: (row:any) => row?.description
      },

      {
        name: t("price"),
        sortable: false,
        center: "true",
        cell: (row:any) => row?.price
      },
      {
        name: "#",
        sortable: false,
        center: true,
        cell: (row:any) => (
          <Actions
            objectToEdit={row}
            showEdit
            onEdit={()=> navigate(`${row.id}`) }
            showView={false}
            onDelete={() => deleteMutation.mutate({ id: row.id })}
          >  
          </Actions>
        ),
      },

    ],
    [t]
  );
};

export default useTableColumns;

