@verified-network/verified-custody 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.json +12 -0
- package/dist/index.d.mts +165 -0
- package/dist/index.d.ts +165 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +31 -42
- package/src/components/overlays.tsx +61 -0
- package/src/components/search.tsx +381 -0
- package/src/components/slider.tsx +29 -0
- package/src/components/success.tsx +142 -0
- package/src/customTypes.d.ts +37 -0
- package/src/index.ts +17 -0
- package/src/pages/addCosigners.tsx +1014 -0
- package/src/pages/contact.tsx +280 -0
- package/src/pages/createPin.tsx +693 -0
- package/src/pages/enterPin.tsx +821 -0
- package/src/pages/ftu.tsx +244 -0
- package/src/pages/index.tsx +170 -0
- package/src/pages/otp.tsx +410 -0
- package/src/services/contracts.ts +817 -0
- package/src/services/store.tsx +65 -0
- package/src/style.css +2030 -0
- package/src/utils/config.ts +103 -0
- package/src/utils/constants.ts +1966 -0
- package/src/utils/helpers.tsx +334 -0
- package/src/utils/types.ts +85 -0
- package/tsconfig.json +16 -0
- package/tsup.config.ts +36 -0
- package/README.md +0 -93
- package/dist/main.js +0 -2
- package/dist/main.js.LICENSE.txt +0 -190
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { useVaultStore } from "../services/store";
|
|
3
|
+
import { errorToast, sendOTPVerification } from "../utils/helpers";
|
|
4
|
+
import PageSlider from "../components/slider";
|
|
5
|
+
import SearchBox from "../components/search";
|
|
6
|
+
import {
|
|
7
|
+
PrivacyOverlay,
|
|
8
|
+
TermsAndConditionsOverlay,
|
|
9
|
+
} from "../components/overlays";
|
|
10
|
+
import { imageAssets } from "../utils/constants";
|
|
11
|
+
|
|
12
|
+
const ContactPage = (props: {
|
|
13
|
+
setStep: (step: string) => void;
|
|
14
|
+
setIsLoading: (isLoading: boolean) => void;
|
|
15
|
+
setUserNumberFmt: (number: string) => void;
|
|
16
|
+
userNumberFmt: string;
|
|
17
|
+
setUserEmail: (email: string) => void;
|
|
18
|
+
userEmail: string;
|
|
19
|
+
setSelectedCountry: (country: {
|
|
20
|
+
name: string;
|
|
21
|
+
area: string;
|
|
22
|
+
flag: string;
|
|
23
|
+
}) => void;
|
|
24
|
+
selectedCountry: { name: string; area: string; flag: string };
|
|
25
|
+
allCountries: any;
|
|
26
|
+
}) => {
|
|
27
|
+
const [userNumber, setUserNumber] = useState("");
|
|
28
|
+
const [userInput, setUserInput] = useState("");
|
|
29
|
+
const [searchActive, setSearchActive] = useState(false);
|
|
30
|
+
const [sendOtpErrorText, setSendOtpErrorText] = useState("");
|
|
31
|
+
|
|
32
|
+
const { pk, vaultContract } = useVaultStore();
|
|
33
|
+
|
|
34
|
+
const handleButtonDisplay = () => {
|
|
35
|
+
const button = document.getElementById("verified-custd-mdl-contact-button");
|
|
36
|
+
if (button && props.selectedCountry.area && userNumber.length === 10) {
|
|
37
|
+
setSendOtpErrorText("");
|
|
38
|
+
button.className = "verified-custd-mdl-startup-button-active";
|
|
39
|
+
} else if (
|
|
40
|
+
button &&
|
|
41
|
+
props.userEmail?.length > 0 &&
|
|
42
|
+
isNaN(Number(props.userEmail)) &&
|
|
43
|
+
props.userEmail?.includes("@")
|
|
44
|
+
) {
|
|
45
|
+
setSendOtpErrorText("");
|
|
46
|
+
button.className = "verified-custd-mdl-startup-button-active";
|
|
47
|
+
} else {
|
|
48
|
+
setSendOtpErrorText("");
|
|
49
|
+
button!.className = "verified-custd-mdl-startup-button";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const handleSendOTP = async () => {
|
|
54
|
+
if (
|
|
55
|
+
props.userEmail?.length > 0 &&
|
|
56
|
+
!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(props.userEmail)
|
|
57
|
+
) {
|
|
58
|
+
setSendOtpErrorText("Invalid input, please check your email");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const vaultId =
|
|
63
|
+
props.userEmail?.length > 0
|
|
64
|
+
? props.userEmail
|
|
65
|
+
: `+${props.selectedCountry.area}${userNumber}`;
|
|
66
|
+
const channel = props.userEmail?.length > 0 ? "email" : "sms";
|
|
67
|
+
|
|
68
|
+
if (vaultId && channel && pk && vaultContract) {
|
|
69
|
+
props.setIsLoading(true);
|
|
70
|
+
await sendOTPVerification(vaultId, channel).then((res: any) => {
|
|
71
|
+
props.setIsLoading(false);
|
|
72
|
+
if (res) {
|
|
73
|
+
setSendOtpErrorText("");
|
|
74
|
+
props.setStep("3");
|
|
75
|
+
} else {
|
|
76
|
+
setSendOtpErrorText(
|
|
77
|
+
channel === "email"
|
|
78
|
+
? "Error while sending otp to your email. Try again later."
|
|
79
|
+
: "Error while sending otp to your phone number. Try again later."
|
|
80
|
+
);
|
|
81
|
+
errorToast(
|
|
82
|
+
"Oops something went wrong",
|
|
83
|
+
props.userEmail?.length > 0
|
|
84
|
+
? `Input a valid email and try again.`
|
|
85
|
+
: `Input a valid phone number and try again.`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div className="verified-custd-mdl-startup-language">
|
|
94
|
+
<div className="verified-custd-mdl-startup-contact">
|
|
95
|
+
<PageSlider sliderCount={[1, 2, 3]} currentSlider="0" />
|
|
96
|
+
<div className="verified-custd-mdl-startup-contact-content">
|
|
97
|
+
<p className="verified-custd-mdl-startup-contact-text">
|
|
98
|
+
Enter your phone number
|
|
99
|
+
</p>
|
|
100
|
+
<div className="verified-custd-mdl-st-contact-input">
|
|
101
|
+
<div className="verified-custd-mdl-st-contact-content-container">
|
|
102
|
+
<div
|
|
103
|
+
onClick={() => {
|
|
104
|
+
setSearchActive(!searchActive);
|
|
105
|
+
}}
|
|
106
|
+
className="verified-custd-mdl-st-contact-first-section"
|
|
107
|
+
>
|
|
108
|
+
<img
|
|
109
|
+
onClick={() => {
|
|
110
|
+
setSearchActive(!searchActive);
|
|
111
|
+
}}
|
|
112
|
+
alt="Country Flag"
|
|
113
|
+
className="verified-custd-mdl-st-contact-selection-icon"
|
|
114
|
+
src={props.selectedCountry.flag}
|
|
115
|
+
/>
|
|
116
|
+
<p
|
|
117
|
+
onClick={() => {
|
|
118
|
+
setSearchActive(!searchActive);
|
|
119
|
+
}}
|
|
120
|
+
className="verified-custd-mdl-st-contact-selection-text"
|
|
121
|
+
>
|
|
122
|
+
+ {props.selectedCountry.area}
|
|
123
|
+
</p>
|
|
124
|
+
{searchActive && (
|
|
125
|
+
<img
|
|
126
|
+
onClick={() => {
|
|
127
|
+
setSearchActive(!searchActive);
|
|
128
|
+
}}
|
|
129
|
+
alt="Dropdown Icon"
|
|
130
|
+
className="verified-custd-mdl-st-contact-dropdown"
|
|
131
|
+
src={imageAssets.arrowUp}
|
|
132
|
+
/>
|
|
133
|
+
)}
|
|
134
|
+
{!searchActive && (
|
|
135
|
+
<img
|
|
136
|
+
onClick={() => {
|
|
137
|
+
setSearchActive(!searchActive);
|
|
138
|
+
}}
|
|
139
|
+
alt="Dropdown Icon"
|
|
140
|
+
className="verified-custd-mdl-st-contact-dropdown"
|
|
141
|
+
src={imageAssets.arrowDown}
|
|
142
|
+
/>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<input
|
|
147
|
+
onInputCapture={(e: any) => {
|
|
148
|
+
if (e.target.value === "") {
|
|
149
|
+
setUserInput(userInput + " ");
|
|
150
|
+
} else {
|
|
151
|
+
setUserInput(e.target.value);
|
|
152
|
+
}
|
|
153
|
+
const numericInput = e.target.value?.replace(/\D/g, "");
|
|
154
|
+
setUserNumber(numericInput);
|
|
155
|
+
let formattedNumber = "";
|
|
156
|
+
for (let i = 0; i < numericInput?.length; i++) {
|
|
157
|
+
formattedNumber += numericInput[i];
|
|
158
|
+
if ((i + 1) % 5 === 0 && i + 1 < numericInput?.length) {
|
|
159
|
+
formattedNumber += " ";
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
props.setUserNumberFmt(formattedNumber);
|
|
163
|
+
}}
|
|
164
|
+
onInput={(e) => {
|
|
165
|
+
handleButtonDisplay();
|
|
166
|
+
}}
|
|
167
|
+
value={props.userNumberFmt}
|
|
168
|
+
id="phone-input"
|
|
169
|
+
type="text"
|
|
170
|
+
className="verified-custd-mdl-st-contact-second-section"
|
|
171
|
+
placeholder="Enter your phone number"
|
|
172
|
+
/>
|
|
173
|
+
</div>
|
|
174
|
+
{searchActive && (
|
|
175
|
+
<SearchBox
|
|
176
|
+
pageName="ftu/contact"
|
|
177
|
+
searchContent={props.allCountries}
|
|
178
|
+
type="area-code"
|
|
179
|
+
handleButtonDisplay={handleButtonDisplay}
|
|
180
|
+
setSelected={props.setSelectedCountry}
|
|
181
|
+
selected={props.selectedCountry}
|
|
182
|
+
searchActive={searchActive}
|
|
183
|
+
setSearchActive={setSearchActive}
|
|
184
|
+
contentMaxHeight="300"
|
|
185
|
+
contentbottomMargin="300"
|
|
186
|
+
/>
|
|
187
|
+
)}
|
|
188
|
+
{userNumber.length !== 10 && userInput.length > 10 && (
|
|
189
|
+
<div className="verified-custd-mdl-st-contact-input-error">
|
|
190
|
+
<p className="verified-custd-mdl-input-error-text">
|
|
191
|
+
Invalid input, please check your phone number
|
|
192
|
+
</p>
|
|
193
|
+
</div>
|
|
194
|
+
)}
|
|
195
|
+
{sendOtpErrorText?.length > 0 && props.userEmail?.length === 0 && (
|
|
196
|
+
<div className="verified-custd-mdl-st-contact-input-error">
|
|
197
|
+
<p className="verified-custd-mdl-input-error-text">
|
|
198
|
+
{sendOtpErrorText}
|
|
199
|
+
</p>
|
|
200
|
+
</div>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
{!searchActive && (
|
|
205
|
+
<React.Fragment>
|
|
206
|
+
<div className="verified-custd-mdl-p-p-payment-portal-amount-info-separator">
|
|
207
|
+
<div className="verified-custd-mdl-p-p-payment-portal-line"></div>
|
|
208
|
+
<p className="verified-custd-mdl-p-payment-portal-separator-text">
|
|
209
|
+
OR
|
|
210
|
+
</p>
|
|
211
|
+
<div className="verified-custd-mdl-p-p-payment-portal-line"></div>
|
|
212
|
+
</div>
|
|
213
|
+
<div className="verified-custd-mdl-st-contact-input">
|
|
214
|
+
<input
|
|
215
|
+
onInputCapture={(e: any) => {
|
|
216
|
+
props.setUserEmail(e.target?.value);
|
|
217
|
+
props.setUserNumberFmt("");
|
|
218
|
+
setUserNumber("");
|
|
219
|
+
setUserInput("");
|
|
220
|
+
}}
|
|
221
|
+
onInput={(e) => {
|
|
222
|
+
handleButtonDisplay();
|
|
223
|
+
}}
|
|
224
|
+
type="text"
|
|
225
|
+
className="verified-custd-mdl-st-contact-second-section"
|
|
226
|
+
placeholder="Enter your email address"
|
|
227
|
+
/>
|
|
228
|
+
{sendOtpErrorText?.length > 0 && props.userEmail?.length > 0 && (
|
|
229
|
+
<div className="verified-custd-mdl-st-contact-input-error">
|
|
230
|
+
<p className="verified-custd-mdl-input-error-text">
|
|
231
|
+
{sendOtpErrorText}
|
|
232
|
+
</p>
|
|
233
|
+
</div>
|
|
234
|
+
)}
|
|
235
|
+
</div>
|
|
236
|
+
</React.Fragment>
|
|
237
|
+
)}
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
{!searchActive && <div style={{ height: "80px" }}></div>}
|
|
241
|
+
|
|
242
|
+
<div className="verified-custd-mdl-startup-contact-footer">
|
|
243
|
+
<div className="verified-custd-mdl-st-contact-footer-first-section">
|
|
244
|
+
<TermsAndConditionsOverlay />
|
|
245
|
+
<button
|
|
246
|
+
id="verified-custd-mdl-contact-button"
|
|
247
|
+
onClick={async (e: any) => {
|
|
248
|
+
if (
|
|
249
|
+
e.target.className.includes(
|
|
250
|
+
"verified-custd-mdl-startup-button"
|
|
251
|
+
) &&
|
|
252
|
+
e.target.className !== "verified-custd-mdl-startup-button"
|
|
253
|
+
) {
|
|
254
|
+
e.target.className = "verified-custd-mdl-startup-button-click";
|
|
255
|
+
await handleSendOTP();
|
|
256
|
+
} else {
|
|
257
|
+
const buttonElement = document.getElementsByClassName(
|
|
258
|
+
"verified-custd-mdl-startup-button-active"
|
|
259
|
+
);
|
|
260
|
+
if (buttonElement.length > 0) {
|
|
261
|
+
buttonElement[0].className =
|
|
262
|
+
"verified-custd-mdl-startup-button-click";
|
|
263
|
+
await handleSendOTP();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}}
|
|
267
|
+
className="verified-custd-mdl-startup-button"
|
|
268
|
+
>
|
|
269
|
+
Get OTP
|
|
270
|
+
</button>
|
|
271
|
+
<div className="verified-custd-mdl-st-contact-footer-second-section">
|
|
272
|
+
<PrivacyOverlay />
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export default ContactPage;
|