Files
explore/ui/block/BlockEpochRewards.tsx
T
tom goriunovandGitHub fae4990e1f API resource refactoring (#2699)
* add prefix to API resources

* fix pw tests

* refactor config

* remove unnecessary prefixes in resource names

* fixes

* update screenshots
2025-05-01 15:22:38 +02:00

41 lines
1.1 KiB
TypeScript

import React from 'react';
import useApiQuery from 'lib/api/useApiQuery';
import { BLOCK_EPOCH } from 'stubs/block';
import DataFetchAlert from 'ui/shared/DataFetchAlert';
import BlockEpochElectionRewards from './epochRewards/BlockEpochElectionRewards';
import BlockEpochRewardsDistribution from './epochRewards/BlockEpochRewardsDistribution';
interface Props {
heightOrHash: string;
}
const BlockEpochRewards = ({ heightOrHash }: Props) => {
const query = useApiQuery('general:block_epoch', {
pathParams: {
height_or_hash: heightOrHash,
},
queryOptions: {
placeholderData: BLOCK_EPOCH,
},
});
if (query.isError) {
return <DataFetchAlert/>;
}
if (!query.data || (!query.data.aggregated_election_rewards && !query.data.distribution)) {
return <span>No block epoch rewards data</span>;
}
return (
<>
<BlockEpochRewardsDistribution data={ query.data } isLoading={ query.isPlaceholderData }/>
<BlockEpochElectionRewards data={ query.data } isLoading={ query.isPlaceholderData }/>
</>
);
};
export default React.memo(BlockEpochRewards);