-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMintItemResult.tsx
More file actions
160 lines (153 loc) · 5.09 KB
/
MintItemResult.tsx
File metadata and controls
160 lines (153 loc) · 5.09 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import { Challenge } from "@/types/challenges";
import { MintResult } from "@/types/mint";
import {
convertIpfsImageUrl,
cutOffTooLongString,
handleDisplayAddress,
} from "@/utils";
import {
IonCard,
IonCardHeader,
IonCardSubtitle,
IonCardTitle,
IonSkeletonText,
IonGrid,
IonRow,
IonCol,
IonIcon,
IonButton,
isPlatform,
} from "@ionic/react";
import React, { useEffect, useState } from "react";
import GenerateInviteBtn from "../GenerateInvite";
import SocialShareButton from "../SocialShareButton";
const shareText = `I just minted in MyCollective.tech`;
export interface MintItemResultProps {
challenge: Challenge;
result?: MintResult;
collective?: any;
}
const MintItemResult: React.FC<MintItemResultProps> = ({
challenge,
result,
collective,
}: MintItemResultProps) => {
const [loadingImage, setLoadingImage] = useState(true);
const [canUseShare, setCanUseShare] = useState(false);
const [shareData, setShareData] = useState<ShareData | undefined>(undefined);
console.log(result, "result group!!!");
const handleShare = () => {
navigator.share(shareData);
};
useEffect(() => {
if (challenge) {
const data = {
url: `${import.meta.env.VITE_CLIENT_PRODUCTION_URL}mint/nft/${challenge.id}`,
text: shareText,
};
if (navigator.canShare && navigator.canShare(data)) {
setCanUseShare(true);
setShareData(data);
} else {
setCanUseShare(false);
}
}
}, [challenge]);
return (
<>
{result?.success && result?.group ? (
<IonGrid>
<IonRow className="ion-justify-content-center">
<IonCol className="ion-text-center">
<h2>Congrats! you Minted</h2>
</IonCol>
</IonRow>
<IonRow className="ion-justify-content-center">
<IonCol size="auto">
<IonCard className="challenge-mint-card">
<img
className="challenge-mint-img"
alt="NFT Image"
style={{ display: loadingImage ? "none" : "block" }}
src={convertIpfsImageUrl(challenge.imageUrl)}
onLoad={() => setLoadingImage(false)}
onError={() => setLoadingImage(false)}
/>
{loadingImage ? (
<IonSkeletonText
className="challenge-mint-img-skeleton"
animated={true}
></IonSkeletonText>
) : null}
<IonCardHeader>
<IonCardTitle>
{loadingImage ? (
<IonSkeletonText animated={true}></IonSkeletonText>
) : (
handleDisplayAddress(challenge.creatorOfMint ?? "")
)}
</IonCardTitle>
<IonCardSubtitle>
<div className="name">
{cutOffTooLongString(challenge.name, 20)}
</div>
<div className="cost">{challenge.floorPrice} ETH</div>
</IonCardSubtitle>
</IonCardHeader>
</IonCard>
</IonCol>
</IonRow>
<IonRow className="ion-justify-content-center ion-margin-top">
<IonCol className="ion-text-center">
<GenerateInviteBtn type="mint" groupId={result.group.id} />
</IonCol>
</IonRow>
<IonRow className="ion-justify-content-center ion-margin-bottom ">
<IonCol size="auto">
{/* <IonButton onClick={joinCollective} color="primary" shape="round">
Invite to Group
</IonButton> */}
</IonCol>
</IonRow>
<IonRow className="ion-justify-content-center ion-margin-top">
<IonCol className="ion-text-center">
<h5>Promote on socials, anyone can mint</h5>
</IonCol>
</IonRow>
<IonRow className="ion-justify-content-center">
<IonCol size="auto">
{!isPlatform("desktop") && canUseShare ? (
<IonButton shape="round" onClick={handleShare}>
Share
</IonButton>
) : (
<>
<SocialShareButton
socialNetwork="x"
text={shareText}
url={shareData?.url}
/>
{/* <SocialShareButton socialNetwork="discord" challengeId={challenge.id}/> */}
<SocialShareButton
socialNetwork="telegram"
text={shareText}
url={shareData?.url}
/>
{/* <SocialShareButton socialNetwork="sound" challengeId={challenge.id}/> */}
</>
)}
<></>
</IonCol>
</IonRow>
</IonGrid>
) : (
<IonGrid>
<IonRow className="ion-justify-content-center">
<IonCol size="8">Result</IonCol>
</IonRow>
</IonGrid>
)}
</>
);
};
export default MintItemResult;