MCPcopy Create free account
hub / github.com/OpenSignLabs/OpenSign / AddContact

Function AddContact

apps/OpenSign/src/primitives/AddContact.jsx:10–281  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

8import { sessionStatus } from "../redux/reducers/userReducer";
9
10const AddContact = (props) => {
11 const { t } = useTranslation();
12 const dispatch = useDispatch();
13 const [name, setName] = useState("");
14 const [phone, setPhone] = useState("");
15 const [email, setEmail] = useState("");
16 const [jobTitle, setJobTitle] = useState("");
17 const [company, setCompany] = useState("");
18 const [addYourself, setAddYourself] = useState(false);
19 const [isLoader, setIsLoader] = useState(false);
20 const [isUserExist, setIsUserExist] = useState(false);
21 const [isOptionalDetails, setIsOptionalDetails] = useState(false);
22
23 useEffect(() => {
24 checkUserExist();
25 // eslint-disable-next-line react-hooks/exhaustive-deps
26 }, []);
27 // Load user details from localStorage when the component mounts
28 useEffect(() => {
29 const savedUserDetails = JSON.parse(
30 localStorage.getItem("UserInformation")
31 );
32 if (savedUserDetails && addYourself) {
33 setName(savedUserDetails.name);
34 setPhone(savedUserDetails?.phone || "");
35 setEmail(savedUserDetails.email);
36 setJobTitle(savedUserDetails?.jobTitle || "");
37 setCompany(savedUserDetails?.company || "");
38 }
39 }, [addYourself]);
40
41 const checkUserExist = async () => {
42 try {
43 const baseURL = localStorage.getItem("baseUrl");
44 const url = `${baseURL}functions/isuserincontactbook`;
45 const token =
46 { "X-Parse-Session-Token": localStorage.getItem("accesstoken") };
47 const headers = {
48 "Content-Type": "application/json",
49 "X-Parse-Application-Id": localStorage.getItem("parseAppId"),
50 ...token
51 };
52 const axiosRes = await axios.post(url, {}, { headers });
53 const contactRes = axiosRes?.data?.result || {};
54 if (!contactRes?.objectId) {
55 setIsUserExist(true);
56 }
57 } catch (err) {
58 console.log("err ", err);
59 }
60 };
61 // Define a function to handle form submission
62 const handleSubmit = async (e) => {
63 e.preventDefault();
64 e.stopPropagation();
65 if (!emailRegex.test(email)) {
66 alert(t("valid-email-alert"));
67 } else {

Callers

nothing calls this directly

Calls 2

checkUserExistFunction · 0.70
handleResetFunction · 0.70

Tested by

no test coverage detected