Files
explore/ui/cluster/ClusterDetails.tsx
tom goriunovandGitHub 932add9d96 Change zero to <0.001 value within different pages (#3150)
* basic components and address page refactoring

* second part of refactoring

* third part of refactoring

* NativeCoinValue component

* more refactoring

* rename TruncatedValue into TruncatedText

* minor fixes

* refactor block details

* fix layout of value and fee in tx table

* update screenshots

* different units for tooltip and stats widget small value fix

* update screenshots

* update tx table screenshot

* fix copy button vertical alignment
2025-12-05 16:04:27 +01:00

106 lines
3.1 KiB
TypeScript

import React from 'react';
import type { ClusterByNameResponse } from 'types/api/clusters';
import { isEvmAddress } from 'lib/address/isEvmAddress';
import { currencyUnits } from 'lib/units';
import { Skeleton } from 'toolkit/chakra/skeleton';
import * as DetailedInfo from 'ui/shared/DetailedInfo/DetailedInfo';
import DetailedInfoTimestamp from 'ui/shared/DetailedInfo/DetailedInfoTimestamp';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import ClustersEntity from 'ui/shared/entities/clusters/ClustersEntity';
import NativeCoinValue from 'ui/shared/value/NativeCoinValue';
interface Props {
clusterData?: ClusterByNameResponse['result']['data'];
clusterName: string;
isLoading: boolean;
}
const ClusterDetails = ({ clusterData, clusterName, isLoading }: Props) => {
if (!clusterData && !isLoading) {
throw new Error('Cluster not found', { cause: { status: 404 } });
}
const ownerIsEvm = clusterData?.owner ? isEvmAddress(clusterData.owner) : false;
const addressType = ownerIsEvm ? 'EVM' : 'NON-EVM';
return (
<DetailedInfo.Container>
<DetailedInfo.ItemLabel
hint="The unique cluster name"
isLoading={ isLoading }
>
Cluster name
</DetailedInfo.ItemLabel>
<DetailedInfo.ItemValue>
<ClustersEntity
clusterName={ clusterName }
isLoading={ isLoading }
noLink
fontWeight={ 500 }
/>
</DetailedInfo.ItemValue>
<DetailedInfo.ItemLabel
hint="The address attached to this cluster name"
isLoading={ isLoading }
>
Owner address
</DetailedInfo.ItemLabel>
<DetailedInfo.ItemValue>
<AddressEntity
address={{ hash: clusterData?.owner || '' }}
isLoading={ isLoading }
fontWeight={ 500 }
noLink={ !ownerIsEvm }
/>
</DetailedInfo.ItemValue>
<DetailedInfo.ItemLabel
hint="The network type of the address attached to this cluster name"
isLoading={ isLoading }
>
Type
</DetailedInfo.ItemLabel>
<DetailedInfo.ItemValue>
<Skeleton loading={ isLoading }>
{ addressType }
</Skeleton>
</DetailedInfo.ItemValue>
<DetailedInfo.ItemLabel
hint={ `The amount of ${ currencyUnits.ether } backing this cluster name` }
isLoading={ isLoading }
>
Backing
</DetailedInfo.ItemLabel>
<DetailedInfo.ItemValue>
<NativeCoinValue
amount={ clusterData?.backingWei || '0' }
loading={ isLoading }
/>
</DetailedInfo.ItemValue>
<DetailedInfo.ItemLabel
hint="When this cluster name was created"
isLoading={ isLoading }
>
Created
</DetailedInfo.ItemLabel>
<DetailedInfo.ItemValue>
{ clusterData?.createdAt ? (
<DetailedInfoTimestamp
timestamp={ clusterData.createdAt }
isLoading={ isLoading }
/>
) : (
<Skeleton loading={ isLoading }>N/A</Skeleton>
) }
</DetailedInfo.ItemValue>
</DetailedInfo.Container>
);
};
export default ClusterDetails;