Show invite link only to registered twitter user

This commit is contained in:
Thunnini 2022-12-21 23:10:18 +09:00
parent 7addde9981
commit 5a8878c9e3
2 changed files with 58 additions and 45 deletions

View File

@ -8,16 +8,17 @@ import ICNSIcon from "../../public/images/svg/icns-logo.svg";
interface Props { interface Props {
isOwner?: boolean; isOwner?: boolean;
registeredTwitterName?: string;
twitterProfileInformation?: TwitterAuthInfoResponse | null; twitterProfileInformation?: TwitterAuthInfoResponse | null;
} }
export const TwitterProfile: FunctionComponent<Props> = (props) => { export const TwitterProfile: FunctionComponent<Props> = (props) => {
const { isOwner, twitterProfileInformation } = props; const { isOwner, registeredTwitterName, twitterProfileInformation } = props;
const [isCopied, setIsCopied] = useState<boolean>(false); const [isCopied, setIsCopied] = useState<boolean>(false);
const onClickInviteLink = async () => { const onClickInviteLink = async () => {
await navigator.clipboard.writeText( await navigator.clipboard.writeText(
`https://app.icns.xyz?referral=${twitterProfileInformation?.username}`, `https://app.icns.xyz?referral=${registeredTwitterName}`,
); );
setIsCopied(true); setIsCopied(true);
@ -29,7 +30,8 @@ export const TwitterProfile: FunctionComponent<Props> = (props) => {
return ( return (
<ProfileContainer color={color.grey["900"]}> <ProfileContainer color={color.grey["900"]}>
{isCopied ? ( {registeredTwitterName ? (
isCopied ? (
<InviteLinkContainer> <InviteLinkContainer>
copied copied
<CopiedIcon <CopiedIcon
@ -71,7 +73,8 @@ export const TwitterProfile: FunctionComponent<Props> = (props) => {
/> />
</CopyIcon> </CopyIcon>
</InviteLinkContainer> </InviteLinkContainer>
)} )
) : null}
<ProfileImageContainer> <ProfileImageContainer>
<Image <Image
src={twitterProfileInformation?.profile_image_url ?? ""} src={twitterProfileInformation?.profile_image_url ?? ""}

View File

@ -106,6 +106,8 @@ export default function VerificationPage() {
const [searchValue, setSearchValue] = useState(""); const [searchValue, setSearchValue] = useState("");
const [nftOwnerAddress, setNFTOwnerAddress] = useState(""); const [nftOwnerAddress, setNFTOwnerAddress] = useState("");
// Handle the token id which actually registered.
const [registeredTwitterName, setRegisteredTwitterName] = useState("");
const [isOwner, setIsOwner] = useState(false); const [isOwner, setIsOwner] = useState(false);
const [isModalOpen, setModalOpen] = useState(false); const [isModalOpen, setModalOpen] = useState(false);
@ -209,6 +211,13 @@ export default function VerificationPage() {
isRegistered: "data" in registeredQueryResponse, isRegistered: "data" in registeredQueryResponse,
}); });
if (
"data" in registeredQueryResponse &&
registeredQueryResponse.data?.name
) {
setRegisteredTwitterName(registeredQueryResponse.data.name);
}
if ("data" in registeredQueryResponse) { if ("data" in registeredQueryResponse) {
const ownerOfQueryResponse = await queryOwnerOfTwitterName( const ownerOfQueryResponse = await queryOwnerOfTwitterName(
registeredQueryResponse.data.name, registeredQueryResponse.data.name,
@ -556,6 +565,7 @@ export default function VerificationPage() {
<BackButton /> <BackButton />
<TwitterProfile <TwitterProfile
isOwner={isOwner} isOwner={isOwner}
registeredTwitterName={registeredTwitterName}
twitterProfileInformation={twitterAuthInfo} twitterProfileInformation={twitterAuthInfo}
/> />
<ChainListTitleContainer> <ChainListTitleContainer>