import { useState, useEffect } from 'react' import { numWithUnits } from '@/lib/format' import AccordianItem from './accordian-item' import Qr from './qr' import Countdown from './countdown' import PayerData from './payer-data' import Bolt11Info from './bolt11-info' import { useQuery } from '@apollo/client' import { INVOICE } from '@/fragments/wallet' import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants' import { WebLnNotEnabledError } from './payment' export default function Invoice ({ invoice, modal, onPayment, info, successVerb, webLn, webLnError, poll }) { const [expired, setExpired] = useState(new Date(invoice.expiredAt) <= new Date()) const { data, error } = useQuery(INVOICE, SSR ? {} : { pollInterval: FAST_POLL_INTERVAL, variables: { id: invoice.id }, nextFetchPolicy: 'cache-and-network', skip: !poll }) if (data) { invoice = data.invoice } if (error) { return
{JSON.stringify(nostr, null, 2)}
}
/>
: null}