forked from passportxyz/passport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNoStampModal.tsx
103 lines (95 loc) · 3.38 KB
/
NoStampModal.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
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
// --- React Methods
import React, { useContext, useState } from "react";
// --- Chakra Elements
import { Modal, ModalOverlay, ModalContent, ModalCloseButton } from "@chakra-ui/react";
// --- Shared context
import { UserContext } from "../context/userContext";
import { AdditionalSignature, fetchAdditionalSigner } from "../signer/utils";
import { AdditionalStampModal } from "./AdditionalStampModal";
import { LoadButton } from "./LoadButton";
export type NoStampModalProps = {
isOpen: boolean;
onClose: () => void;
};
export const NoStampModal = ({ isOpen, onClose }: NoStampModalProps) => {
// pull context in to element
const { address } = useContext(UserContext);
const [verificationInProgress, setVerificationInProgress] = useState(false);
const [additionalSigner, setAdditionalSigner] = useState<AdditionalSignature | undefined>();
const resetStateAndClose = () => {
setAdditionalSigner(undefined);
setVerificationInProgress(false);
onClose();
};
return (
<Modal
isOpen={isOpen}
onClose={() => {
resetStateAndClose();
}}
blockScrollOnMount={false}
>
<ModalOverlay />
<ModalContent>
<div className="m-3 flex flex-col items-center">
<ModalCloseButton
onClick={() => {
resetStateAndClose();
}}
color="var(--color-text-1)"
/>
{additionalSigner ? (
<AdditionalStampModal
additionalSigner={additionalSigner}
onClose={() => {
resetStateAndClose();
}}
/>
) : (
<>
<div className="mt-2 w-fit rounded-full bg-pink-500/25">
<img className="m-2" alt="shield-exclamation-icon" src="./assets/shield-exclamation-icon-warning.svg" />
</div>
<p className="m-1 text-sm font-bold">You do not meet the eligibility criteria</p>
<p className="m-1 mb-4 text-center">
The stamp you are trying to verify could not be associated with your current Ethereum wallet address.
</p>
<div className="flex w-full">
{/* <a
href="https://ens.domains/"
target="_blank"
className="m-1 w-1/2 items-center rounded-md border py-2 text-center"
rel="noreferrer"
onClick={() => {
onClose();
}}
>
Go to ENS
</a> */}
<LoadButton
data-testid="check-other-wallet"
className="m-1 w-full"
onClick={async () => {
// mark as verifying
setVerificationInProgress(true);
try {
// fetch the credentials
const additionalSigner = await fetchAdditionalSigner(address!);
setAdditionalSigner(additionalSigner);
} finally {
// mark as done
setVerificationInProgress(false);
}
}}
isLoading={verificationInProgress}
>
Try another wallet
</LoadButton>
</div>
</>
)}
</div>
</ModalContent>
</Modal>
);
};