diff --git a/src/components/pages/Turbo/TurboIndexPage/CreateSafeModal/CreateSafeModal.tsx b/src/components/pages/Turbo/TurboIndexPage/CreateSafeModal/CreateSafeModal.tsx index fe367c66..d1276907 100644 --- a/src/components/pages/Turbo/TurboIndexPage/CreateSafeModal/CreateSafeModal.tsx +++ b/src/components/pages/Turbo/TurboIndexPage/CreateSafeModal/CreateSafeModal.tsx @@ -48,6 +48,7 @@ export const CreateSafeModal: React.FC = ({ const [hasApproval, setHasApproval] = useState(false); const [approving, setApproving] = useState(false); const [creatingSafe, setCreatingSafe] = useState(false); + const [navigating, setNavigating] = useState(false); // Utils const toast = useToast(); @@ -118,6 +119,7 @@ export const CreateSafeModal: React.FC = ({ approve: onClickApprove, createSafe: onClickCreateSafe, creatingSafe, + navigating, onClose() { // Only allow close if a transaction isn't in progress. if (!approving && !creatingSafe) { @@ -125,8 +127,13 @@ export const CreateSafeModal: React.FC = ({ onClose(); } }, - navigateToCreatedSafe() { - router.push("/turbo/safe/0"); + async navigateToCreatedSafe() { + setNavigating(true); + try { + await router.push("/turbo/safe/0"); + } finally { + setNavigating(false); + } }, }; diff --git a/src/components/pages/Turbo/TurboIndexPage/CreateSafeModal/modalSteps.tsx b/src/components/pages/Turbo/TurboIndexPage/CreateSafeModal/modalSteps.tsx index d8661535..1ab77337 100644 --- a/src/components/pages/Turbo/TurboIndexPage/CreateSafeModal/modalSteps.tsx +++ b/src/components/pages/Turbo/TurboIndexPage/CreateSafeModal/modalSteps.tsx @@ -53,6 +53,8 @@ type CreateSafeCtx = { creatingSafe: boolean; /** Function which closes the modal. */ onClose(): void; + /** Whether the navigation to the created safe is pending. */ + navigating: boolean; /** * Function which navigates to the safe that was just created in this modal. */ @@ -207,7 +209,7 @@ const MODAL_STEP_4: ModalStep = { stepBubbles: ({ hasApproval, approving, creatingSafe, depositAmount }) => ({ steps: 2, loading: approving || creatingSafe, - activeIndex: !hasApproval && parseEther(depositAmount ?? "0") ? 0 : 1, + activeIndex: !hasApproval && parseEther(depositAmount ?? "0").gt(0) ? 0 : 1, background: "neutral", }), buttons: ({ @@ -262,14 +264,15 @@ const MODAL_STEP_5: ModalStep = { ), - buttons: ({ onClose, navigateToCreatedSafe }) => [ + buttons: ({ onClose, navigateToCreatedSafe, navigating }) => [ { - children: "View Safe", + children: navigating ? "Loading..." : "View Safe", + loading: navigating, variant: "neutral", - onClick() { + async onClick() { + // TODO(sharad-s): replace hardcoded value + await navigateToCreatedSafe("0"); onClose(); - // TODO(nathanhleung): replace hardcoded value - navigateToCreatedSafe("0"); }, }, ],