Changes in my account and order details..

This commit is contained in:
2023-04-27 11:20:16 +05:30
parent 6e1b99ea3a
commit 8938f48ee4
11 changed files with 1084 additions and 323 deletions
+14 -4
View File
@@ -1,5 +1,5 @@
//let SERVERNAME = 'https://anwi.bizgaze.app';
let SERVERNAME = 'https://beta.bizgaze.app';
let SERVERNAME = 'http://beta.bizgaze.com';
const STAT = 'b276960fddf84e8cb63de6e32d31529b';
@@ -23,6 +23,16 @@ async function getStatAPIService(url,data={}){
return response;
}
async function getStatAPIService(url,data={}){
const config = {
url,
method: "get",
};
let response = await axios(config);
return response;
}
async function postStatAPIService(url,data={}){
let config = {
url,
@@ -45,7 +55,7 @@ async function postAPIService(url,data={}){
method:'post',
data:data,
headers: {
'Authorization': `Basic fffe5440-5be6-4c07-876f-113c13de7382`,
'Authorization': `Basic b67607dd-283e-478e-b2cf-35736e8bad69`,
'Content-Type': 'application/json'
},
}
@@ -61,7 +71,7 @@ async function postAPIServiceLocal(url,data={}){
method:'post',
data:JSON.stringify(data ),
headers: {
'Authorization': `Basic fffe5440-5be6-4c07-876f-113c13de7382`,
'Authorization': `Basic b67607dd-283e-478e-b2cf-35736e8bad69`,
'Content-Type': 'application/json'
},
}
@@ -75,7 +85,7 @@ async function getAPIServiceLocal(url){
method:'get',
headers: {
'Authorization': `Basic fffe5440-5be6-4c07-876f-113c13de7382`,
'Authorization': `Basic b67607dd-283e-478e-b2cf-35736e8bad69`,
'Content-Type': 'application/json'
},
}
+303
View File
@@ -0,0 +1,303 @@
async function addressDetails() {
debugger;
getbillinginfoBind();
let addr_phone=$('#phonenumber');
let addr_addrline =$('#addressdes');
let addr_zip =$('#zipcode');
function getbillinginfoBind() {
return new Promise(async (resolve, reject) => {
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
console.log(cookieRes);
const { errorMsg, isError, response } =
await API_SERVICES_ACTIONS.getAPIService(
`apis/v4/bizgaze/integrations/products/getbillinginfo/contactid/${cookieRes.userId}`
);
let res = JSON.parse(response.result);
debugger;
console.log(res);
res = res[res.length - 1];
debugger
$('#Profile_User_name').val(res.organizationname)
$('#Profile_Phone_num').val(res.phonenumber)
let Profileusername =$('#Profile_User_name').val()
let Profileuserphone=$('#Profile_Phone_num').val()
$('.overview_user_name').html(Profileusername);
$('.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_phone.val() == "" || 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>`
);
}
resolve();
});
} debugger
$(".address_edit").on("click", function () {
$(this).hide();
$(".profile_Address").hide();
$(".addresslist").show();
$(".address_edit_cancel").show();
getCountryStateCurrency();
});
$(".address_edit_cancel").on("click", function () {
$(this).hide();
$(".addresslist").hide();
$(".profile_Address").show();
$(".address_edit").show();
});
$(".saveaddress")
.off("click")
.click(async function () {
debugger
if(addr_phone.val() == "" || 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();
$('.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();
}
});
async function getCountryStateCurrency() {
const countryRes = await API_SERVICES_ACTIONS.getAPIService(
"apis/v4/bizgaze/integrations/products/getcountry"
);
if (countryRes.isError) {
alert("something went wrong");
console.log(countryRes);
return;
}
let countryData = JSON.parse(countryRes.response.result);
console.log(countryData, "country");
for (let i = 0; i < countryData.length; i++) {
if (countryData[i].countryname.toLowerCase() === "india") {
countryID = countryData[i].countryid;
countrynameData = countryData[i].countryname;
break;
}
}
const stateRes = await API_SERVICES_ACTIONS.getAPIService(
`apis/v4/bizgaze/integrations/products/getcities/countryid/${countryID}`
);
if (stateRes.isError) {
alert("something went wrong");
console.log(stateRes, "state");
return;
}
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,
});
const currencyRes = await API_SERVICES_ACTIONS.getAPIService(
"apis/v4/bizgaze/integrations/products/getcurrencies"
);
if (currencyRes.isError) {
alert("something went wrong");
console.log(currencyRes);
return;
}
let currencyData = JSON.parse(currencyRes.response.result);
console.log(currencyData, "currencyDatacurrencyDatacurrencyData");
for (let i = 0; i < currencyData.length; i++) {
const curr = currencyData[i];
if (curr.currencyname.toLowerCase().includes("india")) {
currencyid = curr.currencyid;
}
}
}
async function getCountryId() {
const countryRes = await API_SERVICES_ACTIONS.getAPIService(
"apis/v4/bizgaze/integrations/products/getcountry"
);
if (countryRes.isError) {
alert("something went wrong");
console.log(countryRes);
return;
}
let ctyId = 0;
let countryData = JSON.parse(countryRes.response.result);
console.log(countryData);
for (let i = 0; i < countryData.length; i++) {
if (countryData[i].countryname.toLowerCase() === "india") {
countryId = countryData[i].countryid;
ctyId = countryId;
countrynameData = countryData[i].countryname;
break;
}
}
return ctyId;
}
function createBillingForm() {
debugger;
return new Promise(async (resolve, reject) => {
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
let { userId, name } = cookieRes;
const ctyId = await getCountryId();
let stateId = parseInt($("#state").val());
let payload = {
cityid: stateId,
CityName: $(`[data-id="${stateId}"`).html(),
addressline1: $("#addressdes").val(),
OrganizationType: 2,
organizationname: name,
//"OrganizationId":,
ContactName: name,
ContactId: userId,
countryname: "india",
countryid: ctyId,
statename: $(`[data-id="${stateId}"`).html(),
phonenumber: $("#phonenumber").val(),
OrganizationId: userId,
currencyid: 2,
taxno: "0",
BillingInfoExists: false,
lobid: 0,
lobname: "IT Products",
gstindetailid: 0,
zipcode: $("#zipcode").val(),
};
const res = await API_SERVICES_ACTIONS.postAPIService(
"apis/v4/bizgaze/crm/address/savebillinginfo",
payload
);
// http://localhost:3088/apis/v4/bizgaze/crm/address/savebillinginfo
console.log(res);
resolve();
});
}
async function AddresssaveForm() {
debugger;
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
let { userId, name } = cookieRes;
const { errorMsg, isError, response } =
await API_SERVICES_ACTIONS.getAPIService(
`apis/v4/bizgaze/integrations/products/getbillinginfo/contactid/${cookieRes.userId}`
);
let resAnwi = JSON.parse(response.result);
console.log(resAnwi, "befores");
resAnwi = resAnwi[resAnwi.length - 1];
let stateId = parseInt($("#state").val());
let payload = {
...resAnwi,
phonenumber: $("#phonenumber").val(),
addressline1: $("#addressdes").val(),
zipcode: $("#zipcode").val(),
cityid: stateId,
CityName: $(`[data-id="${stateId}"`).html(),
};
console.log(payload, "addresssaave");
//
const res = await API_SERVICES_ACTIONS.postAPIService(
"apis/v4/bizgaze/crm/address/savebillinginfo",
payload
);
return new Promise((reslove, reject) => {
reslove(res);
});
}
}
+2
View File
@@ -1,7 +1,9 @@
function initmyaccount(){
$('.my_account_page').removeClass('d-none')
myProfile();
bindOrderDetails();
wattantyFunction();
addressDetails()
}
checkValidAuth(initmyaccount,'./login.html')
+158
View File
@@ -0,0 +1,158 @@
function myProfile() {
debugger
getbillinginfoBind()
async function getbillinginfoBind(){
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
console.log(cookieRes);
const { errorMsg, isError, response } = await API_SERVICES_ACTIONS.getAPIService(
`apis/v4/bizgaze/integrations/products/getbillinginfo/contactid/${cookieRes.userId}`
);
let res = JSON.parse(response.result);
debugger;
console.log(res);
res = res[res.length - 1];
$('#Profile_User_name').val(res.organizationname)
$('#Profile_Phone_num').val(res.phonenumber)
let Profileusername =$('#Profile_User_name').val()
let Profileuserphone=$('#Profile_Phone_num').val()
$('.overview_user_name').html(Profileusername);
$('.overview_user_phone').html(Profileuserphone);
$(".profile_Address").html(`<div class=User_address><address><p><strong>${res.organizationname}</strong><p>${res.addressline},${res.cityname}<br>${res.statename},${res.zipcode}<p>Mobile: ${res.phonenumber}</address></div>`
);
}
let countryId = null;
$(".profile_edit").on("click", function () {
$(this).hide();
// $('.profile_save_btn,.profile_edit_cancel').removeClass('d-none')
$(".profile_save_btn,.profile_edit_cancel,.profile_info_label").show();
$(".profile_info").removeAttr("disabled").removeClass("cursor-notvalid");
});
$(".profile_edit_cancel").on("click", function () {
$(this).hide();
$(".profile_save_btn,.profile_info_label").hide();
$('#Profile_User_name').val('');
$('#Profile_Phone_num').val('');
getbillinginfoBind();
$(".profile_edit").show();
$(".profile_info").attr("disabled", "disabled").addClass("cursor-notvalid");
});
$(".pass_edit").on("click", function () {
$(this).hide();
$(".update_profile_pass,.pass_edit_cancel").show();
$(".profile_info_pass")
.removeAttr("disabled")
.removeClass("cursor-notvalid");
});
$(".pass_edit_cancel").on("click", function () {
$('#Profile_User_current_pass').val('');
$('#Profile_User_confirm_pass').val('');
$('#Profile_User_new_pass').val('');
$('#Profile_User_current_pass,#Profile_User_new_pass,#Profile_User_confirm_pass').removeClass('is-invalid')
// $('#Profile_User_new_pass').val().removeClass('is-invalid')
// $('#Profile_User_confirm_pass').val().removeClass('is-invalid')
$(this).hide();
$(".update_profile_pass").hide();
$(".pass_edit").show();
$(".profile_info_pass")
.attr("disabled", "disabled")
.addClass("cursor-notvalid");
});
$(".update_profile_pass").on("click", async function () {
let userEmail = window.localStorage.getItem("Useremail");
console.log(userEmail);
let port = "http://beta.bizgaze.com";
// let port = "http://localhost:3088";
let url = `${port}/account/getuserbyphoneormail/${userEmail}/${userEmail}`;
const config = {
url,
method: "get",
};
debugger;
let response = await axios(config);
let usernameId = response.data.result.userName;
let UserNewpassword = $("#Profile_User_new_pass");
let usercurrentPass = $("#Profile_User_current_pass");
let userConfirmpass = $("#Profile_User_confirm_pass");
if (usercurrentPass.val() != "") {
$(usercurrentPass).removeClass("is-invalid");
if (UserNewpassword.val() && userConfirmpass.val() != "") {
if (UserNewpassword.val() == userConfirmpass.val()) {
console.log(usernameId);
const UpdatePassPayload = {
username: usernameId,
password: UserNewpassword.val(),
oldpassword: usercurrentPass.val(),
};
const update_passres = await postAPIService(
`hyperfusion/HypersfusionUpdatePassword`,
UpdatePassPayload
);
console.log(update_passres);
if (update_passres.data.errors != null) {
$(".profilepass_feedbackres")
.html(`<div class="alert alert-danger error_msg " role="alert" style="font-size: 12px;"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.2646 3.41366C11.7212 3.15681 12.2788 3.15681 12.7354 3.41366L19.2354 7.06991C19.7077 7.33558 20 7.83536 20 8.37727V15.6227C20 16.1646 19.7077 16.6644 19.2354 16.9301L12.7354 20.5863C12.2788 20.8432 11.7212 20.8432 11.2646 20.5863L4.76461 16.9301C4.29229 16.6644 4 16.1646 4 15.6227V8.37727C4 7.83536 4.29229 7.33559 4.76461 7.06991L11.2646 3.41366Z" fill="#FF3A2E"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M11 7.4C11 7.17909 11.1791 7 11.4 7H12.6C12.8209 7 13 7.17909 13 7.4V12.6C13 12.8209 12.8209 13 12.6 13H11.4C11.1791 13 11 12.8209 11 12.6V7.4Z" fill="white"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M11 16C11 15.4477 11.4477 15 12 15C12.5523 15 13 15.4477 13 16C13 16.5523 12.5523 17 12 17C11.4477 17 11 16.5523 11 16Z" fill="white"></path></svg>
<span class="error_msg_res">${update_passres.data.message}</a></span>
</div>`);
$(userConfirmpass).addClass("is-invalid");
$(UserNewpassword).removeClass("is-invalid");
$(userConfirmpass).removeClass("is-invalid");
} else {
$(".profilepass_feedbackres")
.html(`<div class="alert alert-success success_msg" role="alert" style="font-size: 12px;"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check" viewBox="0 0 16 16">
<path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z"/>
</svg>
<span class="success_msg_res">${update_passres.data.message}</a></span>
</div>`);
usercurrentPass.val("");
UserNewpassword.val("");
userConfirmpass.val("");
}
} else {
$(UserNewpassword).addClass("is-invalid");
$(userConfirmpass).addClass("is-invalid");
return;
}
} else {
$(UserNewpassword).addClass("is-invalid");
$(userConfirmpass).addClass("is-invalid");
return;
}
} else {
$(usercurrentPass).addClass("is-invalid");
return;
}
});
$('.profile_save_btn').on('click',async function(){
await ProfilesaveForm();
$('.profile_edit_cancel').trigger('click')
})
async function ProfilesaveForm() {
debugger
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
let { userId, name } = cookieRes;
const { errorMsg, isError, response } =
await API_SERVICES_ACTIONS.getAPIService(
`apis/v4/bizgaze/integrations/products/getbillinginfo/contactid/${cookieRes.userId}`
);
let resAnwi = JSON.parse(response.result);
console.log(resAnwi, "previous profilesave");
resAnwi = resAnwi[resAnwi.length - 1];
let payload = {
...resAnwi,
organizationname: $("#Profile_User_name").val(),
phonenumber: $("#Profile_Phone_num").val(),
};
console.log(payload, "profilesave");
//
const res = await API_SERVICES_ACTIONS.postAPIService(
"apis/v4/bizgaze/crm/address/savebillinginfo",
payload
);
return new Promise((reslove, reject) => {
reslove(res);
getbillinginfoBind();
});
}
}
+11 -2
View File
@@ -1,9 +1,14 @@
async function bindOrderDetails() {
let user_number =$('.User_phoneum').text();
// validatesession()
let port = SERVERNAME;
debugger
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
let { userId} = cookieRes;
// let userId = '106631380000095';
let port = "https://anwi.bizgaze.app";
// let port = "http://localhost:3088";
let url = `${port}/apis/v4/bizgaze/integrations/products/salesorderdetailsbyphonenumber/phonenumber/${user_number}`;
let url = `${port}/apis/v4/Bizgaze/integrations/products/salesorderdetailsbyorgid/organizationid/${userId}`;
// https://anwi.bizgaze.app/apis/v4/Bizgaze/integrations/products/salesorderdetailsbyorgid/organizationid/{organizationid}
const config = {
url,
method: "get",
@@ -14,6 +19,10 @@ let port = SERVERNAME;
};
debugger
let res = await axios(config);
if(res.data.result == '[]'){
$(".user_order_details").append(`<div><h6 class="text-center">No orders Found</h6></div>`);
return;
}
const orderDetailsres = JSON.parse(res.data.result);
console.log(orderDetailsres);
let new_arrr = orderDetailsres;
+7 -3
View File
@@ -1,9 +1,13 @@
async function order_summary(){
let current_orderSerialDate =window.localStorage.getItem('orderSerialno');
let user_number =window.localStorage.getItem('Userphonenumber');
let port = SERVERNAME;
// let user_number =window.localStorage.getItem('Userphonenumber');
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
let { userId} = cookieRes;
// let userId = '106631380000095';
let port = "https://anwi.bizgaze.app";
// let port = "http://localhost:3088";
let url = `${port}/apis/v4/bizgaze/integrations/products/salesorderdetailsbyphonenumber/phonenumber/${user_number}`;
// let url = `${port}/apis/v4/bizgaze/integrations/products/salesorderdetailsbyphonenumber/phonenumber/${user_number}`;
let url = `${port}/apis/v4/Bizgaze/integrations/products/salesorderdetailsbyorgid/organizationid/${userId}`;
const config = {
url,
method: "get",
+3 -3
View File
@@ -1,5 +1,5 @@
function wattantyFunction() {
let order_card = `<div class=warranty_product><div class="py-3 warranty_productform"><div class=mb-3><label class=form-label for=Add_serial_number_inp>Enter Your Serial Number</label><input class=form-control id=Add_serial_number_inp required><label class="form-label text-danger d-none error_serial_num" for=Add_serial_number_inp >Serial Number should not be empty</label></div><div class=mb-3><label class="form-label d-none Add_phonenumber_inp_label" for=Add_phonenumber_inp>Enter Your Phone Number</label> <input class="form-control d-none "id=Add_phonenumber_inp required><label class="text-danger d-none form-label error_phonenumber" for=Add_phonenumber_inp>Enter Valid Phone Number</label></div><div class=mb-3><label class="form-label d-none Add_Contact_inp_label" for=Add_contactname_inp>Enter Your Contactname</label> <input class="form-control d-none" id=Add_contactname_inp required></div><div class="serial_submit text-end"><button class="btn btn-dark warranty_serialNumber_check" type="button">Submit</button><button class="btn btn-dark warranty_serialNumber_submit d-none" type="button">Submit</button></div></div></div>`;
let order_card = `<div class=warranty_product><div class="py-3 warranty_productform"><div class=mb-3><label class=form-label for=Add_serial_number_inp>Enter Your Serial Number</label><input class=form-control id=Add_serial_number_inp required><label class="form-label text-danger d-none error_serial_num" for=Add_serial_number_inp >Serial Number should not be empty</label></div><div class=mb-3><label class="form-label d-none Add_phonenumber_inp_label" for=Add_phonenumber_inp>Enter Your Phone Number</label> <input type="number" inputmode="tel" class="form-control d-none" pattern="[1-9]{1}[0-9]{9}^[0-9]*$" onKeyPress="if(this.value.length==10) return false;"maxlength="10" id=Add_phonenumber_inp required><label class="text-danger d-none form-label error_phonenumber" for=Add_phonenumber_inp>Enter Valid Phone Number</label></div><div class=mb-3><label class="form-label d-none Add_Contact_inp_label" for=Add_contactname_inp>Enter Your Contactname</label> <input class="form-control d-none" id=Add_contactname_inp required></div><div class="serial_submit text-end"><button class="btn btn-dark warranty_serialNumber_check" type="button">Submit</button><button class="btn btn-dark warranty_serialNumber_submit d-none" type="button">Submit</button></div></div></div>`;
$(".user_orders").append(order_card);
$(".add_serialNum").click(function () {
$(".warranty_productform").removeClass("d-none");
@@ -15,7 +15,7 @@ function wattantyFunction() {
$(".error_phonenumber").addClass("d-none");
$("#Add_serial_number_inp").removeClass("border-danger");
$("#Add_phonenumber_inp").removeClass("border-danger");
let port = SERVERNAME
let port = "https://anwi.bizgaze.app";
debugger;
let url = `${port}/apis/v4/Bizgaze/integrations/products/warrantyservice/serialno/${serial_no_inp}`;
console.log(url);
@@ -80,7 +80,7 @@ function wattantyFunction() {
if (serial_no_inp != "") {
$(".error_serial_num").addClass("d-none");
$("#Add_serial_number_inp").removeClass("border-danger");
let port = SERVERNAME
let port = "https://anwi.bizgaze.app";
debugger;
let url = `${port}/apis/v4/Bizgaze/integrations/products/warrantyservice/serialno/${serial_no_inp}`;
console.log(url);