-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Dynamically import ActivateAccountFlow
- Loading branch information
1 parent
73c42c4
commit aae01f7
Showing
4 changed files
with
47 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import dynamic from 'next/dynamic' | ||
import React, { useContext } from 'react' | ||
import { Button, CircularProgress, Tooltip, Typography } from '@mui/material' | ||
import { TxModalContext } from '@/components/tx-flow' | ||
import { PendingSafeStatus, selectUndeployedSafe } from '@/features/counterfactual/store/undeployedSafesSlice' | ||
import useSafeInfo from '@/hooks/useSafeInfo' | ||
import { useAppSelector } from '@/store' | ||
|
||
const ActivateAccountFlow = dynamic(() => import('./ActivateAccountFlow')) | ||
|
||
const ActivateAccountButton = () => { | ||
const { safe, safeAddress } = useSafeInfo() | ||
const undeployedSafe = useAppSelector((state) => selectUndeployedSafe(state, safe.chainId, safeAddress)) | ||
const { setTxFlow } = useContext(TxModalContext) | ||
|
||
const isProcessing = undeployedSafe?.status.status !== PendingSafeStatus.AWAITING_EXECUTION | ||
|
||
const activateAccount = () => { | ||
setTxFlow(<ActivateAccountFlow />) | ||
} | ||
|
||
return ( | ||
<Tooltip title={isProcessing ? 'The safe activation is already in process' : undefined}> | ||
<span> | ||
<Button variant="contained" size="small" onClick={activateAccount} disabled={isProcessing}> | ||
{isProcessing ? ( | ||
<> | ||
<Typography variant="body2" component="span" mr={1}> | ||
Processing | ||
</Typography> | ||
<CircularProgress size={16} /> | ||
</> | ||
) : ( | ||
'Activate now' | ||
)} | ||
</Button> | ||
</span> | ||
</Tooltip> | ||
) | ||
} | ||
|
||
export default ActivateAccountButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters