2021-05-06 21:15:22 +00:00
|
|
|
import { useQuery } from '@apollo/client'
|
|
|
|
import gql from 'graphql-tag'
|
|
|
|
import { Invoice, InvoiceSkeleton } from '../../components/invoice'
|
|
|
|
import LayoutCenter from '../../components/layout-center'
|
|
|
|
|
|
|
|
export async function getServerSideProps ({ params: { id } }) {
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function FullInvoice ({ id }) {
|
|
|
|
const query = gql`
|
|
|
|
{
|
2021-05-11 15:52:50 +00:00
|
|
|
invoice(id: ${id}) {
|
|
|
|
id
|
|
|
|
bolt11
|
|
|
|
msatsReceived
|
|
|
|
cancelled
|
|
|
|
confirmedAt
|
|
|
|
expiresAt
|
|
|
|
}
|
2021-05-06 21:15:22 +00:00
|
|
|
}`
|
|
|
|
return (
|
|
|
|
<LayoutCenter>
|
|
|
|
<LoadInvoice query={query} />
|
|
|
|
</LayoutCenter>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function LoadInvoice ({ query }) {
|
2021-05-11 15:52:50 +00:00
|
|
|
const { loading, error, data } = useQuery(query, { pollInterval: 1000 })
|
2021-05-06 21:15:22 +00:00
|
|
|
if (error) return <div>error</div>
|
|
|
|
if (!data || loading) {
|
2021-05-11 15:52:50 +00:00
|
|
|
return <InvoiceSkeleton status='loading' />
|
2021-05-06 21:15:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return <Invoice invoice={data.invoice} />
|
|
|
|
}
|