// "use client"

// import { getStringDateWithTimeStart } from "@/utils/date";

// interface DownloadReportParams {
//     fechaI: Date | null;
//     fechaF: Date | null;
//     fileName: string;
//     rol?: string;
//     empresa: string;
//     idCarpeta?: number;
//     setIsDownloading: (isDownloading: boolean) => void;
//     showMessage: (message: string) => void;
// }

// export const useReportExcel = async ({ fechaI, fechaF, setIsDownloading, showMessage, fileName, rol, empresa, idCarpeta }: DownloadReportParams) => {
//     try {
//         const fechaInicio = getStringDateWithTimeStart(fechaI!, 'start');
//         const fechaFin = getStringDateWithTimeStart(fechaF!, 'end');
//         let reporte: any = null;
//         setIsDownloading(true);

//         switch (empresa) {
//             case 'lhiahelpdesk':
//                 reporte = await getExcelReport(
//                     { nombre: fileName, fechaI: fechaInicio, fechaF: fechaFin },
//                     { 'Content-Type': 'application/json' }
//                 );
//                 break;
//             case 'jardin':
//                 reporte = await getExcelReportLhia(
//                     { nombre: fileName, fechaI: fechaInicio, fechaF: fechaFin, rol: rol, idCarpeta: idCarpeta },
//                     { 'Content-Type': 'application/json' }
//                 );
//                 break;
//         }

//         const url = window.URL.createObjectURL(new Blob([reporte]));
//         const link = document.createElement('a');
//         link.href = url;
//         link.setAttribute('download', `${fileName}.xlsx`);
//         document.body.appendChild(link);
//         link.click();
//         link.parentNode?.removeChild(link);

//     } catch (error) {
//         showMessage('Error al exportar el reporte');
//     } finally {
//         setIsDownloading(false);
//     }
// };

// interface DownloadReportParamsCSVMarcimex {
//     fechaI: Date | null;
//     fechaF: Date | null;
//     empresa: string;
//     setIsDownloading: (isDownloading: boolean) => void;
//     showMessage: (message: string) => void;
// }

// export const useReportCSVMarcimex = async ({ fechaI, fechaF, showMessage, empresa, setIsDownloading }: DownloadReportParamsCSVMarcimex) => {
//     setIsDownloading(true);
//     try {
//         const NEXT_PUBLIC_API_LHIA_FLOW = `${process.env.NEXT_PUBLIC_API_LHIA_FLOW}/${empresa}`;
//         const fechaInicio = getStringDateWithTimeStart(fechaI!, 'start');
//         const fechaFin = getStringDateWithTimeStart(fechaF!, 'end');
//         const reporte = await getFullReportCsv(
//             NEXT_PUBLIC_API_LHIA_FLOW,
//             { initDate: fechaInicio, endDate: fechaFin },
//             { 'Content-Type': 'application/json' }
//         );
//         const url = window.URL.createObjectURL(new Blob([reporte]));
//         const link = document.createElement('a');
//         link.href = url;
//         link.setAttribute('download', 'ReporteEstadisticas.csv');
//         document.body.appendChild(link);
//         link.click();
//         link.remove();
//     } catch (error) {
//         showMessage('Error al exportar el reporte');
//     } finally {
//         setIsDownloading(false);
//     }
// };