-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathindex.tsx
63 lines (52 loc) · 1.46 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { HEY_API_URL, IS_MAINNET } from "@hey/data/constants";
import { useQuery } from "@tanstack/react-query";
import axios from "axios";
import type { FC } from "react";
import HeyNft from "./HeyNft";
import HeyProfile from "./HeyProfile";
interface BadgesProps {
id: string;
}
const Badges: FC<BadgesProps> = ({ id }) => {
// Begin: Get isHeyProfile
const getIsHeyProfile = async (): Promise<boolean> => {
const response = await axios.get(`${HEY_API_URL}/badges/isHeyProfile`, {
params: { id }
});
const { data } = response;
return data?.isHeyProfile || false;
};
const { data: isHeyProfile } = useQuery({
queryFn: getIsHeyProfile,
queryKey: ["getIsHeyProfile", id]
});
// End: Get isHeyProfile
// Begin: Check has Hey NFT
const getHasHeyNft = async (): Promise<boolean> => {
const response = await axios.get(`${HEY_API_URL}/badges/hasHeyNft`, {
params: { id }
});
const { data } = response;
return data?.hasHeyNft || false;
};
const { data: hasHeyNft } = useQuery({
enabled: IS_MAINNET,
queryFn: getHasHeyNft,
queryKey: ["getHasHeyNft", id]
});
// End: Check has Hey NFT
const hasBadges = isHeyProfile || hasHeyNft;
if (!hasBadges) {
return null;
}
return (
<>
<div className="divider w-full" />
<div className="flex flex-wrap gap-3">
{isHeyProfile && <HeyProfile />}
{hasHeyNft && <HeyNft />}
</div>
</>
);
};
export default Badges;