import React from 'react';
import { SkeletonLoader } from '@theorchard/suite-components';
import { useGetIdentityByIdQuery } from 'src/apollo/queries/identity';

export interface IdentityNameProps {
    identity: string;
}

const IdentityName: React.FC<IdentityNameProps> = ({ identity }) => {
    const { data, loading } = useGetIdentityByIdQuery(identity);

    const name = data?.identityById?.name || identity;

    return <>{loading ? <SkeletonLoader /> : name}</>;
};

export default IdentityName;
