reimplemented login system and added state list component.
This commit is contained in:
Vendored
+157
-87
@@ -2,9 +2,64 @@ async function addressDetails() {
|
||||
debugger;
|
||||
// const user_addr_num =$("#Profile_Phone_num").val();
|
||||
getbillinginfoBind();
|
||||
let addr_phone=$('#phonenumber');
|
||||
let addr_addrline =$('#addressdes');
|
||||
let addr_zip =$('#zipcode');
|
||||
let addr_phone = $('#phonenumber');
|
||||
let addr_addrline = $('#addressdes');
|
||||
let addr_zip = $('#zipcode');
|
||||
|
||||
let stateArr = [];
|
||||
|
||||
function getCustomDropDownHTML({ cityid, cityname, countryid }) {
|
||||
return ` <div class="bg-white stateoption px-2 border-bottom py-2 cursor-pointer" data-name="${cityname}" data-value="${cityid}">${cityname}</div>`;
|
||||
}
|
||||
|
||||
function renderCustomStateDropdown(stateList) {
|
||||
let html = ``;
|
||||
debugger;;
|
||||
let maxLen = stateList.length > 10 ? 10 : stateList.length
|
||||
for (let i = 0; i < maxLen; i++) {
|
||||
let currItem = stateList[i];
|
||||
html += getCustomDropDownHTML(currItem);
|
||||
}
|
||||
|
||||
$('.stateBox').html(html);
|
||||
|
||||
$('.stateoption').off().click(function (e) {
|
||||
debugger;
|
||||
const name = $(e.target).data('name');
|
||||
const id = $(e.target).data('value');
|
||||
$('#state').val(name);
|
||||
$('#state').attr('data-id', id);
|
||||
})
|
||||
}
|
||||
|
||||
function loadDropdownStateEvents() {
|
||||
$('#state').off().focus(function () {
|
||||
$('.stateBox').removeClass('d-none');
|
||||
$(document).off('click').click(closeDrop);
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
$(document).off().click(closeDrop);
|
||||
|
||||
function closeDrop(e) {
|
||||
let id = $(e.target).hasClass('stateoption');
|
||||
if ($(e.target).attr('id') === 'state') return;
|
||||
if (id) {
|
||||
$('.stateBox').addClass('d-none');
|
||||
$(document).off();
|
||||
} else {
|
||||
$('.stateBox').addClass('d-none');
|
||||
$(document).off();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$('#state').keyup(debounce(function (event) {
|
||||
onChangeState(event)
|
||||
}));
|
||||
}
|
||||
|
||||
function getbillinginfoBind() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
@@ -22,63 +77,67 @@ async function addressDetails() {
|
||||
addr_phone.val(res.phonenumber);
|
||||
$('#Profile_User_name').val(res.organizationname)
|
||||
$('#Profile_Phone_num').val(res.phonenumber)
|
||||
let Profileusername =$('#Profile_User_name').val()
|
||||
let Profileuserphone=$('#Profile_Phone_num').val()
|
||||
let Profileusername = $('#Profile_User_name').val()
|
||||
let Profileuserphone = $('#Profile_Phone_num').val()
|
||||
$('.overview_user_name').html(Profileusername);
|
||||
$('.overview_user_phone').html(Profileuserphone);
|
||||
$('.overview_user_phone').html(Profileuserphone);
|
||||
if (res.cityid == "0") {
|
||||
$(".profile_Address").html(
|
||||
`<div class=User_address><button class="btn btn-outline-primary create_address" type="button"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"/></svg> ADD NEW ADDRESS</button></div>`
|
||||
);
|
||||
|
||||
|
||||
$(".address_edit").hide();
|
||||
$(".create_address").on("click", function () {
|
||||
debugger
|
||||
$(this).hide();
|
||||
$('.saveaddress').hide()
|
||||
$(".addresslist").show();
|
||||
$(".Createaddress").show();
|
||||
getCountryStateCurrency();
|
||||
});
|
||||
$('.Createaddress').on('click',async function(){
|
||||
if( addr_zip.val() == "" || addr_addrline.val() == ""){
|
||||
// toastr.error('Required Feilds are Empty!');
|
||||
// if(addr_phone.val() == '' || addr_phone.val().length <10){
|
||||
// addr_phone.addClass("is-invalid");
|
||||
// }
|
||||
// else{
|
||||
// addr_phone.removeClass("is-invalid");
|
||||
// }
|
||||
if(addr_zip.val() == '' || addr_zip.val().length < 6){
|
||||
addr_zip.addClass("is-invalid");
|
||||
}
|
||||
else{
|
||||
addr_zip.removeClass("is-invalid");
|
||||
}
|
||||
if(addr_addrline.val() == ''){
|
||||
addr_addrline.addClass("is-invalid");
|
||||
} else{
|
||||
addr_addrline.removeClass("is-invalid");
|
||||
}
|
||||
}
|
||||
else{
|
||||
$(".addresslist").hide();
|
||||
$(".profile_Address").show();
|
||||
$(".address_edit").show();
|
||||
$(".address_edit_cancel").hide();
|
||||
await createBillingForm()
|
||||
await getbillinginfoBind();
|
||||
}
|
||||
|
||||
debugger
|
||||
$(this).hide();
|
||||
$('.saveaddress').hide()
|
||||
$(".addresslist").show();
|
||||
$(".Createaddress").show();
|
||||
getCountryStateCurrency();
|
||||
});
|
||||
$('.Createaddress').on('click', async function () {
|
||||
if (addr_zip.val() == "" || addr_addrline.val() == "") {
|
||||
// toastr.error('Required Feilds are Empty!');
|
||||
// if(addr_phone.val() == '' || addr_phone.val().length <10){
|
||||
// addr_phone.addClass("is-invalid");
|
||||
// }
|
||||
// else{
|
||||
// addr_phone.removeClass("is-invalid");
|
||||
// }
|
||||
if (addr_zip.val() == '' || addr_zip.val().length < 6) {
|
||||
addr_zip.addClass("is-invalid");
|
||||
}
|
||||
else {
|
||||
addr_zip.removeClass("is-invalid");
|
||||
}
|
||||
if (addr_addrline.val() == '') {
|
||||
addr_addrline.addClass("is-invalid");
|
||||
} else {
|
||||
addr_addrline.removeClass("is-invalid");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(".addresslist").hide();
|
||||
$(".profile_Address").show();
|
||||
$(".address_edit").show();
|
||||
$(".address_edit_cancel").hide();
|
||||
await createBillingForm()
|
||||
await getbillinginfoBind();
|
||||
}
|
||||
|
||||
})
|
||||
} else {
|
||||
$(".profile_Address").html(
|
||||
`<div class=User_address><address><p><strong class="text-capitalize">${res.organizationname}</strong><p>${res.addressline},${res.cityname}<br>${res.statename},${res.zipcode}<p>Mobile: ${res.phonenumber}</address></div>`
|
||||
`<div class=User_address><address><p><strong class="">${res.organizationname}</strong><p>${res.addressline},${res.cityname},${res.zipcode}<p>Mobile: ${res.phonenumber}</address></div>`
|
||||
);
|
||||
$('#state').val(res.cityname)
|
||||
$('#state').attr('data-id',res.cityid);
|
||||
$('#zipcode').val(res.zipcode);
|
||||
$('#addressdes').val(res.addressline);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
} debugger
|
||||
} debugger
|
||||
|
||||
|
||||
$(".address_edit").on("click", function () {
|
||||
@@ -87,7 +146,7 @@ async function addressDetails() {
|
||||
$(".addresslist").show();
|
||||
$(".address_edit_cancel").show();
|
||||
getCountryStateCurrency();
|
||||
getbillinginfoBind()
|
||||
getbillinginfoBind()
|
||||
});
|
||||
|
||||
$(".address_edit_cancel").on("click", function () {
|
||||
@@ -100,9 +159,9 @@ async function addressDetails() {
|
||||
$(".saveaddress")
|
||||
.off("click")
|
||||
.click(async function () {
|
||||
|
||||
debugger
|
||||
if(addr_zip.val() == "" || addr_addrline.val() == ""){
|
||||
|
||||
debugger
|
||||
if (addr_zip.val() == "" || addr_addrline.val() == "") {
|
||||
// toastr.error('Required Feilds are Empty!');
|
||||
// if(addr_phone.val() == '' || addr_phone.val().length <10){
|
||||
// addr_phone.addClass("is-invalid");
|
||||
@@ -110,33 +169,56 @@ async function addressDetails() {
|
||||
// else{
|
||||
// addr_phone.removeClass("is-invalid");
|
||||
// }
|
||||
if(addr_zip.val() == '' || addr_zip.val().length < 6){
|
||||
addr_zip.addClass("is-invalid");
|
||||
}
|
||||
else{
|
||||
addr_zip.removeClass("is-invalid");
|
||||
}
|
||||
if(addr_addrline.val() == ''){
|
||||
addr_addrline.addClass("is-invalid");
|
||||
} else{
|
||||
addr_addrline.removeClass("is-invalid");
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (addr_zip.val() == '' || addr_zip.val().length < 6) {
|
||||
addr_zip.addClass("is-invalid");
|
||||
}
|
||||
else {
|
||||
addr_zip.removeClass("is-invalid");
|
||||
}
|
||||
if (addr_addrline.val() == '') {
|
||||
addr_addrline.addClass("is-invalid");
|
||||
} else {
|
||||
addr_addrline.removeClass("is-invalid");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(".addresslist").hide();
|
||||
$(".profile_Address").show();
|
||||
$(".address_edit").show();
|
||||
$(".address_edit_cancel").hide();
|
||||
$('.spinner-border').removeClass('d-none')
|
||||
$('.saveaddress').find('span').addClass('d-none')
|
||||
await AddresssaveForm();
|
||||
$('.spinner-border').addClass('d-none')
|
||||
$('.saveaddress').find('span').removeClass('d-none')
|
||||
await getbillinginfoBind();
|
||||
}
|
||||
|
||||
await AddresssaveForm();
|
||||
$('.spinner-border').addClass('d-none')
|
||||
$('.saveaddress').find('span').removeClass('d-none')
|
||||
await getbillinginfoBind();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function onChangeState(e){
|
||||
let userItem = e.target.value.toLowerCase();
|
||||
let limit = 10;
|
||||
let results = [];
|
||||
let maxLen = stateArr.length > 10 ? 10 :stateArr.length;
|
||||
debugger
|
||||
for(let i=0;i<stateArr.length;i++){
|
||||
let currItem = stateArr[i];
|
||||
let stateName = currItem.cityname.toLowerCase();
|
||||
if(stateName.includes(userItem)){
|
||||
results.push(currItem);
|
||||
if(results.length>=10) break;
|
||||
}
|
||||
}
|
||||
$('.stateBox').removeClass('d-none');
|
||||
renderCustomStateDropdown(results);
|
||||
loadDropdownStateEvents();
|
||||
|
||||
|
||||
}
|
||||
|
||||
async function getCountryStateCurrency() {
|
||||
|
||||
const countryRes = await API_SERVICES_ACTIONS.getAPIService(
|
||||
"apis/v4/bizgaze/integrations/anwiauth/getcountry"
|
||||
);
|
||||
@@ -169,22 +251,9 @@ async function addressDetails() {
|
||||
let stateData = JSON.parse(stateRes.response.result);
|
||||
|
||||
console.log(stateData, "state");
|
||||
|
||||
$("#state").html("");
|
||||
console.log("start");
|
||||
let html = "";
|
||||
statesList = stateData;
|
||||
for (let i = 0; i < stateData.length; i++) {
|
||||
html += `<option value="${stateData[i].cityid}" data-id="${stateData[i].cityid}">${stateData[i].cityname}</option>`;
|
||||
}
|
||||
|
||||
$("#state").append(html);
|
||||
|
||||
$("#state").select2({
|
||||
placeholder: "Select a City",
|
||||
allowClear: true,
|
||||
});
|
||||
|
||||
stateArr = stateData;
|
||||
renderCustomStateDropdown(stateArr);
|
||||
loadDropdownStateEvents();
|
||||
const currencyRes = await API_SERVICES_ACTIONS.getAPIService(
|
||||
"apis/v4/bizgaze/integrations/anwiauth/getcurrencies"
|
||||
);
|
||||
@@ -285,14 +354,15 @@ async function addressDetails() {
|
||||
let resAnwi = JSON.parse(response.result);
|
||||
console.log(resAnwi, "befores");
|
||||
resAnwi = resAnwi[resAnwi.length - 1];
|
||||
let stateId = parseInt($("#state").val());
|
||||
let stateId = parseInt($("#state").data('id'));
|
||||
let payload = {
|
||||
...resAnwi,
|
||||
phonenumber: $("#phonenumber").val(),
|
||||
addressline1: $("#addressdes").val(),
|
||||
zipcode: $("#zipcode").val(),
|
||||
cityid: stateId,
|
||||
CityName: $(`[data-id="${stateId}"`).html(),
|
||||
CityName: $('#state').val(),
|
||||
cityname: $('#state').val(),
|
||||
};
|
||||
console.log(payload, "addresssaave");
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user