()
| 15 | import { emailRegex } from "../constant/const"; |
| 16 | |
| 17 | const AddAdmin = () => { |
| 18 | const appName = |
| 19 | "OpenSign™"; |
| 20 | const { t, i18n } = useTranslation(); |
| 21 | const navigate = useNavigate(); |
| 22 | const dispatch = useDispatch(); |
| 23 | const [showPassword, setShowPassword] = useState(false); |
| 24 | const [name, setName] = useState(""); |
| 25 | const [phone, setPhone] = useState(""); |
| 26 | const [password, setPassword] = useState(""); |
| 27 | const [email, setEmail] = useState(""); |
| 28 | const [company, setCompany] = useState(""); |
| 29 | const [jobTitle, setJobTitle] = useState(""); |
| 30 | const [lengthValid, setLengthValid] = useState(false); |
| 31 | const [caseDigitValid, setCaseDigitValid] = useState(false); |
| 32 | const [specialCharValid, setSpecialCharValid] = useState(false); |
| 33 | const [isAuthorize, setIsAuthorize] = useState(false); |
| 34 | const [isSubscribeNews, setIsSubscribeNews] = useState(false); |
| 35 | const [errMsg, setErrMsg] = useState(""); |
| 36 | const [state, setState] = useState({ |
| 37 | loading: false, |
| 38 | alertType: "success", |
| 39 | alertMsg: "" |
| 40 | }); |
| 41 | const togglePasswordVisibility = () => setShowPassword(!showPassword); |
| 42 | |
| 43 | useEffect(() => { |
| 44 | checkUserExist(); |
| 45 | // eslint-disable-next-line |
| 46 | }, []); |
| 47 | const checkUserExist = async () => { |
| 48 | setState((prev) => ({ ...prev, loading: true })); |
| 49 | try { |
| 50 | const app = await getAppLogo(); |
| 51 | if (app?.error === "invalid_json") { |
| 52 | setErrMsg(t("server-down", { appName: appName })); |
| 53 | } else if (app?.user === "exist") { |
| 54 | setErrMsg(t("admin-exists")); |
| 55 | } |
| 56 | } catch (err) { |
| 57 | setErrMsg(t("something-went-wrong-mssg")); |
| 58 | console.log("err in check user exist", err); |
| 59 | } finally { |
| 60 | setState((prev) => ({ ...prev, loading: false })); |
| 61 | } |
| 62 | }; |
| 63 | const clearStorage = async () => { |
| 64 | try { |
| 65 | await Parse.User.logOut(); |
| 66 | } catch (err) { |
| 67 | console.log("Err while logging out", err); |
| 68 | } |
| 69 | const baseUrl = localStorage.getItem("baseUrl"); |
| 70 | const appid = localStorage.getItem("parseAppId"); |
| 71 | const applogo = localStorage.getItem("appLogo"); |
| 72 | const defaultmenuid = localStorage.getItem("defaultmenuid"); |
| 73 | const PageLanding = localStorage.getItem("PageLanding"); |
| 74 | const userSettings = localStorage.getItem("userSettings"); |
nothing calls this directly
no test coverage detected