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.

248 lines
7.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <modal name="edit-contact-modal" width="100%" :clickToClose="false">
  3. <div class="tw-p-[30px] md:tw-p-0 tw-h-full tw-overflow-auto">
  4. <div
  5. class="modal-header tw-flex tw-justify-start tw-items-center tw-mb-[20px] md:tw-mb-[50px] xl:tw-justify-between">
  6. <div class="tw-text-[18px] tw-font-bold tw-leading-[26px] md:tw-text-[20px]">
  7. {{ $t("userProfile.editContactInfo") }}
  8. </div>
  9. <button class="close tw-transition tw-btn-md" @click="$modal.hide('edit-contact-modal')"></button>
  10. </div>
  11. <div
  12. class="modal-content tw-grid tw-grid-cols-1 tw-gap-y-[20px] tw-mb-[30px] md:tw-grid-cols-2 md:tw-gap-x-[64px] md:tw-mb-[60px]">
  13. <div class="element">
  14. <elementInput :input="{
  15. id: 'FirstName',
  16. label: 'userProfile.firstName',
  17. required: true,
  18. type: 'text',
  19. }" :default="formData.FirstName" :validation="validation.FirstName" @change="formData.FirstName = $event">
  20. </elementInput>
  21. </div>
  22. <div class="element">
  23. <elementInput :input="{
  24. id: 'LastName',
  25. label: 'userProfile.lastName',
  26. required: true,
  27. type: 'text',
  28. }" :default="formData.LastName" :validation="validation.LastName" @change="formData.LastName = $event">
  29. </elementInput>
  30. </div>
  31. <div class="element">
  32. <elementInput :input="{
  33. id: 'Email',
  34. label: 'Email',
  35. required: true,
  36. type: 'email',
  37. }" :default="formData.Email" :validation="validation.Email" @change="formData.Email = $event">
  38. </elementInput>
  39. </div>
  40. <div class="element">
  41. <label class="tw-block tw-mb-[10px]"><span>{{ $t("Phone") }}<span class="required">*</span></span></label>
  42. <div class="tw-grid tw-grid-cols-[120px_auto]">
  43. <elementCountryCodeSelect :userCodeSelect="this.formData.PhoneCountryCode" :validation="validation.codeSelect" @returnCode = "getReturnCode"></elementCountryCodeSelect>
  44. <vue-phone-number-input
  45. color="#e5e5e5"
  46. :border-radius="5"
  47. error-color="#ef5a5a"
  48. valid-color="#e5e5e5"
  49. :error="error"
  50. required
  51. no-flags
  52. no-example
  53. :no-country-selector="true"
  54. :validation="validation.PhoneNo"
  55. v-model="formData.PhoneNo"
  56. ></vue-phone-number-input>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="modal-footer md:tw-flex md:tw-justify-start md:tw-items-center md:tw-flex-row-reverse">
  61. <button
  62. class="tw-transition tw-text-[18px] tw-btn-md tw-bg-primary-1 tw-w-full tw-mb-[10px] md:tw-mb-0 md:tw-w-fit md:tw-px-[30px] tw-py-[9.5px] tw-rounded-2xl hover:tw-bg-primary-2"
  63. @click="save">
  64. {{ $t("userProfile.save") }}
  65. </button>
  66. <button
  67. class="tw-transition tw-text-[18px] tw-btn-md tw-text-primary-1 tw-w-full md:tw-w-fit md:tw-px-[30px] tw-py-[9.5px] tw-mr-[10px] tw-rounded-2xl"
  68. @click="reset">
  69. {{ $t("Clear") }}
  70. </button>
  71. </div>
  72. </div>
  73. </modal>
  74. </template>
  75. <script>
  76. import elementInput from "@/components/newComponent/form/ElementInput";
  77. import elementCountryCodeSelect from "@/components/newComponent/form/ElementCountryCodeSelect.vue";
  78. import Swal from "sweetalert2";
  79. import is from "is_js";
  80. export default {
  81. name: "EditContactModal",
  82. components: {
  83. elementInput,
  84. elementCountryCodeSelect
  85. },
  86. props: {
  87. contact: {
  88. type: Object,
  89. },
  90. },
  91. data() {
  92. return {
  93. formData: {},
  94. isValid: false,
  95. countryCode: "",
  96. phoneValid: false,
  97. validation: {
  98. FirstName: true,
  99. LastName: true,
  100. Email: true,
  101. PhoneNo: true,
  102. codeSelect: true,
  103. },
  104. errors: null,
  105. error: false,
  106. countryCode: "",
  107. };
  108. },
  109. mounted() { },
  110. watch: {
  111. contact: {
  112. handler: function () {
  113. this.formData = JSON.parse(JSON.stringify(this.contact));
  114. },
  115. },
  116. },
  117. methods: {
  118. reset() {
  119. this.formData = {
  120. FirstName: "",
  121. LastName: "",
  122. Email: "",
  123. PhoneNo: "",
  124. PhoneCountryCode: "999",
  125. };
  126. // (this.isValid = false),
  127. // (this.PhoneCountryCode = ""),
  128. // (this.phoneValid = false);
  129. },
  130. getReturnCode(code){
  131. this.formData.PhoneCountryCode = code;
  132. },
  133. getPhoneData(phoneData) {
  134. this.formData.PhoneCountryCode = phoneData.countryCode;
  135. },
  136. showCode(object) {
  137. this.formData.PhoneCountryCode = object.dialCode;
  138. },
  139. validators() {
  140. if (is.empty(this.formData.FirstName)) {
  141. this.validation.FirstName = false;
  142. } else {
  143. this.validation.FirstName = true;
  144. }
  145. if (is.empty(this.formData.LastName)) {
  146. this.validation.LastName = false;
  147. } else {
  148. this.validation.LastName = true;
  149. }
  150. if (is.empty(this.formData.Email) || is.not.email(this.formData.Email)) {
  151. this.validation.Email = false;
  152. } else {
  153. this.validation.Email = true;
  154. }
  155. if (is.empty(this.formData.PhoneNo)
  156. ) {
  157. this.validation.PhoneNo = false;
  158. this.error = true;
  159. } else {
  160. this.validation.PhoneNo = true;
  161. this.error = false;
  162. }
  163. if(this.formData.PhoneCountryCode == "999"){
  164. this.validation.codeSelect = false;
  165. }else{
  166. this.validation.codeSelect = true;
  167. }
  168. this.errors = Object.entries(this.validation).filter(
  169. (e) => e[1] == false
  170. );
  171. if (this.errors.length > 0) {
  172. return false;
  173. } else {
  174. return true;
  175. }
  176. },
  177. save() {
  178. this.validators();
  179. if (this.validators()) {
  180. const patchData = JSON.parse(JSON.stringify(this.formData));
  181. this.$axios
  182. .post(
  183. `/trending/api/Members/Contact`, patchData
  184. )
  185. .then((response) => {
  186. //console.log(JSON.stringify(response));
  187. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  188. let data = response.data.DATA.rel
  189. if(data){
  190. this.$emit("update", true);
  191. this.$modal.hide("edit-contact-modal");
  192. }
  193. }
  194. })
  195. .catch((error) => {
  196. console.log(error);
  197. });
  198. }
  199. },
  200. },
  201. };
  202. </script>
  203. <style lang="scss" scoped>
  204. .close {
  205. position: absolute;
  206. right: 30px;
  207. top: 32px;
  208. background-image: url("~/assets/svg/close.svg");
  209. background-position: center;
  210. background-repeat: no-repeat;
  211. background-size: cover;
  212. width: 14px;
  213. height: 14px;
  214. @media screen and (min-width: 768px) {
  215. right: 40px;
  216. top: 40px;
  217. }
  218. }
  219. .v--modal-overlay::v-deep {
  220. .v--modal {
  221. width: 100% !important;
  222. height: 100vh !important;
  223. @media screen and (min-width: 768px) {
  224. padding: 40px;
  225. width: max-content;
  226. height: max-content !important;
  227. border-radius: 30px;
  228. }
  229. }
  230. .v--modal-box {
  231. height: 100vh !important;
  232. overflow: auto;
  233. @media screen and (min-width: 768px) {
  234. padding: 40px;
  235. width: max-content;
  236. height: max-content !important;
  237. }
  238. }
  239. }
  240. </style>