Skip to content

Commit 0a9d5db

Browse files
authored
Merge pull request #854 from subquery/feat/update-create-project
feat: part
2 parents 1383377 + 93e868a commit 0a9d5db

6 files changed

Lines changed: 118 additions & 60 deletions

File tree

src/components/DoBooster/index.tsx

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import React, { FC, useMemo, useState } from 'react';
4+
import React, { FC, useEffect, useMemo, useState } from 'react';
55
import { AiOutlineInfoCircle } from 'react-icons/ai';
6+
import { gql, useLazyQuery, useQuery } from '@apollo/client';
67
import IPFSImage from '@components/IPFSImage';
78
import { ApproveContract } from '@components/ModalApproveToken';
89
import { NumberInput } from '@components/NumberInput';
@@ -15,6 +16,7 @@ import { useAddAllowance } from '@hooks/useAddAllowance';
1516
import { useWaitTransactionhandled } from '@hooks/useWaitTransactionHandled';
1617
import { Modal, openNotification, Spinner, Steps, Tag, Typography } from '@subql/components';
1718
import { useGetDeploymentBoosterTotalAmountByDeploymentIdQuery } from '@subql/react-hooks';
19+
import { ProjectType } from '@subql/react-hooks/dist/graphql';
1820
import { cidToBytes32, parseError, TOKEN } from '@utils';
1921
import { formatNumber, formatSQT } from '@utils/numberFormatters';
2022
import { Button, Form, Radio, Tooltip } from 'antd';
@@ -28,6 +30,7 @@ import { useWeb3Store } from 'src/stores';
2830
import styles from './index.module.less';
2931

3032
interface IProps {
33+
projectType?: ProjectType;
3134
projectId?: string;
3235
deploymentId?: string;
3336
actionBtn?: React.ReactNode;
@@ -37,6 +40,7 @@ interface IProps {
3740
}
3841

3942
const DoBooster: FC<IProps> = ({
43+
projectType,
4044
projectId,
4145
deploymentId,
4246
actionBtn,
@@ -63,6 +67,26 @@ const DoBooster: FC<IProps> = ({
6367
fetchPolicy: 'network-only',
6468
});
6569

70+
const [getAverageBooster, averageBooster] = useLazyQuery<{
71+
deploymentBoosterSummaries: {
72+
aggregates: {
73+
average: {
74+
totalAmount: string;
75+
};
76+
};
77+
};
78+
}>(gql`
79+
{
80+
deploymentBoosterSummaries(filter: { project: { type: { equalTo: ${project.data?.type} } } }) {
81+
aggregates {
82+
average {
83+
totalAmount
84+
}
85+
}
86+
}
87+
}
88+
`);
89+
6690
const [open, setOpen] = useState(initialOpen);
6791
const [loading, setLoading] = useState(false);
6892
const [addOrRemove, setAddOrRemove] = useState<'add' | 'remove'>(initAddOrRemove);
@@ -141,6 +165,14 @@ const DoBooster: FC<IProps> = ({
141165
}
142166
};
143167

168+
useEffect(() => {
169+
if (open && project.data) {
170+
getAverageBooster();
171+
}
172+
}, [open, project.data]);
173+
174+
console.warn(averageBooster.data);
175+
144176
return (
145177
<div className={styles.doBooster}>
146178
{actionBtn ? (
@@ -253,7 +285,7 @@ const DoBooster: FC<IProps> = ({
253285

254286
<div>
255287
<Form layout="vertical" form={form}>
256-
<Typography>Boost amount</Typography>
288+
<Typography>Boost amount </Typography>
257289
<Form.Item
258290
style={{ marginBottom: 0 }}
259291
name="boostVal"
@@ -291,6 +323,18 @@ const DoBooster: FC<IProps> = ({
291323
}}
292324
></NumberInput>
293325
</Form.Item>
326+
{balance.result.data?.eq(0) ? (
327+
<Typography.Link
328+
href="https://subquery.network/doc/subquery_network/token/token.html#where-is-sqt-traded"
329+
type="info"
330+
variant="small"
331+
style={{ transform: 'translateY(-10px)' }}
332+
>
333+
Get SQT
334+
</Typography.Link>
335+
) : (
336+
''
337+
)}
294338
</Form>
295339
<div className="col-flex" style={{ gap: 8, marginBottom: 24 }}>
296340
<div className="flex">
@@ -338,6 +382,36 @@ const DoBooster: FC<IProps> = ({
338382
{TOKEN}
339383
</Typography>
340384
</div>
385+
386+
<div className="flex">
387+
<Typography variant="medium" type="secondary" style={{ display: 'flex', alignItems: 'center' }}>
388+
Average Booster
389+
<Tooltip title="The total amount that you can freely boost to new projects.">
390+
<AiOutlineInfoCircle
391+
style={{ fontSize: 14, marginLeft: 6, color: 'var(--sq-gray500)' }}
392+
></AiOutlineInfoCircle>
393+
</Tooltip>
394+
</Typography>
395+
<span style={{ flex: 1 }}></span>
396+
<Typography variant="medium">
397+
{averageBooster.loading ? (
398+
<Spinner size={10}></Spinner>
399+
) : (
400+
<Tooltip
401+
title={formatSQT(
402+
averageBooster.data?.deploymentBoosterSummaries.aggregates.average.totalAmount || '0',
403+
{ fixedNum: 18 },
404+
)}
405+
>
406+
{formatSQT(
407+
averageBooster.data?.deploymentBoosterSummaries.aggregates.average.totalAmount || '0',
408+
{ fixedNum: 2 },
409+
)}
410+
</Tooltip>
411+
)}{' '}
412+
{TOKEN}
413+
</Typography>
414+
</div>
341415
</div>
342416
</div>
343417
</>

src/components/IndexerDetails/IndexerDetails.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ type Props = {
3939
const NoIndexers: React.FC = () => {
4040
const { t } = useTranslation();
4141
return (
42-
<EmptyList
43-
title={t('noIndexers.title')}
44-
description={t('noIndexers.description')}
45-
infoLinkDesc={t('noIndexers.subtitle')}
46-
infoI18nKey={t('noIndexers.subtitle')}
47-
infoLink={URLS.INDEXER}
48-
/>
42+
<EmptyList>
43+
<div>
44+
<Typography>{t('noIndexers.description')}</Typography> <br></br>
45+
Or{' '}
46+
<Typography.Link href="https://discord.com/invite/subquery" type="info">
47+
Join Discord
48+
</Typography.Link>{' '}
49+
to communicate with Node Operators directly
50+
</div>
51+
</EmptyList>
4952
);
5053
};
5154

src/components/ProjectOverview/ProjectOverview.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,12 @@ const ProjectOverview: React.FC<Props> = ({ project, metadata, deploymentDescrip
320320
</div>
321321
<span style={{ flex: 1 }}></span>
322322

323-
<DoBooster projectId={project.id} deploymentId={deploymentId} initialOpen={initialOpenModal}></DoBooster>
323+
<DoBooster
324+
projectType={project.type}
325+
projectId={project.id}
326+
deploymentId={deploymentId}
327+
initialOpen={initialOpenModal}
328+
></DoBooster>
324329
</div>
325330
}
326331
>

src/i18n/en/explorer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ const translation = {
121121
},
122122
},
123123
noIndexers: {
124-
description: 'no Node Operators available',
125-
title: 'Start indexing this project',
126-
subtitle: 'Learn how to index a SubQuery project ',
124+
description: 'Boost more SQT to attract Node Operators',
125+
title: '',
126+
subtitle:
127+
'Or Join Discord [PROVIDE LINK:https://discord.com/invite/subquery] to communicate with Node Operators directly',
127128
},
128129
indexers: {
129130
head: {

src/pages/consumer/MyBoostedProjects/MyBoostedProjects.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ const MyBoostedProjects: FC = () => {
213213
onSuccess={() => boostedProjects.refetch()}
214214
></DoBooster>
215215
<DoBooster
216-
deploymentId={deploymentId}
217216
projectId={record.projectId}
218217
actionBtn={<Typography.Link type="danger">Remove Boost</Typography.Link>}
219218
onSuccess={() => boostedProjects.refetch()}

src/pages/projects/Create/Create.tsx

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,17 @@ const Create: React.FC = () => {
124124
Now what&apos;s next?
125125
</Typography>
126126
<Typography type="secondary">
127-
Your next challenge is to get Node Operators to run your project, here are some options that you
128-
have.
127+
Explore ways to encourage Node Operators to run your project
129128
</Typography>
130129
</div>
131130

132131
<div className={styles.plainCard}>
133132
<div className="col-flex" style={{ gap: 8 }}>
134133
<Typography>Boost your Project to attract Node Operators</Typography>
135134
<Typography variant="medium" type="secondary">
136-
You should boost your project by locking SQT to increase the rewards that Node Operators can
137-
receive from your project. This is the best way to attract more Node Operators and ensure your
138-
project is indexed.{' '}
135+
Boost your project by locking SQT to increase the rewards that Node Operators can receive from
136+
your project. This is the best way to attract more Node Operators and ensure your project is
137+
indexed.{' '}
139138
<Typography.Link
140139
active
141140
href="https://academy.subquery.network/subquery_network/consumers/boosting.html#consumer-boosting"
@@ -157,11 +156,10 @@ const Create: React.FC = () => {
157156

158157
<div className={styles.plainCard}>
159158
<div className="col-flex" style={{ gap: 8 }}>
160-
<Typography>Setup Flex Plan</Typography>
159+
<Typography>Set up Flex Plan</Typography>
161160
<Typography variant="medium" type="secondary">
162-
Flex plans are a great way to indicate to Node Operators what price you are willing to pay for
163-
access to this project, you can create a flex plan today before any Node Operators complete
164-
indexing.{' '}
161+
Flex Plans are required so Node Operators know what price you are willing to pay for access to
162+
this project, you can create a flex plan today before any Node Operators complete indexing.{' '}
165163
<Typography.Link
166164
active
167165
href="https://academy.subquery.network/subquery_network/consumers/plan.html"
@@ -180,43 +178,6 @@ const Create: React.FC = () => {
180178
</Button>
181179
</Typography.Link>
182180
</div>
183-
184-
<div className={styles.plainCard}>
185-
<div className="col-flex" style={{ gap: 8 }}>
186-
<Typography>Create a closed price agreement</Typography>
187-
<Typography variant="medium" type="secondary">
188-
Creating a closed price agreement is good when only you will use the data in this project, as it
189-
creates a commitment between you and a node operator to access data for a predetermined amount
190-
of SQT.{' '}
191-
<Typography.Link
192-
active
193-
href="https://academy.subquery.network/subquery_network/consumers/plan.html"
194-
target="_blank"
195-
>
196-
Read the docs.
197-
</Typography.Link>
198-
</Typography>
199-
</div>
200-
<Typography.Link target="_href" href={`/consumer/my-offers`}>
201-
<Button shape="round" type="primary" size="large">
202-
Create agreement
203-
</Button>
204-
</Typography.Link>
205-
</div>
206-
<div className={styles.plainCard}>
207-
<div className="col-flex" style={{ gap: 8 }}>
208-
<Typography>Notify Node Operators on the Forum and in Discord</Typography>
209-
<Typography variant="medium" type="secondary">
210-
We recommend posting your project in the SubQuery Network forum and even mentioning it in the
211-
Discord community.
212-
</Typography>
213-
</div>
214-
<Typography.Link href="https://forum.subquery.network/" target="_blank">
215-
<Button shape="round" type="primary" size="large">
216-
Go to forum
217-
</Button>
218-
</Typography.Link>
219-
</div>
220181
</div>
221182
}
222183
extra={[
@@ -232,6 +193,20 @@ const Create: React.FC = () => {
232193
>
233194
View project
234195
</Button>,
196+
<a href="https://discord.com/invite/subquery" target="_blank" rel="noreferrer" key="join-discord">
197+
<Button
198+
key="view-project"
199+
type="primary"
200+
shape="round"
201+
size="large"
202+
onClick={() => {
203+
navigate(`${STUDIO_PROJECT_NAV}/${resultId}`);
204+
destroy();
205+
}}
206+
>
207+
Join Discord
208+
</Button>
209+
</a>,
235210
]}
236211
></Result>
237212
),
@@ -255,6 +230,7 @@ const Create: React.FC = () => {
255230
<Spinner></Spinner>
256231
</div>
257232
);
233+
258234
return (
259235
<div>
260236
<Formik

0 commit comments

Comments
 (0)