diff --git a/components/form.js b/components/form.js index 5b5b12d2..c429ab7c 100644 --- a/components/form.js +++ b/components/form.js @@ -20,7 +20,6 @@ import TextareaAutosize from 'react-textarea-autosize' import { useToast } from './toast' import { numWithUnits } from '@/lib/format' import textAreaCaret from 'textarea-caret' -import ReactDatePicker from 'react-datepicker' import 'react-datepicker/dist/react-datepicker.css' import useDebounceCallback, { debounce } from './use-debounce-callback' import { FileUpload } from './file-upload' @@ -38,9 +37,10 @@ import QrIcon from '@/svgs/qr-code-line.svg' import QrScanIcon from '@/svgs/qr-scan-line.svg' import { useShowModal } from './modal' import { QRCodeSVG } from 'qrcode.react' -import { Scanner } from '@yudiel/react-qr-scanner' +import dynamic from 'next/dynamic' import { qrImageSettings } from './qr' import { useIsClient } from './use-client' +import PageLoading from './page-loading' export class SessionRequiredError extends Error { constructor () { @@ -971,6 +971,19 @@ export function Select ({ label, items, info, groupClassName, onChange, noForm, ) } +function DatePickerSkeleton () { + return ( +
+ {children}
+
+
{children}
@@ -269,9 +283,13 @@ function Code ({ node, inline, className, children, style, ...props }) {
}
return (
-
- {children}
-
+ <>
+ {ReactSyntaxHighlighter && syntaxTheme && (
+
+ {children}
+
+ )}
+ >
)
}
diff --git a/pages/withdraw.js b/pages/withdraw.js
index 1a39386e..1e198d21 100644
--- a/pages/withdraw.js
+++ b/pages/withdraw.js
@@ -15,7 +15,6 @@ import { lnAddrSchema, withdrawlSchema } from '@/lib/validate'
import { useShowModal } from '@/components/modal'
import { useField } from 'formik'
import { useToast } from '@/components/toast'
-import { Scanner } from '@yudiel/react-qr-scanner'
import { decode } from 'bolt11'
import CameraIcon from '@/svgs/camera-line.svg'
import { FAST_POLL_INTERVAL, SSR } from '@/lib/constants'
@@ -24,6 +23,8 @@ import useDebounceCallback from '@/components/use-debounce-callback'
import { lnAddrOptions } from '@/lib/lnurl'
import AccordianItem from '@/components/accordian-item'
import { numWithUnits } from '@/lib/format'
+import PageLoading from '@/components/page-loading'
+import dynamic from 'next/dynamic'
export const getServerSideProps = getGetServerSideProps({ authRequired: true })
@@ -153,39 +154,47 @@ function InvoiceScanner ({ fieldName }) {
const showModal = useShowModal()
const [,, helpers] = useField(fieldName)
const toaster = useToast()
+ const Scanner = dynamic(() => import('@yudiel/react-qr-scanner').then(mod => mod.Scanner), {
+ ssr: false,
+ loading: () =>
+ })
+
return (
{
showModal(onClose => {
return (
- {
- result = result.toLowerCase()
- if (result.split('lightning=')[1]) {
- helpers.setValue(result.split('lightning=')[1].split(/[&?]/)[0])
- } else if (decode(result.replace(/^lightning:/, ''))) {
- helpers.setValue(result.replace(/^lightning:/, ''))
- } else {
- throw new Error('Not a proper lightning payment request')
- }
- onClose()
- }}
- styles={{
- video: {
- aspectRatio: '1 / 1'
- }
- }}
- onError={(error) => {
- if (error instanceof DOMException) {
- console.log(error)
- } else {
- toaster.danger('qr scan: ' + error?.message || error?.toString?.())
- }
- onClose()
- }}
- />
+ <>
+ {Scanner && (
+ {
+ result = result.toLowerCase()
+ if (result.split('lightning=')[1]) {
+ helpers.setValue(result.split('lightning=')[1].split(/[&?]/)[0])
+ } else if (decode(result.replace(/^lightning:/, ''))) {
+ helpers.setValue(result.replace(/^lightning:/, ''))
+ } else {
+ throw new Error('Not a proper lightning payment request')
+ }
+ onClose()
+ }}
+ styles={{
+ video: {
+ aspectRatio: '1 / 1'
+ }
+ }}
+ onError={(error) => {
+ if (error instanceof DOMException) {
+ console.log(error)
+ } else {
+ toaster.danger('qr scan: ' + error?.message || error?.toString?.())
+ }
+ onClose()
+ }}
+ />)}
+ >
)
})
}}