"use client";
import {
  useDeleteContactUs,
  useReadAllContactUs,
} from "@/hooks/queries/useContactUsQuery";
import { TContact } from "@/lib/api/types/TContacts";
import { usePathname, useRouter } from "next/navigation";
import { useState } from "react";
export const useContactUsListPresenter = () => {
  const [isModalOpen, setIsModalOpen] = useState(false);
  const [currentContact, setCurrentContact] = useState<TContact>();
  const columns: string[] = [
    "row",
    "Full name",
    "email",
    "status",
    "phone",
    "created at",
    "actions",
  ];
  const pathname = usePathname();
  const router = useRouter();
  const { data, isPending } = useReadAllContactUs();
  const { mutate: deleteContactUS } = useDeleteContactUs(() =>
    setIsModalOpen(false),
  );

  const onConfirmDelete = () => {
    if (!currentContact) return;
    deleteContactUS(currentContact?.id);
  };
  return {
    columns,
    pathname,
    router,
    isPending,
    contacts: data?.data.contacts,
    onConfirmDelete,
    setIsModalOpen,
    setCurrentContact,
    isModalOpen,
    currentContact,
  };
};
