diff --git a/dapp/src/components/Header/ConnectWallet.tsx b/dapp/src/components/Header/ConnectWallet.tsx index 32072522b..fad9aa380 100644 --- a/dapp/src/components/Header/ConnectWallet.tsx +++ b/dapp/src/components/Header/ConnectWallet.tsx @@ -69,6 +69,32 @@ export default function ConnectWallet() { ) } + const options = [ + { + id: "Copy", + icon: IconCopy, + label: hasCopied ? "Address copied" : "Copy Address", + onClick: onCopy, + isSupported: true, + closeOnSelect: false, + }, + { + id: "Change account", + icon: IconUserCode, + label: "Change account", + onClick: () => handleConnectWallet(true), + isSupported: isChangeAccountFeatureSupported(embeddedApp), + closeOnSelect: true, + }, + { + id: "Disconnect", + icon: IconLogout, + label: "Disconnect", + onClick: onDisconnect, + closeOnSelect: true, + isSupported: true, + }, + ] return isMobile ? ( @@ -83,29 +109,20 @@ export default function ConnectWallet() { {truncateAddress(address)} - } - onClick={onCopy} - > - {hasCopied ? "Address copied" : "Copy Address"} - - {isChangeAccountFeatureSupported(embeddedApp) && ( - } - onClick={() => handleConnectWallet(true)} - > - Change account - + {options.map( + (option) => + option.isSupported && ( + } + onClick={option.onClick} + > + {option.label} + + ), )} - } - onClick={onDisconnect} - > - Disconnect - )} @@ -147,44 +164,26 @@ export default function ConnectWallet() { spacing={1} divider={} > - - } - px={2} - boxSize={5} - onClick={onCopy} - /> - - - {isChangeAccountFeatureSupported(embeddedApp) && ( - - } - px={2} - boxSize={5} - onClick={() => handleConnectWallet(true)} - /> - + {options.map( + (option) => + option.isSupported && ( + + } + px={2} + boxSize={5} + onClick={option.onClick} + /> + + ), )} - - - } - px={2} - boxSize={5} - onClick={onDisconnect} - /> -