`;
return html;
}
load(id, containerid, callback) {
return __awaiter(this, void 0, void 0, function* () {
this._accountManager = yield Unibase.Platform.Membership.Managers.AccountManager.Instance();
yield this.loadTenants(callback);
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");
$(".pr-password").click(function () {
var signUpPswd = $(".pr-password");
signUpPswd.passwordRequirements({
numCharacters: 8,
useLowercase: true,
useUppercase: true,
useNumbers: true,
useSpecial: true
});
});
$("#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_Otp").keypress(function (e) {
if (e.which == 13)
document.getElementById("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);
});
if (callback != null)
callback();
});
}
loadTenants(callback) {
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);
}
if (callback != null) {
callback();
}
});
}
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 Tenant !", "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 Tenant", "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;
$(".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);
}
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("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;
$("#modal_Otp").modal("show");
$(".preloader-it").delay(200).fadeOut("slow");
}
}, function () {
$(".preloader-it").delay(200).fadeOut("slow");
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.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', '');
$("#txt_Otp").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', '');
$("#txt_Otp").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 = password;
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() {
}
static Instance() {
return new HomeAffairsRegisterUser();
}
}
Components.HomeAffairsRegisterUser = HomeAffairsRegisterUser;
})(Components = Compact.Components || (Compact.Components = {}));
})(Compact = Themes.Compact || (Themes.Compact = {}));
})(Themes = Unibase.Themes || (Unibase.Themes = {}));
})(Unibase || (Unibase = {}));