diff --git a/packages/react-components/src/AccountName.tsx b/packages/react-components/src/AccountName.tsx index ce22c4246444..cfe05cae0423 100644 --- a/packages/react-components/src/AccountName.tsx +++ b/packages/react-components/src/AccountName.tsx @@ -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 = 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(null); const [isRegistrar, setIsRegistrar] = useState(false); const [judgementAccountId, setJudgementAccountId] = useState(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 )} - {identity.display && ( - - {t('display')} - {identity.display} - - )} - {identity.legal && ( - - {t('legal')} - {identity.legal} - - )} - {identity.email && ( - - {t('email')} - {identity.email} - - )} - {identity.web && ( - - {t('www')} - {identity.web} - - )} - {identity.twitter && ( - - {t('twitter')} - {identity.twitter} - - )} - {identity.riot && ( - - {t('riot')} - {identity.riot} - - )} + {DISPLAY_KEYS + .filter((key): boolean => !!identity[key as 'web']) + .map((key): React.ReactNode => ( + + {t(key)} + {identity[key as 'web']} + + )) + } @@ -264,14 +246,7 @@ function AccountName ({ children, className, defaultName, label, onClick, overri