Skip to content

Commit d27a7b6

Browse files
authored
Merge pull request #879 from subquery/feat/replace-to-discord
feat: replace to forum card
2 parents dd46e3e + 68f1b23 commit d27a7b6

File tree

1 file changed

+59
-63
lines changed

1 file changed

+59
-63
lines changed
Lines changed: 59 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,70 @@
11
// Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { useEffect, useState } from 'react';
54
import { BsChatLeftDots } from 'react-icons/bs';
6-
import { IGetLatestTopics, useForumApis } from '@hooks/useForumApis';
75
import { SubqlCard, Typography } from '@subql/components';
8-
import { renderAsync } from '@subql/react-hooks';
9-
import { parseError } from '@utils';
10-
import { Skeleton } from 'antd';
116
import Link from 'antd/es/typography/Link';
12-
import dayjs from 'dayjs';
137

14-
export const ForumCard = () => {
15-
const forumApis = useForumApis();
16-
const [topics, setTopics] = useState<IGetLatestTopics['topic_list']['topics']>([]);
17-
18-
const getTopics = async () => {
19-
const res = await forumApis.getLatestApi();
20-
21-
setTopics(res.slice(0, 5));
22-
};
8+
const DISCORD_CHANNELS = [
9+
{
10+
id: '1479054492501672007',
11+
title: 'General',
12+
url: 'https://discord.com/channels/796198414798028831/1479054492501672007',
13+
},
14+
{
15+
id: '1479055557817008149',
16+
title: 'Subquery-foundation',
17+
url: 'https://discord.com/channels/796198414798028831/1479055557817008149',
18+
},
19+
{
20+
id: '1479308156365701191',
21+
title: 'Technical-support',
22+
url: 'https://discord.com/channels/796198414798028831/1479308156365701191',
23+
},
24+
{
25+
id: '1479308193426444348',
26+
title: 'Questions-feedback',
27+
url: 'https://discord.com/channels/796198414798028831/1479308193426444348',
28+
},
29+
{
30+
id: '1479308237944651888',
31+
title: 'Mainnet-discussions',
32+
url: 'https://discord.com/channels/796198414798028831/1479308237944651888',
33+
},
34+
];
2335

24-
useEffect(() => {
25-
getTopics();
26-
}, []);
27-
28-
return renderAsync(
29-
{
30-
loading: !!!topics.length,
31-
data: !topics.length ? undefined : topics,
32-
},
33-
{
34-
loading: () => <Skeleton active paragraph={{ rows: 14 }} style={{ marginTop: 30 }}></Skeleton>,
35-
error: (e) => <>{parseError(e)}</>,
36-
data: (topics) => {
37-
return (
38-
<SubqlCard
39-
title={
40-
<Typography style={{ display: 'flex', alignItems: 'flex-end' }}>
41-
Forum
42-
<BsChatLeftDots style={{ fontSize: 20, color: 'var(--sq-blue600)', marginLeft: 10 }}></BsChatLeftDots>
36+
export const ForumCard = () => {
37+
return (
38+
<SubqlCard
39+
title={
40+
<Typography style={{ display: 'flex', alignItems: 'flex-end' }}>
41+
Discord
42+
<BsChatLeftDots style={{ fontSize: 20, color: 'var(--sq-blue600)', marginLeft: 10 }}></BsChatLeftDots>
43+
</Typography>
44+
}
45+
width={302}
46+
>
47+
<div className="col-flex">
48+
{DISCORD_CHANNELS.map((channel) => {
49+
return (
50+
<Link
51+
key={channel.id}
52+
href={channel.url}
53+
className="col-flex"
54+
style={{ marginBottom: 16 }}
55+
target="_blank"
56+
rel="noopener noreferrer"
57+
>
58+
<Typography variant="medium" style={{ marginBottom: 0 }}>
59+
#{channel.title}
4360
</Typography>
44-
}
45-
width={302}
46-
>
47-
<div className="col-flex">
48-
{topics.map((topic) => {
49-
return (
50-
<Link
51-
key={topic.slug}
52-
href={`${import.meta.env.VITE_FORUM_DOMAIN}/t/${topic.slug}`}
53-
className="col-flex"
54-
style={{ marginBottom: 16 }}
55-
>
56-
<Typography variant="medium" style={{ marginBottom: 0 }}>
57-
{topic.title}
58-
</Typography>
59-
<Typography variant="small" type="secondary" style={{ marginTop: 8, marginBottom: 0 }}>
60-
{dayjs(topic.last_posted_at || topic.created_at)
61-
.utc(true)
62-
.fromNow()}
63-
</Typography>
64-
</Link>
65-
);
66-
})}
67-
<Link href="https://forum.subquery.network/c/kepler-network/16">View Forum</Link>
68-
</div>
69-
</SubqlCard>
70-
);
71-
},
72-
},
61+
</Link>
62+
);
63+
})}
64+
<Link href="https://discord.gg/subquery" target="_blank" rel="noopener noreferrer">
65+
Join Discord
66+
</Link>
67+
</div>
68+
</SubqlCard>
7369
);
7470
};

0 commit comments

Comments
 (0)