diff --git a/apps/web/src/components/common/OnlyOwner/index.tsx b/apps/web/src/components/common/OnlyOwner/index.tsx new file mode 100644 index 0000000000..a283eb7959 --- /dev/null +++ b/apps/web/src/components/common/OnlyOwner/index.tsx @@ -0,0 +1,31 @@ +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 { + 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(() => (!isSafeOwner ? Message.NotSafeOwner : undefined), [isSafeOwner]) + + if (!message) return children(true) + + return ( + + {children(false)} + + ) +} + +export default OnlyOwner diff --git a/apps/web/src/components/settings/ProposersList/index.tsx b/apps/web/src/components/settings/ProposersList/index.tsx index d35ccc76fa..27042a0040 100644 --- a/apps/web/src/components/settings/ProposersList/index.tsx +++ b/apps/web/src/components/settings/ProposersList/index.tsx @@ -1,7 +1,7 @@ -import CheckWallet from '@/components/common/CheckWallet' import { Chip } from '@/components/common/Chip' import EnhancedTable from '@/components/common/EnhancedTable' import tableCss from '@/components/common/EnhancedTable/styles.module.css' +import OnlyOwner from '@/components/common/OnlyOwner' import Track from '@/components/common/Track' import UpsertProposer from '@/features/proposers/components/UpsertProposer' import DeleteProposerDialog from '@/features/proposers/components/DeleteProposerDialog' @@ -100,7 +100,7 @@ const ProposersList = () => { {isEnabled && ( - + {(isOk) => ( )} - + )}