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

fix: undefined account and hook #541

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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