"use client";
import { useState } from "react";
import { FileDown, Loader2, FileSpreadsheet, FileText } from "lucide-react";
import { useExport } from "@/hooks/useExport";
import { toast } from "react-hot-toast";
export function ExportPanel() {
const { exportSnapshot, exportAuditTrail, isLoading, error } = useExport();
const handleExportSnapshot = async (format: "csv" | "xlsx") => {
try {
await exportSnapshot(format);
const formatName = format === "csv" ? "CSV" : "Excel";
toast.success(`Inventory snapshot exported as ${formatName}`);
} catch (err) {
// Error handled by hook
}
};
const handleExportAuditTrail = async (format: "csv" | "xlsx") => {
try {
await exportAuditTrail(format);
const formatName = format === "csv" ? "CSV" : "Excel";
toast.success(`Audit trail exported as ${formatName}`);
} catch (err) {
// Error handled by hook
}
};
return (
{/* Inventory Snapshot Section */}
Inventory Snapshot
Export current inventory state with all item details
{/* Audit Trail Section */}
Audit Trail
Complete log of system actions and changes
{error && (
Error: {error}
)}
);
}