diff --git a/hooks/use-Create-Invoice.tsx b/hooks/use-Create-Invoice.tsx index 9daae169..a52fcaa3 100644 --- a/hooks/use-Create-Invoice.tsx +++ b/hooks/use-Create-Invoice.tsx @@ -54,16 +54,19 @@ const useCreateInvoice = ({ recipientWalletCurrency }: Props) => { "loading" | "new" | "need-update" | "expired" >("loading") - const mutation = - recipientWalletCurrency === "USD" - ? useLnUsdInvoiceCreateOnBehalfOfRecipientMutation - : useLnInvoiceCreateOnBehalfOfRecipientsMutation - - const [createInvoice, { loading, error, data }] = mutation({ + const usdMutation = useLnUsdInvoiceCreateOnBehalfOfRecipientMutation({ + onError: console.error, + onCompleted: () => setInvoiceStatus("new"), + }) + const btcMutation = useLnInvoiceCreateOnBehalfOfRecipientsMutation({ onError: console.error, onCompleted: () => setInvoiceStatus("new"), }) + const mutation = recipientWalletCurrency === "USD" ? usdMutation : btcMutation + + const [createInvoice, { loading, error, data }] = mutation + return { createInvoice, setInvoiceStatus, diff --git a/pages/[username].tsx b/pages/[username].tsx index c62902e6..3c348610 100644 --- a/pages/[username].tsx +++ b/pages/[username].tsx @@ -30,7 +30,7 @@ function ReceivePayment() { const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) let accountUsername: string - if (username == undefined) { + if (!username) { accountUsername = "" } else { accountUsername = username.toString() @@ -52,6 +52,7 @@ function ReceivePayment() { const { data, error: usernameError } = useAccountDefaultWalletsQuery({ variables: { username: accountUsername }, + skip: !accountUsername, }) const [state, dispatch] = React.useReducer(reducer, {