stacker.news/pages/invoices/[id].js

30 lines
980 B
JavaScript
Raw Normal View History

2021-05-06 21:15:22 +00:00
import { useQuery } from '@apollo/client'
import { Invoice } from '@/components/invoice'
import { QrSkeleton } from '@/components/qr'
import { CenterLayout } from '@/components/layout'
2021-10-26 20:49:37 +00:00
import { useRouter } from 'next/router'
import { INVOICE } from '@/fragments/wallet'
import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
import { getGetServerSideProps } from '@/api/ssrApollo'
// force SSR to include CSP nonces
export const getServerSideProps = getGetServerSideProps({ query: null })
2021-05-06 21:15:22 +00:00
2021-10-26 20:49:37 +00:00
export default function FullInvoice () {
const router = useRouter()
const { data, error } = useQuery(INVOICE, SSR
? {}
: {
pollInterval: FAST_POLL_INTERVAL,
variables: { id: router.query.id },
nextFetchPolicy: 'cache-and-network'
})
2021-05-06 21:15:22 +00:00
return (
<CenterLayout>
{error && <div>{error.toString()}</div>}
2024-04-16 21:20:13 +00:00
{data ? <Invoice invoice={data.invoice} /> : <QrSkeleton description status='loading' bolt11Info />}
</CenterLayout>
)
2021-05-06 21:15:22 +00:00
}