Spaces:
Sleeping

drop-edit / app /components /PDFDownloadButton.tsx
anititititi's picture
feat: hf-space migration
e8e7389
Raw History Blame Contribute Delete
998 Bytes
'use client'
import { PDFDownloadLink } from '@react-pdf/renderer'
import ResultadoPDF from '@/app/components/ResultadoPDF'
interface PDFDownloadButtonProps {
resultado: any
onDownload?: () => void
}
export default function PDFDownloadButton({ resultado, onDownload }: PDFDownloadButtonProps) {
const slug = (resultado?.nome_estetica || 'editorial')
.toString()
.toLowerCase()
.normalize('NFD')
.replace(/[̀-ͯ]/g, '')
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-|-$/g, '')
return (
<PDFDownloadLink
document={<ResultadoPDF resultado={resultado} />}
fileName={`drop-edit-${slug}.pdf`}
className="w-full text-center bg-gray-100 text-black border border-gray-200 text-[11px] font-medium tracking-widest uppercase py-4 hover:bg-black hover:text-white hover:border-black transition-colors block"
onClick={() => onDownload?.()}
>
{({ loading }) => (loading ? 'Generating PDF…' : '↓ Download PDF')}
</PDFDownloadLink>
)
}