import { AccountsContext , getControllers } from '@substrate/context' ; import { Spinner } from '@substrate/design-system' ; import { InputAddress } from '@substrate/ui-components' ; import React , { useCallback , useContext } from 'react' ; interface Props { onlyControllers : boolean ; width ? : string ; } const AccountsDropdown = function ( props ) : React . ReactElement { const { onlyControllers , width } = props ; const { state : { allAccounts , currentAccount , stashControllerMap } , dispatch , } = useContext ( AccountsContext ) ; const handleOnChangeAddress = useCallback ( ( address ) : void => { dispatch ( { type : 'setCurrentAccount' , data : address , } ) ; } , [ dispatch ] ) ; if ( ! allAccounts || ! currentAccount ) { return < Spinner inline active / > ; } return ( < InputAddress accounts = { onlyControllers ? getControllers ( allAccounts , stashControllerMap ) : allAccounts } fromKeyring = { false } onChangeAddress = { handleOnChangeAddress } value = { currentAccount } width = { width || '3rem' } / > ) ; } ; export default AccountsDropdown ;