var Unibase; (function (Unibase) { let Themes; (function (Themes) { let Compact; (function (Compact) { let Components; (function (Components) { class Signup extends Unibase.Platform.Core.BaseComponent { jsFiles() { return ["tenants/themes/compact/index.anonymous.js", "platform/membership/managers/accountmanager.js", "libs/passwordrequirement/passwordrequirement.js"]; } cssFiles() { return ["libs/passwordrequirement/passwordrequirement.css"]; } html(id, containerid) { if (jQuery("#external-form").length === 0) { var index = new Components.Index_Anonymous(); index.init(null); } const html = `

Sign up for free

Create your account and start your free trial today

Register
or

Already have an account?Sign In

`; return html; } load(id, containerid, callback) { $(".pr-password").click(function () { var signUpPswd = $(".pr-password"); signUpPswd.passwordRequirements({ numCharacters: 8, useLowercase: true, useUppercase: true, useNumbers: true, useSpecial: true }); }); this._accountManager = Unibase.Platform.Membership.Managers.AccountManager.Instance(); var instance = this; instance.loadIndustries(); jQuery(".preloader-it").delay(500).fadeOut("slow"); jQuery("#external-container").delay(500).fadeIn("slow"); jQuery("#bizgaze_body").css("background-color", "#f4f6f7"); $("#div_modalbody").removeAttr("style"); $('#chk_ReadTerms').change(function () { if ($(this).prop("checked")) $("#btn_Register").removeClass('disabled'); else $("#btn_Register").addClass('disabled'); }); $('#passwordHide').click(function () { var input = $('#txt_Password'); input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password'); $('#passwordHide').toggleClass('fa-eye-slash fa-eye'); }); $('#confirmPasswordHide').click(function () { var input = $('#txt_ConfirmPassword'); input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password'); $('#confirmPasswordHide').toggleClass('fa-eye-slash fa-eye'); }); $("#txt_Otp").keypress(function (e) { if (e.which == 13) document.getElementById("btn_VerifyOtp").click(); }); $("#txt_PhoneNum").keypress(function (e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { MessageHelper.Instance().showError("Numbers only allowed", "div_ValidationSummary"); return false; } }); $("#btn_Register").click(function () { instance.validate(); }); $("#btn_VerifyOtp").click(function () { instance.verifyOtp(); }); $("#btn_ResendOtp").click(function () { instance.sendOtp(instance.OtpId); }); } loadIndustries() { var instance = this; this._accountManager.getIndustries().then(function (response) { if (response.result.length > 0) { $('#ddl_Industry').removeClass("hidden"); $('#txt_IndustryName').addClass("hidden"); let cmbLob = document.getElementById('ddl_Industry'); $('#ddl_Industry').empty(); $('#ddl_Industry').append(''); instance.IndustryLength = response.result.length; for (var i = 0; i < response.result.length; i++) { var data = response.result[i]; var opt = document.createElement("option"); var Name = data.industryName; var id = data.industryId + "|" + data.industryTenantId + "|" + data.isDefaultData; opt.text = Name; opt.value = id; cmbLob.append(opt); } } else { $('#ddl_Industry').addClass("hidden"); $('#txt_IndustryName').removeClass("hidden"); } }); } validate() { var instance = this; var confirmPassword = $("#txt_ConfirmPassword").val(); var password = $("#txt_Password").val(); var phone = $("#txt_PhoneNum").val(); var email = $("#txt_Email").val(); var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+((com|COM|in|IN))+$/; var signUpForm = document.getElementById('frm_Signup'); var isValid = signUpForm.checkValidity(); if (!isValid) { MessageHelper.Instance().showError("Mandatory fields are missing!", 'div_ValidationSummary'); return false; } if (password.length < 8 || confirmPassword.length < 8) { MessageHelper.Instance().showError("Password must be atleast 8 characters!", 'div_ValidationSummary'); return false; } var password = $("#txt_Password").val(); var decimal = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,15}$/; var checkpassword = password.match(decimal) ? true : false; if (checkpassword == false) { $(".pr-password").focus(); MessageHelper.Instance().showError("Please Match the Password in requested Format", "div_ValidationSummary"); return false; } if (password != confirmPassword) { MessageHelper.Instance().showError("New and Confirm Passwords doesn't match!", "div_ValidationSummary"); return false; } if (regex.test(email) == false) { MessageHelper.Instance().showError("Email is not provided in correct format", "div_ValidationSummary"); return false; } if (instance.IndustryLength != 0) { if ($('#ddl_Industry option:selected').val() == 0) { MessageHelper.Instance().showError("Select an Industry!", "div_ValidationSummary"); return false; } } else { if ($("#txt_IndustryName").val() == "") { MessageHelper.Instance().showError("Industry Name cannot be empty!", "div_ValidationSummary"); return false; } } instance._accountManager.getUser(phone, email).then(function (response) { if (response.result != null) { if (response.result.contactNumber == phone && response.result.email == email) { MessageHelper.Instance().showError("Phone Number & Email already exists!", "div_ValidationSummary"); return false; } else if (response.result.contactNumber == phone) { MessageHelper.Instance().showError("Phone Number already exists!", "div_ValidationSummary"); return false; } else if (response.result.email == email) { MessageHelper.Instance().showError("Email already exists!", "div_ValidationSummary"); return false; } } else { $(".lbl_Otp").removeClass('text-danger text-success').text("We have sent OTP on your Mobile Number and Email !"); $("#txt_Otp").val(''); $("#div_ValidationSummary").empty(); instance.sendOtp(0); } }, function () { MessageHelper.Instance().showError("Some Error has occurred!", 'div_ValidationSummary'); }); } sendOtp(isResend) { var instance = this; $(".preloader-it").fadeIn(); var postData = { FirstName: $("#txt_FirstName").val(), LastName: $("#txt_LastName").val(), ContactNumber: $("#txt_PhoneNum").val(), Email: $("#txt_Email").val(), TenantName: $("#txt_TenantName").val(), ContactOrEmail: "", IsForgotPswd: false, IsRegisterUser: false, IsSignup: true, UnibaseId: "", OtpId: isResend, UserOtp: "" }; instance._accountManager.sendOtp(postData).then(function (response) { if (isResend != 0) { $(".lbl_Otp").text("OTP has been Resent!").removeClass('text-danger', '').addClass('text-success', ''); } if (response == 0) { $(".preloader-it").delay(200).fadeOut("slow"); MessageHelper.Instance().showError("Some Error has occurred!", 'div_ValidationSummary'); } else { instance.OtpId = response; $(".preloader-it").delay(200).fadeOut("slow"); $("#modal_Otp").modal("show"); } }, function () { $(".preloader-it").delay(200).fadeOut("slow"); $("#signup-container").show(); MessageHelper.Instance().showError("Some Error has occurred!", 'div_ValidationSummary'); }); } verifyOtp() { var instance = this; if ($("#txt_Otp").val() == "") $(".lbl_Otp").text("Please Enter OTP!").addClass('text-danger', ''); else { var postData = { FirstName: "", LastName: "", ContactNumber: "", Email: "", TenantName: "", ContactOrEmail: "", IsForgotPswd: false, IsRegisterUser: false, IsSignup: true, UnibaseId: "", OtpId: instance.OtpId, UserOtp: $("#txt_Otp").val(), }; instance._accountManager.verifyOtp(postData).then(function (response) { if (response.result != null) { if (response.result.contactConfirmed == false && response.result.emailConfirmed == false) { $("#modal_Otp").modal("show"); $(".lbl_Otp").text("Invalid OTP!").addClass('text-danger', ''); $("#txt_Otp").val(''); } else { $("#modal_Otp").modal("hide"); instance.saveSignUp(response.result.contactConfirmed, response.result.emailConfirmed); } } else if (response.code.toString() == "2") { $("#modal_Otp").modal("show"); $(".lbl_Otp").text(response.errors.toString()).addClass('text-danger', ''); $("#txt_Otp").val(''); } }); } } saveSignUp(ContactConfirmed, EmailConfirmed) { var instance = this; $(".preloader-it").fadeIn(); var industryId = 0; var industryTenantId = 0; var isDefaultData = false; var industryName = ""; if ($("#txt_IndustryName").val() == "" && $("#ddl_Industry option:selected").val() != "0") { var value = $("#ddl_Industry option:selected").val().toString().split('|'); industryId = parseInt(value[0]); industryTenantId = parseInt(value[1]); isDefaultData = JSON.parse(value[2]); industryName = $("#ddl_Industry option:selected").text(); } else industryName = $("#txt_IndustryName").val(); var postData = { FirstName: $("#txt_FirstName").val(), LastName: $("#txt_LastName").val(), ContactNumber: $("#txt_PhoneNum").val(), Email: $("#txt_Email").val(), Password: $("#txt_Password").val(), TenantName: $("#txt_TenantName").val(), TenantId: 0, ContactNumberConfirmed: ContactConfirmed, EmailConfirmed: EmailConfirmed, IndustryId: industryId, IndustryTenantId: industryTenantId, IndustryName: industryName, IsDefaultData: isDefaultData, }; instance._accountManager.signUp(postData).then(function (response) { $("#frm_Signup").find("input,textarea").val(''); $("#frm_Signup").find("input").prop("checked", false); $(".preloader-it").delay(200).fadeOut("slow"); if (response.errors == null) { MessageHelper.Instance().showSuccess("Tenant Created Successfully", 'div_ValidationSummary'); instance.fileCacheHelper.loadJsFileAsync('tenants/themes/compact/components/signup/signupsuccesspage.js', function () { Unibase.Themes.Compact.Components.SignupSuccessPage.Instance().init("#bizgaze_body"); }); } else { MessageHelper.Instance().showError(response.message, 'div_ValidationSummary'); $(".preloader-it").delay(200).fadeOut("slow"); return false; } }, function () { $(".preloader-it").delay(200).fadeOut("slow"); $("#signup-container").show(); MessageHelper.Instance().showError("Some Error has occurred!", 'div_ValidationSummary'); }); } static Instance() { return new Signup(); } } Components.Signup = Signup; })(Components = Compact.Components || (Compact.Components = {})); })(Compact = Themes.Compact || (Themes.Compact = {})); })(Themes = Unibase.Themes || (Unibase.Themes = {})); })(Unibase || (Unibase = {}));