-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a0cbe2
commit f985daa
Showing
13 changed files
with
382 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 26 additions & 5 deletions
31
...y-node-metrics/src/trustworthy-node-metrics-frontend/src/components/NodeProviderChart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...node-metrics/src/trustworthy-node-metrics-frontend/src/components/NodeProviderRewards.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { getLatestRewardRange, LoadingIndicator, setNodeProviderRewardsData } from '../utils/utils'; | ||
import { Box, Grid } from '@mui/material'; | ||
import { Principal } from '@dfinity/principal'; | ||
import { NodeProviderRewards } from '../../../declarations/trustworthy-node-metrics/trustworthy-node-metrics.did'; | ||
import { WidgetNumber } from './Widgets'; | ||
import { boxStyleWidget } from '../Styles'; | ||
|
||
export interface NodeProviderRewardsChartProps { | ||
provider: string; | ||
} | ||
|
||
export const NodeProviderRewardsChart: React.FC<NodeProviderRewardsChartProps> = ({ provider }) => { | ||
const latestRewardRange = getLatestRewardRange(); | ||
const [latestProviderRewards, setLatestProviderRewards] = useState<NodeProviderRewards | null>(null); | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
if (provider) { | ||
setNodeProviderRewardsData(latestRewardRange, Principal.fromText(provider), setLatestProviderRewards, setIsLoading); | ||
} | ||
}, [provider]); | ||
|
||
if (isLoading) { | ||
return <LoadingIndicator />; | ||
} | ||
|
||
if (!latestProviderRewards) { | ||
return <p>No latestNodeRewards</p>; | ||
} | ||
|
||
return ( | ||
<Grid item xs={12}> | ||
<Box sx={boxStyleWidget('right')}> | ||
<WidgetNumber value={Math.round(latestProviderRewards.rewards_xdr).toString()} title="Rewards XDR" sxValue={{ color: '#FFCC00' }} /> | ||
</Box> | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default NodeProviderRewardsChart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.