import { Button } from "@mui/material";
import { Download, Eye } from "lucide-react";
import { useState } from "react";

// Composant bouton d'aperçu à ajouter dans votre header
export function PDFActionButtons({ 
    onPreview, 
    onDownload 
}: { 
    onPreview: () => void; 
    onDownload?: () => void;
}) {
    return (
        <div className="flex items-center gap-2">
            <Button
                variant="outlined"
                startIcon={<Eye size={18} />}
                onClick={onPreview}
                sx={{
                    textTransform: 'capitalize',
                    borderColor: '#d1d5db',
                    color: '#374151',
                    borderRadius: '9999px',
                    '&:hover': { 
                        borderColor: '#9ca3af', 
                        backgroundColor: 'rgba(0,0,0,0.02)' 
                    }
                }}
            >
                Aperçu
            </Button>
            
            <Button
                variant="outlined"
                startIcon={<Download size={18} />}
                onClick={onDownload || onPreview}
                sx={{
                    textTransform: 'capitalize',
                    borderColor: '#d1d5db',
                    color: '#374151',
                    borderRadius: '9999px',
                    '&:hover': { 
                        borderColor: '#9ca3af', 
                        backgroundColor: 'rgba(0,0,0,0.02)' 
                    }
                }}
            >
                PDF
            </Button>
        </div>
    );
}


export function usePDFPreview() {
    const [showPreview, setShowPreview] = useState(false);

    const openPreview = () => setShowPreview(true);
    const closePreview = () => setShowPreview(false);

    return { showPreview, openPreview, closePreview };
}
