// Copyright 2017-2026 @pezkuwi/app-js authors & contributors // SPDX-License-Identifier: Apache-2.0 import React, { useEffect, useState } from 'react'; import { AddressMini, InputAddress, Labelled, styled, TxButton } from '@pezkuwi/react-components'; import { useApi } from '@pezkuwi/react-hooks'; import { useTranslation } from './translate.js'; interface Props { allAccounts: string[]; className?: string; isMine?: boolean; sudoKey?: string; } function SetKey ({ allAccounts, className = '', isMine, sudoKey }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); const [selected, setSelected] = useState(null); useEffect((): void => { sudoKey && !selected && setSelected(sudoKey); }, [selected, sudoKey]); const willLose = isMine && !!selected && selected !== sudoKey && allAccounts.some((s): boolean => s === selected); return (
{isMine ? ( <> ) : ( ) } {willLose && (
{t('You will no longer have sudo access')}
)}
); } const StyledSection = styled.section` align-items: flex-end; justify-content: center; .summary { text-align: center; } .sudoInputAddress { margin: -0.25rem 0.5rem -0.25rem 0; } .sudoLabelled { align-items: center; } `; export default React.memo(SetKey);