-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Enable Add proposer button for owners only (#4744)
* fix: Enable Add proposer button for owners only * fix: Add wallet connected status check to OnlyOwner
- Loading branch information
1 parent
ea7dc6d
commit 236e002
Showing
2 changed files
with
43 additions
and
3 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,40 @@ | ||
import { useMemo, type ReactElement } from 'react' | ||
import useIsSafeOwner from '@/hooks/useIsSafeOwner' | ||
import useWallet from '@/hooks/wallets/useWallet' | ||
import useConnectWallet from '../ConnectWallet/useConnectWallet' | ||
import { Tooltip } from '@mui/material' | ||
|
||
type CheckWalletProps = { | ||
children: (ok: boolean) => ReactElement | ||
} | ||
|
||
enum Message { | ||
WalletNotConnected = 'Please connect your wallet', | ||
NotSafeOwner = 'Your connected wallet is not a signer of this Safe Account', | ||
} | ||
|
||
const OnlyOwner = ({ children }: CheckWalletProps): ReactElement => { | ||
const wallet = useWallet() | ||
const isSafeOwner = useIsSafeOwner() | ||
const connectWallet = useConnectWallet() | ||
|
||
const message = useMemo(() => { | ||
if (!wallet) { | ||
return Message.WalletNotConnected | ||
} | ||
|
||
if (!isSafeOwner) { | ||
return Message.NotSafeOwner | ||
} | ||
}, [isSafeOwner, wallet]) | ||
|
||
if (!message) return children(true) | ||
|
||
return ( | ||
<Tooltip title={message}> | ||
<span onClick={wallet ? undefined : connectWallet}>{children(false)}</span> | ||
</Tooltip> | ||
) | ||
} | ||
|
||
export default OnlyOwner |
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