import { useRef, useEffect } from 'react' import SignatureCanvas from 'react-signature-canvas' interface Props { onFirma: (dataUrl: string) => void } /** Pad de firma del cliente; exporta PNG base64 al terminar cada trazo */ export default function SignaturePad({ onFirma }: Props) { const ref = useRef(null) useEffect(() => { // Notifica firma vacĂ­a al montar (estado inicial) onFirma('') // eslint-disable-next-line react-hooks/exhaustive-deps }, []) const limpiar = () => { ref.current?.clear() onFirma('') } const alTerminar = () => { const pad = ref.current if (!pad) return onFirma(pad.isEmpty() ? '' : pad.getTrimmedCanvas().toDataURL('image/png')) } return (
) }