diff --git a/src/components/@reviewScreens/ApproveReview/ApproveReview.tsx b/src/components/@reviewScreens/ApproveReview/ApproveReview.tsx index 45356dc7..d0f01444 100644 --- a/src/components/@reviewScreens/ApproveReview/ApproveReview.tsx +++ b/src/components/@reviewScreens/ApproveReview/ApproveReview.tsx @@ -27,6 +27,7 @@ import { } from "./ApproveReview.styles"; interface ApproveReviewProps { + hasEditButton?: boolean; isLoading: boolean; amount: string; amountPlusFee?: string; @@ -35,17 +36,17 @@ interface ApproveReviewProps { readableAllowance: string; token: TokenInfo | null; wrappedNativeToken: TokenInfo | null; - onEditButtonClick: () => void; + onEditButtonClick?: () => void; onRestartButtonClick?: () => void; onSignButtonClick: () => void; className?: string; } const ApproveReview: FC = ({ + hasEditButton, isLoading, amount, amountPlusFee, - backButtonText, errors = [], readableAllowance, token, @@ -78,6 +79,16 @@ const ApproveReview: FC = ({ return toRoundedNumberString(amountPlusFee, justifiedToken?.decimals); }, [amountPlusFee, justifiedToken]); + const handleEditOrBackButtonClick = () => { + if (!isLoading && hasEditButton && onEditButtonClick) { + onEditButtonClick(); + } + + if (onRestartButtonClick) { + onRestartButtonClick(); + } + }; + return ( @@ -133,8 +144,10 @@ const ApproveReview: FC = ({ diff --git a/src/components/@reviewScreens/WrapReview/WrapReview.tsx b/src/components/@reviewScreens/WrapReview/WrapReview.tsx index d78d2df9..96014e2c 100644 --- a/src/components/@reviewScreens/WrapReview/WrapReview.tsx +++ b/src/components/@reviewScreens/WrapReview/WrapReview.tsx @@ -28,24 +28,24 @@ import { } from "./WrapReview.styles"; interface WrapReviewProps { + hasEditButton?: boolean; isLoading: boolean; amount: string; amountPlusFee?: string; - backButtonText?: string; errors?: AppError[]; wrappedNativeToken: TokenInfo | null; shouldDepositNativeTokenAmount: string; - onEditButtonClick: () => void; + onEditButtonClick?: () => void; onRestartButtonClick?: () => void; onSignButtonClick: () => void; className?: string; } const ApproveReview: FC = ({ + hasEditButton, isLoading, amount, amountPlusFee, - backButtonText, errors = [], shouldDepositNativeTokenAmount, wrappedNativeToken, @@ -80,6 +80,16 @@ const ApproveReview: FC = ({ return toRoundedNumberString(amountPlusFee, wrappedNativeToken?.decimals); }, [amountPlusFee, wrappedNativeToken]); + const handleEditOrBackButtonClick = () => { + if (!isLoading && hasEditButton && onEditButtonClick) { + onEditButtonClick(); + } + + if (onRestartButtonClick) { + onRestartButtonClick(); + } + }; + return ( @@ -137,8 +147,10 @@ const ApproveReview: FC = ({ diff --git a/src/components/@widgets/MakeWidget/MakeWidget.tsx b/src/components/@widgets/MakeWidget/MakeWidget.tsx index f973c110..9e3b123e 100644 --- a/src/components/@widgets/MakeWidget/MakeWidget.tsx +++ b/src/components/@widgets/MakeWidget/MakeWidget.tsx @@ -338,6 +338,11 @@ const MakeWidget: FC = () => { setState(MakeWidgetState.list); }; + const restart = () => { + setState(MakeWidgetState.list); + dispatch(reset()); + }; + const handleActionButtonClick = (action: ButtonActions) => { if (action === ButtonActions.connectWallet) { setShowWalletList(true); @@ -352,13 +357,13 @@ const MakeWidget: FC = () => { } if (action === ButtonActions.restart) { - dispatch(reset()); + restart(); } }; const handleBackButtonClick = (action: ButtonActions) => { if (action === ButtonActions.restart) { - dispatch(reset()); + restart(); } if (action === ButtonActions.goBack) { @@ -385,13 +390,14 @@ const MakeWidget: FC = () => { return ( @@ -402,14 +408,15 @@ const MakeWidget: FC = () => { return ( @@ -509,7 +516,6 @@ const MakeWidget: FC = () => { hasMissingMakerToken={!makerTokenInfo} hasMissingTakerAmount={hasMissingTakerAmount} hasMissingTakerToken={!takerTokenInfo} - isLoading={hasApprovalPending || hasDepositPending} isNetworkUnsupported={ !!web3Error && web3Error instanceof UnsupportedChainIdError } diff --git a/src/components/@widgets/MakeWidget/subcomponents/ActionButtons/ActionButtons.tsx b/src/components/@widgets/MakeWidget/subcomponents/ActionButtons/ActionButtons.tsx index 12e6df39..0e6eab8f 100644 --- a/src/components/@widgets/MakeWidget/subcomponents/ActionButtons/ActionButtons.tsx +++ b/src/components/@widgets/MakeWidget/subcomponents/ActionButtons/ActionButtons.tsx @@ -21,7 +21,6 @@ type ActionButtonsProps = { hasMissingMakerToken: boolean; hasMissingTakerAmount: boolean; hasMissingTakerToken: boolean; - isLoading: boolean; isNetworkUnsupported: boolean; shouldDepositNativeToken: boolean; walletIsNotConnected: boolean; @@ -40,7 +39,6 @@ const ActionButtons: FC = ({ hasMissingMakerToken, hasMissingTakerAmount, hasMissingTakerToken, - isLoading, isNetworkUnsupported, shouldDepositNativeToken, walletIsNotConnected, @@ -97,7 +95,6 @@ const ActionButtons: FC = ({ {buttonText} diff --git a/src/components/@widgets/OrderDetailWidget/OrderDetailWidget.tsx b/src/components/@widgets/OrderDetailWidget/OrderDetailWidget.tsx index 2795ea2f..edabb7cb 100644 --- a/src/components/@widgets/OrderDetailWidget/OrderDetailWidget.tsx +++ b/src/components/@widgets/OrderDetailWidget/OrderDetailWidget.tsx @@ -255,7 +255,7 @@ const OrderDetailWidget: FC = ({ order }) => { dispatch(reset()); }; - const handleEditButtonClick = () => { + const backToOverview = () => { setState(OrderDetailWidgetState.overview); }; @@ -298,8 +298,7 @@ const OrderDetailWidget: FC = ({ order }) => { errors={errors} shouldDepositNativeTokenAmount={shouldDepositNativeTokenAmount} wrappedNativeToken={wrappedNativeToken} - onEditButtonClick={handleEditButtonClick} - onRestartButtonClick={restart} + onRestartButtonClick={backToOverview} onSignButtonClick={depositNativeToken} /> @@ -316,8 +315,7 @@ const OrderDetailWidget: FC = ({ order }) => { readableAllowance={"0"} token={senderToken} wrappedNativeToken={wrappedNativeToken} - onEditButtonClick={handleEditButtonClick} - onRestartButtonClick={restart} + onRestartButtonClick={backToOverview} onSignButtonClick={approveToken} /> @@ -335,7 +333,7 @@ const OrderDetailWidget: FC = ({ order }) => { signerAmount={signerAmount || "0"} signerToken={signerToken} wrappedNativeToken={wrappedNativeToken} - onEditButtonClick={handleEditButtonClick} + onEditButtonClick={backToOverview} onRestartButtonClick={restart} onSignButtonClick={takeOrder} /> diff --git a/src/components/@widgets/SwapWidget/SwapWidget.tsx b/src/components/@widgets/SwapWidget/SwapWidget.tsx index f4497182..b7e9961f 100644 --- a/src/components/@widgets/SwapWidget/SwapWidget.tsx +++ b/src/components/@widgets/SwapWidget/SwapWidget.tsx @@ -776,6 +776,10 @@ const SwapWidget: FC = () => { dispatch(setCustomServerUrl(null)); }; + const backToOverview = () => { + handleActionButtonClick(ButtonActions.restart); + }; + if (ordersStatus === "signing") { return ( @@ -795,9 +799,7 @@ const SwapWidget: FC = () => { token={baseTokenInfo} wrappedNativeToken={wrappedNativeTokenInfo} onEditButtonClick={handleEditButtonClick} - onRestartButtonClick={() => - handleActionButtonClick(ButtonActions.restart) - } + onRestartButtonClick={backToOverview} onSignButtonClick={approveToken} /> @@ -890,9 +892,7 @@ const SwapWidget: FC = () => { needsApproval={!!baseToken && shouldApprove} pairUnavailable={pairUnavailable} onButtonClicked={(action) => handleActionButtonClick(action)} - isLoading={ - isConnecting || isRequestingQuotes || hasApprovalPending - } + isLoading={isConnecting || isRequestingQuotes} transactionsTabOpen={transactionsTabIsOpen} /> )} @@ -919,17 +919,10 @@ const SwapWidget: FC = () => { - handleActionButtonClick(ButtonActions.restart) - } + onCloseButtonClick={backToOverview} isHidden={!ordersErrors.length} > - - handleActionButtonClick(ButtonActions.restart) - } - /> +