snort/packages/app/src/Pages/new/GetVerified.tsx

116 lines
3.3 KiB
TypeScript
Raw Normal View History

2023-02-09 22:22:16 +00:00
import { useState } from "react";
2023-02-09 11:24:15 +00:00
import { FormattedMessage } from "react-intl";
import { useNavigate } from "react-router-dom";
2023-02-12 12:31:48 +00:00
import Logo from "Element/Logo";
2023-04-17 21:22:00 +00:00
import { Nip5Services } from "Pages/Verification";
2023-02-09 11:24:15 +00:00
import Nip5Service from "Element/Nip5Service";
import ProfileImage from "Element/ProfileImage";
2023-03-03 14:30:31 +00:00
import { useUserProfile } from "Hooks/useUserProfile";
2023-04-14 11:33:19 +00:00
import useLogin from "Hooks/useLogin";
2023-02-09 11:24:15 +00:00
import messages from "./messages";
export default function GetVerified() {
const navigate = useNavigate();
2023-04-14 11:33:19 +00:00
const { publicKey } = useLogin();
2023-02-09 22:22:16 +00:00
const user = useUserProfile(publicKey);
2023-02-09 22:26:13 +00:00
const [isVerified, setIsVerified] = useState(false);
const name = user?.name || "nostrich";
const [nip05, setNip05] = useState(`${name}@snort.social`);
2023-02-09 11:24:15 +00:00
const onNext = async () => {
navigate("/new/import");
};
return (
<div className="main-content new-user" dir="auto">
2023-02-12 12:31:48 +00:00
<Logo />
2023-02-09 11:24:15 +00:00
<div className="progress-bar">
<div className="progress progress-third"></div>
</div>
<h1>
<FormattedMessage {...messages.Identifier} />
</h1>
2023-04-18 12:17:50 +00:00
<div className="next-actions continue-actions">
<button className="secondary" type="button" onClick={onNext}>
<FormattedMessage {...messages.Skip} />
</button>
</div>
2023-02-09 11:24:15 +00:00
<h4>
<FormattedMessage {...messages.PreviewOnSnort} />
</h4>
<div className="profile-preview-nip">
{publicKey && <ProfileImage pubkey={publicKey} defaultNip={nip05} verifyNip={false} />}
2023-02-09 11:24:15 +00:00
</div>
<p>
<FormattedMessage {...messages.IdentifierHelp} />
</p>
<ul>
<li>
<FormattedMessage {...messages.PreventFakes} />
</li>
<li>
<FormattedMessage {...messages.EasierToFind} />
</li>
<li>
<FormattedMessage {...messages.Funding} />
</li>
</ul>
<p className="warning">
<FormattedMessage {...messages.NameSquatting} />
</p>
2023-02-09 22:22:16 +00:00
{!isVerified && (
<>
<h2>
<FormattedMessage {...messages.GetSnortId} />
</h2>
<p>
<FormattedMessage {...messages.GetSnortIdHelp} />
</p>
<div className="nip-container">
<Nip5Service
key="snort"
2023-04-17 21:22:00 +00:00
{...Nip5Services[0]}
2023-02-09 22:22:16 +00:00
helpText={false}
onChange={setNip05}
onSuccess={() => setIsVerified(true)}
/>
</div>
</>
)}
{!isVerified && (
<>
<h2>
<FormattedMessage {...messages.GetPartnerId} />
</h2>
<p>
<FormattedMessage {...messages.GetPartnerIdHelp} />
</p>
<div className="nip-container">
<Nip5Service
key="nostrplebs"
2023-04-17 21:22:00 +00:00
{...Nip5Services[1]}
2023-02-09 22:22:16 +00:00
helpText={false}
onChange={setNip05}
onSuccess={() => setIsVerified(true)}
/>
</div>
</>
)}
2023-02-09 11:24:15 +00:00
<div className="next-actions">
2023-02-09 22:22:16 +00:00
{!isVerified && (
<button type="button" className="transparent" onClick={onNext}>
<FormattedMessage {...messages.Skip} />
</button>
)}
{isVerified && (
<button type="button" onClick={onNext}>
<FormattedMessage {...messages.Next} />
</button>
)}
2023-02-09 11:24:15 +00:00
</div>
</div>
);
}