Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. function myProfile() {
  2. debugger
  3. getbillinginfoBind()
  4. async function getbillinginfoBind(){
  5. let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
  6. console.log(cookieRes);
  7. const { errorMsg, isError, response } = await API_SERVICES_ACTIONS.getAPIService(
  8. `apis/v4/bizgaze/integrations/anwiauth/getbillinginfo/contactid/${cookieRes.userId}`
  9. );
  10. let res = JSON.parse(response.result);
  11. debugger;
  12. console.log(res);
  13. res = res[res.length - 1];
  14. $('#Profile_User_name').val(res?.organizationname)
  15. $('#Profile_Phone_num').val(res?.phonenumber)
  16. let Profileusername =$('#Profile_User_name').val()
  17. let Profileuserphone=$('#Profile_Phone_num').val()
  18. $('.overview_user_name').html(Profileusername);
  19. $('.overview_user_phone').html(Profileuserphone);
  20. $(".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>`
  21. );
  22. }
  23. let countryId = null;
  24. $(".profile_edit").on("click", function () {
  25. $(this).hide();
  26. // $('.profile_save_btn,.profile_edit_cancel').removeClass('d-none')
  27. $(".profile_save_btn,.profile_edit_cancel,.profile_info_label").show();
  28. $(".profile_info").removeAttr("disabled").removeClass("cursor-notvalid");
  29. });
  30. $(".profile_edit_cancel").on("click", function () {
  31. $(this).hide();
  32. $(".profile_save_btn,.profile_info_label").hide();
  33. $('#Profile_User_name').val('');
  34. $('#Profile_Phone_num').val('');
  35. getbillinginfoBind();
  36. $(".profile_edit").show();
  37. $(".profile_info").attr("disabled", "disabled").addClass("cursor-notvalid");
  38. });
  39. $(".pass_edit").on("click", function () {
  40. $(this).hide();
  41. $(".update_profile_pass,.pass_edit_cancel").show();
  42. $(".profile_info_pass")
  43. .removeAttr("disabled")
  44. .removeClass("cursor-notvalid");
  45. });
  46. $(".pass_edit_cancel").on("click", function () {
  47. $('#Profile_User_current_pass').val('');
  48. $('#Profile_User_confirm_pass').val('');
  49. $('#Profile_User_new_pass').val('');
  50. $('#Profile_User_current_pass,#Profile_User_new_pass,#Profile_User_confirm_pass').removeClass('is-invalid')
  51. // $('#Profile_User_new_pass').val().removeClass('is-invalid')
  52. // $('#Profile_User_confirm_pass').val().removeClass('is-invalid')
  53. $(this).hide();
  54. $(".update_profile_pass").hide();
  55. $(".pass_edit").show();
  56. $(".profile_info_pass")
  57. .attr("disabled", "disabled")
  58. .addClass("cursor-notvalid");
  59. });
  60. $(".update_profile_pass").on("click", async function () {
  61. let userEmail = window.localStorage.getItem("Useremail");
  62. console.log(userEmail);
  63. let port = SERVERNAME;
  64. // let port = "http://localhost:3088";
  65. let url = `${port}/account/getuserbyphoneormail/${userEmail}/${userEmail}`;
  66. const config = {
  67. url,
  68. method: "get",
  69. };
  70. debugger;
  71. let response = await axios(config);
  72. let usernameId = response.data.result.userName;
  73. let UserNewpassword = $("#Profile_User_new_pass");
  74. let usercurrentPass = $("#Profile_User_current_pass");
  75. let userConfirmpass = $("#Profile_User_confirm_pass");
  76. if (usercurrentPass.val() != "") {
  77. $(usercurrentPass).removeClass("is-invalid");
  78. if (UserNewpassword.val() && userConfirmpass.val() != "") {
  79. if (UserNewpassword.val() == userConfirmpass.val()) {
  80. console.log(usernameId);
  81. const UpdatePassPayload = {
  82. username: usernameId,
  83. password: UserNewpassword.val(),
  84. oldpassword: usercurrentPass.val(),
  85. };
  86. const update_passres = await postAPIService(
  87. `hyperfusion/HypersfusionUpdatePassword`,
  88. UpdatePassPayload
  89. );
  90. console.log(update_passres);
  91. if (update_passres.data.errors != null) {
  92. $(".profilepass_feedbackres")
  93. .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>
  94. <span class="error_msg_res">${update_passres.data.message}</a></span>
  95. </div>`);
  96. $(userConfirmpass).addClass("is-invalid");
  97. $(UserNewpassword).removeClass("is-invalid");
  98. $(userConfirmpass).removeClass("is-invalid");
  99. } else {
  100. $(".profilepass_feedbackres")
  101. .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">
  102. <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"/>
  103. </svg>
  104. <span class="success_msg_res">${update_passres.data.message}</a></span>
  105. </div>`);
  106. usercurrentPass.val("");
  107. UserNewpassword.val("");
  108. userConfirmpass.val("");
  109. }
  110. } else {
  111. $(UserNewpassword).addClass("is-invalid");
  112. $(userConfirmpass).addClass("is-invalid");
  113. return;
  114. }
  115. } else {
  116. $(UserNewpassword).addClass("is-invalid");
  117. $(userConfirmpass).addClass("is-invalid");
  118. return;
  119. }
  120. } else {
  121. $(usercurrentPass).addClass("is-invalid");
  122. return;
  123. }
  124. });
  125. $('.profile_save_btn').on('click',async function(){
  126. await ProfilesaveForm();
  127. $('.profile_edit_cancel').trigger('click')
  128. })
  129. async function ProfilesaveForm() {
  130. debugger
  131. let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
  132. let { userId, name } = cookieRes;
  133. const { errorMsg, isError, response } =
  134. await API_SERVICES_ACTIONS.getAPIService(
  135. `apis/v4/bizgaze/integrations/anwiauth/getbillinginfo/contactid/${cookieRes.userId}`
  136. );
  137. let resAnwi = JSON.parse(response.result);
  138. console.log(resAnwi, "previous profilesave");
  139. resAnwi = resAnwi[resAnwi.length - 1];
  140. let payload = {
  141. ...resAnwi,
  142. organizationname: $("#Profile_User_name").val(),
  143. phonenumber: $("#Profile_Phone_num").val(),
  144. };
  145. console.log(payload, "profilesave");
  146. //
  147. const res = await API_SERVICES_ACTIONS.postAPIService(
  148. "apis/v4/bizgaze/crm/address/savebillinginfo",
  149. payload
  150. );
  151. return new Promise((reslove, reject) => {
  152. reslove(res);
  153. getbillinginfoBind();
  154. });
  155. }
  156. }