Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
fix: undefined account and hook (#541)
Browse files Browse the repository at this point in the history
* fix: undefined account and hook
  • Loading branch information
ntheile authored Aug 24, 2023
1 parent 45cf0fe commit 8657fe6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions hooks/use-Create-Invoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion pages/[username].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -52,6 +52,7 @@ function ReceivePayment() {

const { data, error: usernameError } = useAccountDefaultWalletsQuery({
variables: { username: accountUsername },
skip: !accountUsername,
})

const [state, dispatch] = React.useReducer(reducer, {
Expand Down

0 comments on commit 8657fe6

Please sign in to comment.