Skip to content

Commit

Permalink
Fix NAN for promoted operator TVL when search results is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenthongzy committed Sep 3, 2024
1 parent 1adcfed commit 7bcb29e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/avs/AVSDetailsOperatorsTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function AVSOperatorsList({ address, avsError, isAVSLoading, tvl }) {
error: undefined,
operators: [],
promotedOperators: [],
promotedOperatorsRate: 1,
isInputTouched: false,
isTableLoading: true,
totalPages: undefined,
Expand Down Expand Up @@ -217,7 +218,8 @@ function AVSOperatorsList({ address, avsError, isAVSLoading, tvl }) {
try {
const response = await rdService.getAVSPromotedOperators(address);
dispatch({
promotedOperators: response.results
promotedOperators: response.results,
promotedOperatorsRate: response.rate
});
} catch (e) {
//TODO: handle error
Expand Down Expand Up @@ -280,14 +282,16 @@ function AVSOperatorsList({ address, avsError, isAVSLoading, tvl }) {
: `${((operator.strategiesTotal / tvl) * 100).toFixed(2)}%`}
</TableCell>
<TableCell className="pe-8 text-end">
<div>{formatUSD(operator.strategiesTotal * state.currentRate)}</div>
<div>
{formatUSD(operator.strategiesTotal * state.promotedOperatorsRate)}
</div>
<div className="text-xs text-foreground-2">
{formatETH(operator.strategiesTotal)}
</div>
</TableCell>
</TableRow>
));
}, [navigate, state.currentRate, state.promotedOperators, tvl]);
}, [navigate, state.promotedOperators, state.promotedOperatorsRate, tvl]);

return (
<div className="rd-box text-sm">
Expand Down
10 changes: 7 additions & 3 deletions src/operators/OperatorList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function OperatorList() {
const [state, dispatch] = useMutativeReducer(reduceState, {
operators: [],
promotedOperators: [],
promotedOperatorsRate: 1,
isFetchingData: false,
searchTerm: searchParams.get('search'),
error: null,
Expand Down Expand Up @@ -106,7 +107,8 @@ export default function OperatorList() {
try {
const response = await rdService.getPromotedOperators();
dispatch({
promotedOperators: response.results
promotedOperators: response.results,
promotedOperatorsRate: response.rate
});
} catch (e) {
//TODO: handle error
Expand Down Expand Up @@ -188,14 +190,16 @@ export default function OperatorList() {
{formatNumber(operator.stakerCount)}
</TableCell>
<TableCell className="pe-8 text-end">
<div>{formatUSD(operator.strategiesTotal * state.rate)}</div>
<div>
{formatUSD(operator.strategiesTotal * state.promotedOperatorsRate)}
</div>
<div className="text-xs text-foreground-2">
{formatETH(operator.strategiesTotal)}
</div>
</TableCell>
</TableRow>
));
}, [navigate, state.promotedOperators, state.rate]);
}, [navigate, state.promotedOperators, state.promotedOperatorsRate]);

return (
<div className="flex h-full flex-col">
Expand Down

0 comments on commit 7bcb29e

Please sign in to comment.