From 8938f48ee4d785373cab1f4306e9788f8eb4a504 Mon Sep 17 00:00:00 2001 From: ananthvijay Date: Thu, 27 Apr 2023 11:20:16 +0530 Subject: [PATCH] Changes in my account and order details.. --- dist/Js/auth/apiservice.js | 18 +- dist/Js/myaccount/Address.js | 303 +++++++++ dist/Js/myaccount/Myaccount.js | 2 + dist/Js/myaccount/Profile.js | 158 +++++ dist/Js/myaccount/orderdetails.js | 13 +- dist/Js/orderDetails/order_summary.js | 10 +- dist/Js/warranty.js | 6 +- dist/css/style.css | 47 +- myaccount.html | 842 ++++++++++++++++---------- orderdetails.html | 5 +- ramproducts.html | 3 +- 11 files changed, 1084 insertions(+), 323 deletions(-) create mode 100644 dist/Js/myaccount/Address.js create mode 100644 dist/Js/myaccount/Profile.js diff --git a/dist/Js/auth/apiservice.js b/dist/Js/auth/apiservice.js index bd08f3b..3fecafa 100644 --- a/dist/Js/auth/apiservice.js +++ b/dist/Js/auth/apiservice.js @@ -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' }, } diff --git a/dist/Js/myaccount/Address.js b/dist/Js/myaccount/Address.js new file mode 100644 index 0000000..db82641 --- /dev/null +++ b/dist/Js/myaccount/Address.js @@ -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( + `
` + ); + + $(".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( + `

${res.organizationname}

${res.addressline},${res.cityname}
${res.statename},${res.zipcode}

Mobile: ${res.phonenumber}

` + ); + } + 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 += ``; + } + + $("#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); + }); + } +} diff --git a/dist/Js/myaccount/Myaccount.js b/dist/Js/myaccount/Myaccount.js index 689a392..797668d 100644 --- a/dist/Js/myaccount/Myaccount.js +++ b/dist/Js/myaccount/Myaccount.js @@ -1,7 +1,9 @@ function initmyaccount(){ $('.my_account_page').removeClass('d-none') + myProfile(); bindOrderDetails(); wattantyFunction(); + addressDetails() } checkValidAuth(initmyaccount,'./login.html') \ No newline at end of file diff --git a/dist/Js/myaccount/Profile.js b/dist/Js/myaccount/Profile.js new file mode 100644 index 0000000..cf0134c --- /dev/null +++ b/dist/Js/myaccount/Profile.js @@ -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(`

${res.organizationname}

${res.addressline},${res.cityname}
${res.statename},${res.zipcode}

Mobile: ${res.phonenumber}

` + ); +} + 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(``); + $(userConfirmpass).addClass("is-invalid"); + $(UserNewpassword).removeClass("is-invalid"); + $(userConfirmpass).removeClass("is-invalid"); + } else { + $(".profilepass_feedbackres") + .html(``); + 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(); + }); + } +} diff --git a/dist/Js/myaccount/orderdetails.js b/dist/Js/myaccount/orderdetails.js index c75aa5f..78a1f00 100644 --- a/dist/Js/myaccount/orderdetails.js +++ b/dist/Js/myaccount/orderdetails.js @@ -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(`
No orders Found
`); + return; + } const orderDetailsres = JSON.parse(res.data.result); console.log(orderDetailsres); let new_arrr = orderDetailsres; diff --git a/dist/Js/orderDetails/order_summary.js b/dist/Js/orderDetails/order_summary.js index f887bca..d813af0 100644 --- a/dist/Js/orderDetails/order_summary.js +++ b/dist/Js/orderDetails/order_summary.js @@ -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", diff --git a/dist/Js/warranty.js b/dist/Js/warranty.js index d7258b0..c6e170f 100644 --- a/dist/Js/warranty.js +++ b/dist/Js/warranty.js @@ -1,5 +1,5 @@ function wattantyFunction() { - let order_card = `
`; + let order_card = `
`; $(".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); diff --git a/dist/css/style.css b/dist/css/style.css index b0e07fd..619409d 100644 --- a/dist/css/style.css +++ b/dist/css/style.css @@ -6444,11 +6444,13 @@ margin-bottom: 0.5rem !important; margin-top: -20px; } */ -.myaccount-content h3 { - font-size: 20px; +.myaccount-content .profile_head { border-bottom: 1px dashed #ccc; padding-bottom: 10px; margin-bottom: 25px; +} +.myaccount-content h3 { + font-size: 20px; font-weight: 600; } @@ -6506,7 +6508,24 @@ margin-bottom: 0.5rem !important; .myaccount-content .account-details-form .single-input-item input:focus { border-bottom: 1px solid #354060; } +.profile_info.cursor-notvalid , .profile_info_pass.cursor-notvalid{ + cursor: not-allowed; +} +.Theme_btn{ + border: none; + background: linear-gradient(145deg,rgb(27,45,83,0.9),rgb(10,19,34)) !important; + text-transform: uppercase; + font-weight: 600; + padding: 9px 25px; + color: #fff; + font-size: 13px; +} +.profile_head .edit_sec .check-btn:hover{ +color:#2843c7; +cursor: pointer; +transition:linear cubic-bezier(0.455, 0.03, 0.515, 0.955); +} .myaccount-content .account-details-form .single-input-item button { border: none; background-color: #0A1039; @@ -31717,4 +31736,28 @@ h4.checkout-title::before { to { transform: rotate(360deg); } +} +input[type=number]::-webkit-inner-spin-button, +input[type=number]::-webkit-outer-spin-button { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + margin: 0; +} +.select2-container--default{ + width: 100% !important; +} + +.select2-selection__clear span{ + display: none !important; +} + +.select2-selection__rendered { + line-height: 50px !important; +} +.select2-container .select2-selection--single { + height: 60px !important; +} +.select2-selection__arrow { + height: 50px !important; } \ No newline at end of file diff --git a/myaccount.html b/myaccount.html index 6f4b0f4..64a5563 100644 --- a/myaccount.html +++ b/myaccount.html @@ -12,6 +12,7 @@ + @@ -31,7 +32,7 @@ - +
@@ -41,89 +42,104 @@ -
-
@@ -414,7 +639,7 @@ - + @@ -423,51 +648,54 @@ + + + diff --git a/orderdetails.html b/orderdetails.html index 2bbedca..9c767aa 100644 --- a/orderdetails.html +++ b/orderdetails.html @@ -180,7 +180,9 @@ - + + + @@ -199,6 +201,7 @@ + diff --git a/ramproducts.html b/ramproducts.html index e660bb7..a77215f 100644 --- a/ramproducts.html +++ b/ramproducts.html @@ -60,7 +60,8 @@
- + +