// Copyright 2017-2026 @pezkuwi/react-components authors & contributors // SPDX-License-Identifier: Apache-2.0 import React, { useMemo } from 'react'; import { useApi, useRegistrars, useSubidentities, useToggle } from '@pezkuwi/react-hooks'; import { AddressIdentityOtherDiscordKey } from '@pezkuwi/react-hooks/constants'; import { type AddressIdentity } from '@pezkuwi/react-hooks/types'; import { isHex } from '@pezkuwi/util'; import AddressMini from '../AddressMini.js'; import AvatarItem from '../AvatarItem.js'; import Expander from '../Expander.js'; import IconLink from '../IconLink.js'; import { useTranslation } from '../translate.js'; import Judgements from './Judgements.js'; import RegistrarJudgement from './RegistrarJudgement.js'; import UserIcon from './UserIcon.js'; interface Props { address: string; identity?: AddressIdentity; } const SUBS_DISPLAY_THRESHOLD = 4; function Identity ({ address, identity }: Props): React.ReactElement | null { const { t } = useTranslation(); const { apiIdentity } = useApi(); const { isRegistrar, registrars } = useRegistrars(); const [isJudgementOpen, toggleIsJudgementOpen] = useToggle(); const subs = useSubidentities(address); const subsList = useMemo(() => subs?.map((sub) => ) , [subs] ); if (!identity || !identity.isExistent || !apiIdentity.query.identity?.identityOf) { return null; } return (
{t('identity')}
// : // } subtitle={identity.legal} title={identity.display} />
{identity.parent && (
{t('parent')}
)} {identity.email && (
{t('email')}
{isHex(identity.email) || !identity.isKnownGood ? identity.email : ( {identity.email} )}
)} {identity.web && (
{t('website')}
{isHex(identity.web) || !identity.isKnownGood ? identity.web : ( {identity.web} )}
)} {identity.twitter && (
{t('twitter')}
{isHex(identity.twitter) || !identity.isKnownGood ? identity.twitter : ( {identity.twitter} )}
)} {identity.other && AddressIdentityOtherDiscordKey in identity.other && (
{t('discord')}
{identity.other[AddressIdentityOtherDiscordKey]}
)} {identity.github && (
{t('github')}
{identity.github}
)} {identity.matrix && (
{t('matrix')}
{identity.matrix}
)} {identity.discord && (
{t('discord')}
{identity.discord}
)} {identity.riot && (
{t('riot')}
{identity.riot}
)} {!!subs?.length && (
{t('subs')}
{subs.length > SUBS_DISPLAY_THRESHOLD ? ( {subsList} ) : ( <>
{subs.length}
{subsList} ) }
)}
{isRegistrar && (
)} {isJudgementOpen && isRegistrar && ( )}
); } export default React.memo(Identity);