No Description
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.

Profile.js 7.1KB

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