123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- 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/anwiauth/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 = SERVERNAME;
- // 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/anwiauth/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();
- });
- }
- }
|