diff --git a/src/components/BitcoinQR.tsx b/src/components/BitcoinQR.tsx index a666391e..a033b463 100644 --- a/src/components/BitcoinQR.tsx +++ b/src/components/BitcoinQR.tsx @@ -6,17 +6,17 @@ import { AmountSats, BitcoinAddress } from '../libs/JmWalletApi' interface BitcoinQRProps { address: BitcoinAddress - sats: AmountSats - errorCorrectionLevel: QRCode.QRCodeErrorCorrectionLevel + amount?: AmountSats + errorCorrectionLevel?: QRCode.QRCodeErrorCorrectionLevel width?: number } -export const BitcoinQR = ({ address, sats, errorCorrectionLevel = 'H', width = 260 }: BitcoinQRProps) => { +export const BitcoinQR = ({ address, amount, errorCorrectionLevel = 'H', width = 260 }: BitcoinQRProps) => { const [data, setData] = useState() const [image, setImage] = useState() useEffect(() => { - const btc = satsToBtc(String(sats)) || 0 + const btc = amount ? satsToBtc(String(amount)) || 0 : 0 const uri = `bitcoin:${address}${btc > 0 ? `?amount=${btc.toFixed(8)}` : ''}` QRCode.toDataURL(uri, { @@ -31,7 +31,7 @@ export const BitcoinQR = ({ address, sats, errorCorrectionLevel = 'H', width = 2 setImage(undefined) setData(uri) }) - }, [address, sats, errorCorrectionLevel, width]) + }, [address, amount, errorCorrectionLevel, width]) return (
diff --git a/src/components/CopyButton.tsx b/src/components/CopyButton.tsx index 713afc26..c3a47933 100644 --- a/src/components/CopyButton.tsx +++ b/src/components/CopyButton.tsx @@ -38,15 +38,25 @@ interface CopyableProps { onSuccess?: () => void onError?: (e: Error) => void className?: string + disabled?: boolean } -function Copyable({ value, onSuccess, onError, className, children, ...props }: PropsWithChildren) { +function Copyable({ + value, + onSuccess, + onError, + className, + children, + disabled, + ...props +}: PropsWithChildren) { const valueFallbackInputRef = useRef(null) return ( <>