import { useTranslation } from "react-i18next"; import { useDeleteOrder } from "../../api/order"; import Actions from "../../Components/Ui/tables/Actions"; import { useNavigate } from "react-router-dom"; import { FaCheck, FaTimes, FaClock, FaBan } from 'react-icons/fa'; const useTableColumns = () => { const [t] = useTranslation(); const navigate = useNavigate() const deleteMutation = useDeleteOrder() const language = localStorage.getItem("language") ?? "en" let column = [ { name: t("order_code"), sortable: false, center:true, selector:(row:any) => row?.id, }, { name: t("name"), sortable: false, center:true, selector:(row:any) => row?.user?.name, }, { name: t("email"), sortable: false, center:true, selector:(row:any) => row?.user?.email, }, { name: t("status"), center: true, width:"250", cell: (row: any) => { let status = row?.state; let icon; // Assigning an icon component based on the status switch (status) { case 'pending_approve': icon = ; break; case 'approved': icon = ; break; case 'rejected': icon = ; break; case 'pending_cancellation': icon = ; break; default: icon = null; } // Rendering the status with its corresponding icon return (
{icon} {status}
); } }, { name: t("total"), center: true, cell:(row:any)=>{ return (row?.total) } }, { name: "#", center: true, cell: (row:any) => deleteMutation.mutate({order_id:row.id })} showEdit={true} onView={()=>navigate(`/order/view/${row?.id}` , {replace:true})} onEdit={()=>navigate(`/order/${row?.id}` , {replace:true})} /> }, ] return column }; export default useTableColumns;