// utils/exportUtils.js export const exportToCSV = (data, filename = "export.csv") => { if (!data || data.length === 0) return; const headers = Object.keys(data[0]); const csvRows = []; // Add headers csvRows.push(headers.join(",")); // Add values data.forEach(row => { const values = headers.map(header => `"${row[header] ?? ""}"`); csvRows.push(values.join(",")); }); // Create CSV Blob const csvContent = csvRows.join("\n"); const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" }); // Create download link const link = document.createElement("a"); const url = URL.createObjectURL(blob); link.setAttribute("href", url); link.setAttribute("download", filename); link.click(); };