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.

303 lines
8.9 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
2 years ago
  1. <template>
  2. <modal name="edit-company-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
  7. class="tw-flex tw-justify-between tw-w-full tw-text-[18px] tw-font-bold tw-leading-[26px] md:tw-text-[20px]">
  8. {{ $t("userProfile.editCompanyInfo") }}
  9. </div>
  10. <button class="close tw-transition tw-btn-md" @click="$modal.hide('edit-company-modal')"></button>
  11. </div>
  12. <div
  13. 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]">
  14. <div class="element">
  15. <elementInput :input="{
  16. id: 'CompanyName',
  17. label: 'userProfile.companyName',
  18. required: true,
  19. type: 'text',
  20. }" :default="userCompany.CompanyName" :validation="validation.CompanyName"
  21. @change="userCompany.CompanyName = $event"></elementInput>
  22. </div>
  23. <div class="element">
  24. <elementInput :input="{
  25. id: 'TaxNumber',
  26. label: 'userProfile.taxNumber',
  27. required: true,
  28. type: 'tel',
  29. }" :default="userCompany.TaxNumber" :validation="validation.TaxNumber"
  30. @change="userCompany.TaxNumber = $event"></elementInput>
  31. </div>
  32. <div class="element md:tw-col-span-2">
  33. <elementAddress :input="{
  34. id: 'StreetAddress',
  35. label: 'userProfile.companyAddress',
  36. required: true,
  37. type: 'street',
  38. }" :default1="userCompany.Street1" :default2="userCompany.Street2"
  39. :validation1="validation.Street1" :validation2="validation.Street2"
  40. @change1="userCompany.Street1 = $event" @change2="userCompany.Street2 = $event">
  41. </elementAddress>
  42. </div>
  43. <div class="element">
  44. <elementInput :input="{
  45. id: 'City',
  46. label: 'userProfile.companyCity',
  47. required: true,
  48. type: 'text',
  49. }" :default="userCompany.CityName" :validation="validation.CityName"
  50. @change="userCompany.CityName = $event"></elementInput>
  51. </div>
  52. <div class="element">
  53. <elementInput :input="{
  54. id: 'State',
  55. label: 'userProfile.stateAndProvince',
  56. required: false,
  57. type: 'text',
  58. }" :default="userCompany.StateName" :validation="validation.StateName"
  59. @change="userCompany.StateName = $event"></elementInput>
  60. </div>
  61. <!-- {{ userCompany.Country.CountryID }} -->
  62. <div class="element">
  63. <elementSelect :select="{
  64. id: 'Country',
  65. label: 'userProfile.companyCountry',
  66. required: true,
  67. }" :selectList="countryOptions" :default="userCompany.CountryID"
  68. :validation="validation.CountryID" @change="userCompany.CountryID = $event"></elementSelect>
  69. </div>
  70. <div class="element">
  71. <elementInput :input="{
  72. id: 'ZIP',
  73. label: 'userProfile.zipAndPostalCode',
  74. required: true,
  75. type: 'zip',
  76. }" :default="userCompany.ZipCode" :validation="validation.ZipCode"
  77. @change="userCompany.ZipCode = $event"></elementInput>
  78. </div>
  79. </div>
  80. <div class="md:tw-flex md:tw-flex-row-reverse">
  81. <button
  82. class="tw-text-[18px] tw-bg-primary-1 tw-text-white tw-w-full tw-py-[12px] tw-rounded-[16px] tw-mb-[10px] md:tw-w-fit md:tw-px-[24px] md:tw-mb-0 md:hover:tw-bg-primary-2"
  83. @click="save">
  84. {{ $t("userProfile.save") }}
  85. </button>
  86. <button
  87. class="tw-text-[18px] tw-bg-white tw-text-primary-1 tw-w-full tw-py-[12px] tw-rounded-[16px] md:tw-w-fit md:tw-px-[24px] md:tw-mr-[10px]"
  88. @click="reset">
  89. {{ $t("userProfile.clear") }}
  90. </button>
  91. </div>
  92. </div>
  93. </modal>
  94. </template>
  95. <script>
  96. import elementInput from "@/components/newComponent/form/ElementInput";
  97. import elementAddress from "@/components/newComponent/form/ElementAddress";
  98. import elementSelect from "@/components/newComponent/form/ElementSelect";
  99. import is from "is_js";
  100. import { ConsoleWriter } from "istanbul-lib-report";
  101. export default {
  102. name: "EditCompanytModal",
  103. components: {
  104. elementInput,
  105. elementAddress,
  106. elementSelect,
  107. is,
  108. },
  109. model: {
  110. event: "update:is-company-edit-dialog-active",
  111. },
  112. props: {
  113. userCompany: {
  114. type: Object,
  115. required: true,
  116. },
  117. countryOptions: {
  118. type: Array,
  119. required: true,
  120. },
  121. },
  122. data() {
  123. return {
  124. userCompanyCopy: {},
  125. countrySelect: null,
  126. validation: {
  127. CompanyName: true,
  128. TaxNumber: true,
  129. Street1: true,
  130. Street2: true,
  131. CityName: true,
  132. StateName: true,
  133. CountryID: true,
  134. ZipCode: true,
  135. },
  136. errors: null,
  137. rules: {
  138. require: (value) => !!value || this.$t("Required."),
  139. email: (v) =>
  140. /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(
  141. v
  142. ) || this.$t("Invalid email"),
  143. checkPassword: (v) =>
  144. (/(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(v) &&
  145. v.length >= 8 &&
  146. v.length <= 20) ||
  147. this.$t(
  148. "Passwords must be 8-20 characters with at least 1 number, 1 lower case letter and 1 upper case letter"
  149. ),
  150. },
  151. valid: false,
  152. };
  153. },
  154. methods: {
  155. validators() {
  156. if (is.empty(this.userCompany.CompanyName)) {
  157. this.validation.CompanyName = false;
  158. } else {
  159. this.validation.CompanyName = true;
  160. }
  161. if (is.empty(this.userCompany.TaxNumber)) {
  162. this.validation.TaxNumber = false;
  163. } else {
  164. this.validation.TaxNumber = true;
  165. }
  166. if (is.empty(this.userCompany.Street1)) {
  167. this.validation.Street1 = false;
  168. } else {
  169. this.validation.Street1 = true;
  170. }
  171. if (is.empty(this.userCompany.CityName)) {
  172. this.validation.CityName = false;
  173. } else {
  174. this.validation.CityName = true;
  175. }
  176. if (this.userCompany.ZipCode == "") {
  177. this.validation.CountryID = false;
  178. } else {
  179. this.validation.CountryID = true;
  180. }
  181. if (is.empty(this.userCompany.ZipCode)) {
  182. this.validation.ZipCode = false;
  183. } else {
  184. this.validation.ZipCode = true;
  185. }
  186. this.errors = Object.entries(this.validation).filter(
  187. (e) => e[1] == false
  188. );
  189. if (this.errors.length > 0) {
  190. return false;
  191. } else {
  192. return true;
  193. }
  194. },
  195. save() {
  196. this.validators();
  197. if (this.validators()) {
  198. const patchData = this.userCompany;
  199. this.$axios
  200. .post(`/trending/api/Members/Company`, patchData)
  201. .then((response) => {
  202. //console.log(JSON.stringify(response));
  203. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  204. let data = response.data.DATA.rel
  205. if(data){
  206. this.$emit("refetch-user");
  207. //this.$emit("update", true);
  208. this.$modal.hide("edit-company-modal");
  209. }
  210. }
  211. })
  212. .catch((error) => {
  213. console.log(error);
  214. });
  215. }
  216. },
  217. reset() {
  218. this.userCompany = {
  219. CompanyName: "",
  220. TaxNumber: "",
  221. Street1: "",
  222. Street2: "",
  223. CityName: "",
  224. StateName: "",
  225. CountryID: "",
  226. ZipCode: "",
  227. };
  228. },
  229. },
  230. };
  231. </script>
  232. <style scoped lang="scss">
  233. .close {
  234. // position: absolute;
  235. right: 30px;
  236. top: 32px;
  237. background-image: url("~/assets/svg/close.svg");
  238. background-position: center;
  239. background-repeat: no-repeat;
  240. background-size: cover;
  241. width: 14px;
  242. height: 14px;
  243. @media screen and (min-width: 768px) {
  244. right: 40px;
  245. top: 40px;
  246. }
  247. }
  248. .v--modal-overlay::v-deep {
  249. .v--modal {
  250. width: 100% !important;
  251. height: 100vh !important;
  252. @media screen and (min-width: 768px) {
  253. padding: 40px;
  254. width: max-content;
  255. height: max-content !important;
  256. border-radius: 30px;
  257. }
  258. }
  259. .v--modal-box {
  260. height: 100vh !important;
  261. overflow: auto;
  262. @media screen and (min-width: 768px) {
  263. padding: 40px;
  264. width: max-content;
  265. height: max-content !important;
  266. }
  267. }
  268. // :deep() {
  269. // .v-dialog {
  270. // border-radius: 30px !important;
  271. // }
  272. // .v-text-field--outlined fieldset {
  273. // border-color: #e5e5e5;
  274. // }
  275. // .v-select {
  276. // border-color: #e5e5e5;
  277. // }
  278. // }
  279. // .input-wrap {
  280. // @media screen and (max-width: 600px) {
  281. // width: 88%;
  282. // }
  283. // @media screen and (min-width: 600px) and (max-width: 960px) {
  284. // width: 45%;
  285. // }
  286. // @media screen and (min-width: 961px) {
  287. // width: 45%;
  288. // }
  289. // }
  290. }
  291. </style>