From d2da58a896ac1cccd875dd9059a384c4619014e5 Mon Sep 17 00:00:00 2001 From: Kieran Date: Thu, 8 Aug 2024 15:19:23 +0100 Subject: [PATCH] fix ts errors --- src/components/pay-button.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/pay-button.tsx b/src/components/pay-button.tsx index 1b46232..14ad42e 100644 --- a/src/components/pay-button.tsx +++ b/src/components/pay-button.tsx @@ -2,6 +2,14 @@ import { MachineSpec } from "../api"; import "./pay-button.css" +declare global { + interface Window { + btcpay?: { + appendInvoiceFrame(invoiceId: string): void; + } + } +} + export default function VpsPayButton({ spec }: { spec: MachineSpec }) { const serverUrl = "https://btcpay.v0l.io/api/v1/invoices"; @@ -11,7 +19,7 @@ export default function VpsPayButton({ spec }: { spec: MachineSpec }) { const xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200 && this.responseText) { - window.btcpay.appendInvoiceFrame(JSON.parse(this.responseText).invoiceId); + window.btcpay?.appendInvoiceFrame(JSON.parse(this.responseText).invoiceId); } }; xhttp.open('POST', serverUrl, true);