Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework toasts #1741

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
10 changes: 5 additions & 5 deletions src/i18n/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,6 @@
"liquidity.reviewTransaction.modal.error.copy": "Copy error message",
"liquidity.reviewTransaction.modal.error.copied": "Message copied!",
"liquidity.reviewTransaction.modal.error.tip": "Not enough HDX for TIP",
"liquidity.reviewTransaction.toast.pending": "Submitting transaction...",
"liquidity.reviewTransaction.toast.success": "Transaction successful.",
"liquidity.reviewTransaction.toast.error": "Transaction failed.",
"liquidity.reviewTransaction.toast.unknown": "Transaction status unknown.",
"liquidity.reviewTransaction.calldata.encoded": "Encoded call data",
"liquidity.reviewTransaction.calldata.encodedHash": "Encoded call hash",
"liquidity.reviewTransaction.calldata.decoded": "Decoded",
Expand Down Expand Up @@ -1105,5 +1101,9 @@
"memepad.summary.adminRights.burn": "Burn admin rights",
"memepad.summary.adminRights.burned": "Admin rights revoked",
"memepad.summary.adminRights.toast.onLoading": "Revoking admin rights...",
"memepad.summary.adminRights.toast.onSuccess": "Admin rights revoked."
"memepad.summary.adminRights.toast.onSuccess": "Admin rights revoked.",
"toast.pending": "Submitting transaction...",
"toast.success": "Transaction successful.",
"toast.error": "Transaction failed.",
"toast.unknown": "Transaction status unknown."
}
46 changes: 8 additions & 38 deletions src/sections/transaction/ReviewTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ReviewTransactionError } from "./ReviewTransactionError"
import { ReviewTransactionForm } from "./ReviewTransactionForm"
import { ReviewTransactionPending } from "./ReviewTransactionPending"
import { ReviewTransactionSuccess } from "./ReviewTransactionSuccess"
import { ReviewTransactionToast } from "./ReviewTransactionToast"
import { ReviewTransactionXCallForm } from "./ReviewTransactionXCallForm"
import { WalletUpgradeModal } from "sections/web3-connect/upgrade/WalletUpgradeModal"
import { isEvmXCall } from "sections/transaction/ReviewTransactionXCallForm.utils"
Expand All @@ -28,13 +27,13 @@ export const ReviewTransaction = (props: Transaction) => {
isSuccess,
isError: isSendError,
error: sendError,
data,
txState,
reset,
txLink,
txHash,
bridge,
} = useSendTx()
} = useSendTx({
toast: props.toast,
onSuccess: (data) => props.onSuccess?.(data),
onError: props.onError,
})

if (!isLoaded) return null

Expand All @@ -54,32 +53,19 @@ export const ReviewTransaction = (props: Transaction) => {
props.description ?? t("liquidity.reviewTransaction.modal.desc"),
}

const handleTxOnClose = () => {
if (isLoading) {
setMinimizeModal(true)
return
}

if (isSuccess) {
props.onSuccess?.(data)
} else {
props.onError?.()
}
}

const onClose = () => {
handleTxOnClose()
setMinimizeModal(true)
props.onClose?.()
}

const onMinimizeModal = () => {
handleTxOnClose()
setMinimizeModal(true)
if (!props.disableAutoClose) props.onClose?.()
}

const onBack = props.onBack
? () => {
handleTxOnClose()
setMinimizeModal(true)
props.onBack?.()
}
: undefined
Expand All @@ -91,22 +77,6 @@ export const ReviewTransaction = (props: Transaction) => {

return (
<>
{minimizeModal && (
<ReviewTransactionToast
id={props.id}
isLoading={isLoading}
isSuccess={isSuccess}
isError={isError}
error={error}
link={txLink}
txHash={txHash}
onReview={onReview}
onClose={onMinimizeModal}
toastMessage={props.toastMessage}
bridge={bridge}
/>
)}

<Modal
open={!minimizeModal}
onBack={onBack}
Expand Down
Loading
Loading