fix ts errors

This commit is contained in:
Kieran 2024-08-08 15:19:23 +01:00
parent d889a0c6f8
commit d2da58a896
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -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);