Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/booster amount #686

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"src": "favicon.ico",
"type": "image/x-icon",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"src": "favicon.ico",
"type": "image/x-icon",
"sizes": "512x512"
}
],
Expand Down
31 changes: 20 additions & 11 deletions src/components/ProjectCard/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Address, Typography } from '@subql/components';
import { ProjectFieldsFragment, ProjectType } from '@subql/network-query';
import { formatSQT } from '@subql/react-hooks';
import { formatNumber, TOKEN } from '@utils';
import BigNumber from 'bignumber.js';
import dayjs from 'dayjs';

import { ProjectMetadata } from 'src/models';
Expand All @@ -32,6 +33,16 @@ const ProjectCard: React.FC<Props> = ({ project, onClick }) => {
return project.metadata.image;
}, [project.metadata]);

const booster = React.useMemo(() => {
return project?.deployments?.nodes.reduce(
(cur, add) =>
cur.plus(
BigNumber(add?.deploymentBoosterSummaries?.groupedAggregates?.[0]?.sum?.totalAmount.toString() || '0'),
),
BigNumber(0),
);
}, [project?.deployments?.nodes]);

return (
<div className={styles.card} onClick={onClick}>
<IPFSImage
Expand All @@ -40,18 +51,22 @@ const ProjectCard: React.FC<Props> = ({ project, onClick }) => {
renderPlaceholder={() => <div style={{ width: '100%', height: '205px', background: '#fff' }}></div>}
/>
<div style={{ flex: 1 }}>
<Typography className="overflowEllipsis2" style={{ marginTop: 16, marginBottom: 6, height: 48 }} weight={600}>
<Typography
className="overflowEllipsis2"
style={{ marginTop: 16, marginBottom: 6, height: 48, wordBreak: 'break-word' }}
weight={600}
>
{project.metadata?.name || project.id}
</Typography>
</div>

{project.type === ProjectType.SUBQUERY ? (
<Address address={project.owner} size="small" />
) : (
<Typography variant="small" style={{ textTransform: 'capitalize' }}>
<Typography variant="small" style={{ textTransform: 'uppercase' }}>
{project.manifest?.rpcFamily?.[0]}
{project.manifest?.rpcFamily?.[0] && project.manifest?.nodeType && ' - '}
{project.manifest?.nodeType}
<span style={{ textTransform: 'capitalize' }}>{project.manifest?.nodeType}</span>
</Typography>
)}

Expand All @@ -62,19 +77,13 @@ const ProjectCard: React.FC<Props> = ({ project, onClick }) => {
{project?.deployments?.nodes.reduce((cur, add) => cur + (add?.indexers.totalCount || 0), 0)}
</Typography>
<Typography variant="small" type="secondary" style={{ marginLeft: 5 }}>
Indexers
Operator
</Typography>
</div>
<span style={{ flex: 1 }}></span>
<div className="flex">
<Typography variant="small">
{formatNumber(
formatSQT(
project?.deployments?.nodes?.[0]?.deploymentBoosterSummaries?.groupedAggregates?.[0]?.sum
?.totalAmount || '0',
),
)}{' '}
{TOKEN}
{formatNumber(formatSQT(booster.toString()))} {TOKEN}
</Typography>
<Typography variant="small" type="secondary" style={{ marginLeft: 5 }}>
Boost
Expand Down
Loading