Skip to content

Commit

Permalink
tx success ui fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hckrg committed Jul 17, 2023
1 parent 5bf60fa commit 9d9e67f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/IssueModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function IssueTokenModal({ onClose, basketDetails, type}: IssueTokenModalProps)
})

console.log("Transaction Id : ", txId)
subscribeTxStatus(txId)
subscribeTxStatus(txId, onClose)
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/RedeemModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function RedeemTokenModal({ onClose, basketDetails}: IssueTokenModalProps) {
})

console.log("Transaction Id : ", txId)
subscribeTxStatus(txId)
subscribeTxStatus(txId, onClose)
}

useEffect(() => {
Expand Down
14 changes: 10 additions & 4 deletions src/utils/subscribeTxStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fcl from '@onflow/fcl'
import { NavigateFunction } from 'react-router-dom'
import { toast } from 'react-toastify'

export const subscribeTxStatus = (transactionId: string, navigate?: NavigateFunction) => {
export const subscribeTxStatus = (transactionId: string, onClose: () => void) => {
const loaderId = toast.loading('Transaction in process...')
console.log('Transaction ID: ', transactionId)
fcl.tx(transactionId).subscribe((res: any) => {
Expand All @@ -12,11 +12,17 @@ export const subscribeTxStatus = (transactionId: string, navigate?: NavigateFunc
if (res?.errorMessage === "") {
toast.dismiss(loaderId)
toast.success('Transaction sealed')
navigate ? navigate('/dashboard') : window.location.reload()
} else
} else {
toast.dismiss(loaderId)
toast.error(res?.errorMessage)
}
} else if (res?.statusString === "EXECUTED") {
toast.success('Transaction executed')
if (res?.errorMessage === "") {
toast.success('Transaction executed')
} else {
toast.dismiss(loaderId)
toast.error(res?.errorMessage)
}
} else if (res?.statusString === "PENDING") {
toast.success('Transaction pending')
} else if (res?.statusString === "EXPIRED") {
Expand Down

0 comments on commit 9d9e67f

Please sign in to comment.