2021-05-06 21:15:22 +00:00
|
|
|
import { useQuery } from '@apollo/client'
|
2024-03-20 00:37:31 +00:00
|
|
|
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'
|
2024-03-20 00:37:31 +00:00
|
|
|
import { INVOICE } from '@/fragments/wallet'
|
2024-04-08 14:13:12 +00:00
|
|
|
import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
|
2024-03-20 00:37:31 +00:00
|
|
|
import { getGetServerSideProps } from '@/api/ssrApollo'
|
2024-02-13 22:40:26 +00:00
|
|
|
|
|
|
|
// 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()
|
2023-07-31 19:54:30 +00:00
|
|
|
const { data, error } = useQuery(INVOICE, SSR
|
|
|
|
? {}
|
|
|
|
: {
|
2024-04-08 14:13:12 +00:00
|
|
|
pollInterval: FAST_POLL_INTERVAL,
|
2023-07-31 19:54:30 +00:00
|
|
|
variables: { id: router.query.id },
|
|
|
|
nextFetchPolicy: 'cache-and-network'
|
|
|
|
})
|
2021-05-06 21:15:22 +00:00
|
|
|
|
2023-07-23 15:08:43 +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 />}
|
2023-07-23 15:08:43 +00:00
|
|
|
</CenterLayout>
|
|
|
|
)
|
2021-05-06 21:15:22 +00:00
|
|
|
}
|