var Unibase; (function (Unibase) { let Themes; (function (Themes) { let Compact; (function (Compact) { let Components; (function (Components) { class MobilRegisterUser 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", 'tenants/themes/compact/css/style.ext.css']; } html(id, containerid) { if (jQuery("#external-form").length === 0) { var index = new Components.Index_Anonymous(); index.init(null); } const html = `

Registration

We will send new code to your Email or Phone to create your password.

Back to login

Create your Password

Back to login

Password Created Successfully

Click here to Login

`; 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(); 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"); $(".btn-outline-secondary").addClass('hidden'); $("#passwordHide").click(function () { var input = $('#txt_NewPswd'); 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_ConfirmPswd'); input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password'); $('#confirmPasswordHide').toggleClass('fa-eye-slash fa-eye'); }); $("#OtpHide").click(function () { var input = $('#txt_Otp'); input.attr('type') == "password" ? input.attr('type', 'text') : input.attr('type', 'password'); $('#OtpHide').toggleClass('fa-eye-slash fa-eye'); }); $("#txt_EmailorPhone").keypress(function (e) { if (e.which == 13) document.getElementById("btn_SendOtp").click(); }); $("#txt_EmailorPhone").focusout(function (e) { instance.loadUserTenants(); }); $(".txt_Otp:last").keypress(function (e) { if (e.which == 13) $("#btn_VerifyOtp").click(); }); $("#txt_NewPswd,#txt_ConfirmPswd").keypress(function (e) { if (e.which == 13) document.getElementById("btn_CreatePswd").click(); }); var instance = this; $("#btn_SendOtp").click(function () { instance.validate(); }); $("#btn_CreatePswd").click(function () { instance.createPassword(); }); $("#btn_VerifyOtp").click(function () { instance.verifyOtp(); }); $("#btn_ResendOtp").click(function () { instance.sendOtp(instance.OtpId); }); $("#InputTermsandConditions").click(function (e) { e.stopPropagation(); e.preventDefault(); $("#modal_termsandconditions").modal("show"); }); $("#InputTermsandConditionsAccept").click(function () { var accept = $("#InputTermsandConditionsAccept").prop("checked"); if (accept == true) { $('#InputTermsandConditions').prop('checked', true); $("#modal_termsandconditions").modal('hide'); $('#btn_CreatePswd').prop("disabled", false); } else { $('#InputTermsandConditions').prop('checked', false); $('#btn_CreatePswd').prop("disabled", true); } }); $('.floating-label-form-group .txt_Otp').on('input', function (e) { const inputEl = this; inputEl.value = inputEl.value.replace(/[^0-9]/g, ''); }); $(".txt_Otp").click(function () { $(".lbl_Otp").empty(); }); if (callback != null) callback(); } otpInputTabChange(val) { const ele = $('.txt_Otp'); if (ele[val - 1].value != '') { if (ele[val]) ele[val].focus(); } else if (ele[val - 1].value == '') { if (ele[val - 2]) ele[val - 2].focus(); } } loadTenants() { var instance = this; instance._accountManager.getTenants().then(function (response) { var res = response; let cmbLob = document.getElementById('ddl_Tenant'); $('#ddl_Tenant').empty(); $('#ddl_Tenant').append(''); for (var i = 0; i < response.result.length; i++) { var data = response.result[i]; var opt = document.createElement("option"); var Name = data.tenantName; var id = data.tenantId; opt.text = Name; opt.value = id; cmbLob.append(opt); } if (res.result.filter(x => x.isTemplateDb == false).length == 1) { var Id = $('#ddl_Tenant option[value=' + res.result.filter(x => x.isTemplateDb == false)[0].tenantId + ']'); Id.attr("selected", true); $("#ddl_Tenant").prop('disabled', true); } }); } loadUserTenants() { var instance = this; var emailorphone = $("#txt_EmailorPhone").val(); instance._accountManager.getUserTenants(emailorphone).then(function (response) { debugger; var res = response; let cmbLob = document.getElementById('ddl_Tenant'); $('#ddl_Tenant').empty(); $('#ddl_Tenant').append(''); for (var i = 0; i < response.result.length; i++) { var data = response.result[i]; var opt = document.createElement("option"); var Name = data.tenantName; var id = data.defaultTenantId; opt.text = Name; opt.value = id; cmbLob.append(opt); } if (res.result.filter(x => x.isTemplateDb == false).length == 1) { var Id = $('#ddl_Tenant option[value=' + res.result.filter(x => x.isTemplateDb == false)[0].tenantId + ']'); Id.attr("selected", true); $("#ddl_Tenant").removeClass('hidden'); $("#ddl_Tenant").prop('disabled', true); } else if (res.result.length == 1) { var Id = $('#ddl_Tenant option[value=' + res.result[0].defaultTenantId + ']'); Id.attr("selected", true); $("#ddl_Tenant").removeClass('hidden'); $("#ddl_Tenant").prop('disabled', true); } else if (res.result.length == 0) { $("#ddl_Tenant").addClass('hidden'); MessageHelper.Instance().showError("This Numberis not registered with any distributor! Please contact your DSR for further process.", "div_ValidationSummary"); return false; } else { var Id = $('#ddl_Tenant option[value=' + res.result[0].defaultTenantId + ']'); Id.attr("selected", true); $("#ddl_Tenant").removeClass('hidden'); $("#ddl_Tenant").prop('disabled', false); } }); } validate() { $(".lbl_Otp").text(""); $("#txt_Otp").val(''); $("#div_ValidationSummary").empty(); var phoneOrEmail = $("#txt_EmailorPhone").val(); var tenantId = $("#ddl_Tenant option:selected").val(); if (phoneOrEmail == "" && tenantId == 0) { MessageHelper.Instance().showError("Please enter Email/Phone and select a Distributor !", "div_ValidationSummary"); return false; } if (phoneOrEmail == "") { MessageHelper.Instance().showError("Email or Phone cannot be Empty!", "div_ValidationSummary"); return false; } if (tenantId == 0) { MessageHelper.Instance().showError("Please select a Distributor", "div_ValidationSummary"); return false; } else { var instance = this; instance._accountManager.getContact(phoneOrEmail, tenantId).then(function (response) { if (response.result != null) { instance.Email = response.result.emailAddress; instance.ContactNumber = response.result.phoneNumber; instance.UserName = response.result.unibaseId; instance.TenantId = response.result.tenantId; instance.ContactName = response.result.userName; $("#div_ValidationSummary").empty(); instance.sendOtp(0); } else { MessageHelper.Instance().showError(response.message, "div_ValidationSummary"); } }); } } sendOtp(IsResend) { var instance = this; $(".preloader-it").fadeIn(); var postData = { ContactOrEmail: $("#txt_EmailorPhone").val(), FirstName: instance.ContactName, LastName: "", ContactNumber: "", Email: "", TenantName: "", IsSignup: false, IsForgotPswd: false, IsRegisterUser: true, UnibaseId: instance.UserName, OtpId: IsResend, UserOtp: "" }; instance._accountManager.sendOtp(postData).then(function (response) { if (IsResend != 0) { $(".lbl_Otp").text("We have resent the OTP to your Registered Mobile Number!").removeClass('text-danger'); } if (response == 0) { $(".preloader-it").delay(200).fadeOut("slow"); MessageHelper.Instance().showError("Some Error has occurred!", 'div_ValidationSummary'); } else { instance.OtpId = response; $("#modal_Otp").modal("show"); $(".preloader-it").delay(200).fadeOut("slow"); $("#btn_ResendOtp").prop("disabled", true); $(".otpdiv").removeClass('hidden'); $(".timerdiv").removeClass('hidden'); $(".modal-footer").show(); $("#txt_Otp").parent().removeClass('col-sm-12').addClass('col-sm-7'); Unibase.Themes.Compact.Components.MobilRegisterUser.Instance().timer(60, IsResend); } }, function () { $(".preloader-it").delay(200).fadeOut("slow"); MessageHelper.Instance().showError("Some Error has occurred!", 'div_ValidationSummary'); }); } verifyOtp() { var otpMsg = ""; $(".floating-label-form-group .txt_Otp").each(function () { otpMsg += $(this).val(); }); parseInt(otpMsg); $(".floating-label-form-group").find('#otpMsg').attr("value", otpMsg); var instance = this; if ($("#otpMsg").val() == "") $(".lbl_Otp").text("Please Enter OTP!").addClass('text-danger', ''); if ($("#otpMsg").val() < 6) $(".lbl_Otp").text("Please Enter 6 Digit OTP!").addClass('text-danger', ''); else { var postData = { FirstName: "", LastName: "", ContactNumber: "", Email: "", TenantName: "", ContactOrEmail: "", IsForgotPswd: false, IsRegisterUser: false, IsSignup: true, UnibaseId: "", OtpId: instance.OtpId, UserOtp: $("#otpMsg").val(), }; instance._accountManager.verifyOtp(postData).then(function (response) { if (response.code.toString() == "2") { $(".preloader-it").delay(200).fadeOut("slow"); $(".lbl_Otp").text("Otp Expired, Please click on Resend to get new OTP").addClass('text-danger', ''); $("#otpMsg").val(''); } else if (response.result != null) { if (response.result.contactConfirmed == false && response.result.emailConfirmed == false) { $(".preloader-it").delay(200).fadeOut("slow"); $(".lbl_Otp").text("Invalid OTP!").addClass('text-danger', ''); $("#otpMsg").text(''); } else { $(".preloader-it").fadeIn(); $("#div_RegisterUser").addClass('d-none'); $("#modal_Otp").modal("hide"); $(".preloader-it").delay(200).fadeOut("slow"); $("#lbl_Email").text($("#txt_EmailorPhone").val()); $("#div_CreatePswd").removeClass('d-none'); } } }); } } createPassword() { var instance = this; $("#div_ValidationSummary").empty(); var confirmPassword = $("#txt_ConfirmPswd").val(); var password = $("#txt_NewPswd").val(); if (password.length == 0 || confirmPassword.length == 0) { MessageHelper.Instance().showError("Password fields cannot be empty!", 'div_ValidationSummary'); return false; } if (password.length < 8 || confirmPassword.length < 8) { MessageHelper.Instance().showError("Password must be atleast 8 characters!", 'div_ValidationSummary'); return false; } if (password != confirmPassword) { MessageHelper.Instance().showError("New and Confirm Passwords doesn't match!", "div_ValidationSummary"); return false; } var password = $("#txt_ConfirmPswd").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; } var postData = { Password: $("#txt_NewPswd").val(), UserName: instance.UserName, Email: instance.Email, ContactNumber: instance.ContactNumber, TenantId: instance.TenantId, }; instance._accountManager.registerUser(postData).then(function (response) { if (response.errors == null) { $("#div_CreatePswd").addClass('d-none'); $("#div_SuccessMsg").removeClass('d-none'); MessageHelper.Instance().showSuccess("Password Created Successfully", 'div_ValidationSummary'); } else { $(".preloader-it").delay(200).fadeOut("slow"); MessageHelper.Instance().showError(response.errors[0], "div_ValidationSummary"); } }); } submit() { } timer(remaining, resend) { let timerOn = true; let m = Math.floor(remaining / 60); let s = remaining % 60; let mins = m < 10 ? '0' + m : m; let seconds = s < 10 ? '0' + s : s; document.getElementById('mycounter').innerHTML = mins + ':' + seconds; remaining -= 1; if (remaining >= 0 && timerOn) { setTimeout(function () { Unibase.Themes.Compact.Components.MobilRegisterUser.Instance().timer(remaining, resend); }, 1000); return; } if (!timerOn) { return; } if (resend != 0) { $(".otpdiv").addClass('hidden'); $(".timerdiv").addClass('hidden'); $(".lbl_Otp").text("Please contact the DSR for registration!").addClass('text-danger', ''); $(".modal-footer").hide(); } else { $("#btn_ResendOtp").prop("disabled", false); $("#txt_Otp").parent().removeClass('col-sm-7').addClass('col-sm-12'); } } static Instance() { return new MobilRegisterUser(); } } Components.MobilRegisterUser = MobilRegisterUser; })(Components = Compact.Components || (Compact.Components = {})); })(Compact = Themes.Compact || (Themes.Compact = {})); })(Themes = Unibase.Themes || (Unibase.Themes = {})); })(Unibase || (Unibase = {}));