Cleanup AccountName display (#2166)
This commit is contained in:
parent
af2121dc73
commit
edc9eddf33
@ -33,6 +33,15 @@ interface Props extends BareProps {
|
||||
withShort?: boolean;
|
||||
}
|
||||
|
||||
const JUDGEMENT_ENUM = [
|
||||
{ value: 0, text: 'Unknown' },
|
||||
{ value: 1, text: 'Fee paid' },
|
||||
{ value: 2, text: 'Reasonable' },
|
||||
{ value: 3, text: 'Known good' },
|
||||
{ value: 4, text: 'Out of date' },
|
||||
{ value: 5, text: 'Low quality' }
|
||||
];
|
||||
const DISPLAY_KEYS = ['display', 'legal', 'email', 'web', 'twitter', 'riot'];
|
||||
const nameCache: Map<string, [boolean, [React.ReactNode, React.ReactNode | null]]> = new Map();
|
||||
|
||||
function defaultOrAddr (defaultName = '', _address: AccountId | AccountIndex | Address | string | Uint8Array, _accountIndex?: AccountIndex | null): [[React.ReactNode, React.ReactNode | null], boolean, boolean] {
|
||||
@ -64,7 +73,7 @@ function AccountName ({ children, className, defaultName, label, onClick, overri
|
||||
const [accountId, setAccountId] = useState<string | null>(null);
|
||||
const [isRegistrar, setIsRegistrar] = useState(false);
|
||||
const [judgementAccountId, setJudgementAccountId] = useState<string | null>(null);
|
||||
const [judgementEnum, setJudgementEnum] = useState(0);
|
||||
const [judgementEnum, setJudgementEnum] = useState(2); // Reasonable
|
||||
const [registrarIndex, setRegistrarIndex] = useState(-1);
|
||||
const address = useMemo((): string => (value || '').toString(), [value]);
|
||||
|
||||
@ -154,42 +163,15 @@ function AccountName ({ children, className, defaultName, label, onClick, overri
|
||||
<td><AddressMini value={identity.parent} /></td>
|
||||
</tr>
|
||||
)}
|
||||
{identity.display && (
|
||||
<tr>
|
||||
<td>{t('display')}</td>
|
||||
<td>{identity.display}</td>
|
||||
</tr>
|
||||
)}
|
||||
{identity.legal && (
|
||||
<tr>
|
||||
<td>{t('legal')}</td>
|
||||
<td>{identity.legal}</td>
|
||||
</tr>
|
||||
)}
|
||||
{identity.email && (
|
||||
<tr>
|
||||
<td>{t('email')}</td>
|
||||
<td>{identity.email}</td>
|
||||
</tr>
|
||||
)}
|
||||
{identity.web && (
|
||||
<tr>
|
||||
<td>{t('www')}</td>
|
||||
<td>{identity.web}</td>
|
||||
</tr>
|
||||
)}
|
||||
{identity.twitter && (
|
||||
<tr>
|
||||
<td>{t('twitter')}</td>
|
||||
<td>{identity.twitter}</td>
|
||||
</tr>
|
||||
)}
|
||||
{identity.riot && (
|
||||
<tr>
|
||||
<td>{t('riot')}</td>
|
||||
<td>{identity.riot}</td>
|
||||
</tr>
|
||||
)}
|
||||
{DISPLAY_KEYS
|
||||
.filter((key): boolean => !!identity[key as 'web'])
|
||||
.map((key): React.ReactNode => (
|
||||
<tr key={key}>
|
||||
<td>{t(key)}</td>
|
||||
<td>{identity[key as 'web']}</td>
|
||||
</tr>
|
||||
))
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -264,14 +246,7 @@ function AccountName ({ children, className, defaultName, label, onClick, overri
|
||||
<Dropdown
|
||||
label={t('judgement')}
|
||||
onChange={setJudgementEnum}
|
||||
options={[
|
||||
{ value: 0, text: 'Unknown' },
|
||||
{ value: 1, text: 'Fee paid' },
|
||||
{ value: 2, text: 'Reasonable' },
|
||||
{ value: 3, text: 'Known good' },
|
||||
{ value: 4, text: 'Out of date' },
|
||||
{ value: 5, text: 'Low quality' }
|
||||
]}
|
||||
options={JUDGEMENT_ENUM}
|
||||
value={judgementEnum}
|
||||
/>
|
||||
</Modal.Content>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user