Skip to content

Commit

Permalink
Merge pull request #648 from subquery/fix/dashboard
Browse files Browse the repository at this point in the history
fix: style issue & next delegate stake value.
  • Loading branch information
HuberTRoy authored Jan 29, 2024
2 parents ea0d9bf + 2726006 commit 7a9350b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
22 changes: 17 additions & 5 deletions src/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: Apache-2.0

import React, { FC } from 'react';
import React, { FC, useMemo } from 'react';
import { useNavigate } from 'react-router';
import NewCard from '@components/NewCard';
import { useEra } from '@hooks';
Expand Down Expand Up @@ -202,6 +202,15 @@ const CirculatingCard = (props: { circulatingSupply: string | bigint; totalStake
const Dashboard: FC = () => {
const dashboardData = useGetDashboardQuery();
const { currentEra } = useEra();

const showNextOrCur = useMemo(() => {
if (dashboardData.data?.indexerStakeSummary?.eraIdx === currentEra.data?.index) {
return 'cur';
}

return 'next';
}, [currentEra.data, dashboardData]);

return (
<div className={styles.dashboard}>
<Typography variant="h4" weight={600}>
Expand All @@ -216,13 +225,16 @@ const Dashboard: FC = () => {
+(fetchedData?.delegations?.aggregates?.distinctCount?.delegatorId?.toString() || 0) -
(fetchedData.indexers?.totalCount || 0);

const currentEraIdx = currentEra.data?.index;

const totalStake =
currentEraIdx === fetchedData.indexerStakeSummary?.eraIdx
showNextOrCur === 'cur'
? fetchedData.indexerStakeSummary?.totalStake
: fetchedData.indexerStakeSummary?.nextTotalStake;

const totalDelegation =
showNextOrCur === 'cur'
? fetchedData.indexerStakeSummary?.delegatorStake
: fetchedData.indexerStakeSummary?.nextDelegatorStake;

return (
<div className={styles.dashboardMain}>
<div className={styles.dashboardMainTop}>
Expand All @@ -239,7 +251,7 @@ const Dashboard: FC = () => {
></StakeCard>

<DelegationsCard
delegatorStake={fetchedData?.indexerStakeSummary?.delegatorStake || '0'}
delegatorStake={totalDelegation || '0'}
nextDelegatorStake={fetchedData?.indexerStakeSummary?.nextDelegatorStake || '0'}
totalCount={delegatorsTotalCount < 0 ? 0 : delegatorsTotalCount}
></DelegationsCard>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/indexer/MyDelegators/MyDelegators.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.content {
background: white;
padding: 2rem;
overflow: scroll;
overflow: auto;
min-height: 80%;
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/indexer/MyProjects/MyProjects.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.content {
background: white;
padding: 2rem;
overflow: scroll;
overflow: auto;
min-height: 80%;
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/indexer/MyStaking/MyStaking.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
.content {
width: 100%;
padding: 1rem 2rem;
overflow: scroll;
overflow: auto;
}

.profile {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/indexer/MyStaking/MyStaking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const MyStaking: React.FC = () => {
retry(sortedIndexer.refresh);
}}
/>
<div style={{ marginLeft: '1rem' }}>
<div>
<SetCommissionRate
onSuccess={() => {
retry(sortedIndexer.refresh);
Expand Down

0 comments on commit 7a9350b

Please sign in to comment.