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.

78 lines
2.8 KiB

2 years ago
  1. <template>
  2. <div class="tw-min-w-full tw-min-h-full lg:tw-w-[908px] tw-bg-white tw-px-[30px] tw-py-[30px] xl:tw-py-[20px]">
  3. <div class="tw-flex tw-items-center tw-py-[11px] tw-mb-5 md:tw-mb-[30px]">
  4. <div class="circle-decoration tw-mr-[6px]"></div>
  5. <div class="circle-decoration tw-mr-[30px]"></div>
  6. <div class="tw-t18 tw-font-bold">{{ $t('Contact Info') }}</div>
  7. </div>
  8. <div v-if="userContact.length < 1" class="tw-flex tw-justify-center">
  9. <div>
  10. <img :src="contactImg" alt="" class="tw-h-[142px] tw-w-[160px]">
  11. <div class="tw-text-center tw-t16">{{ $t('No Contact yet ...') }}</div>
  12. </div>
  13. </div>
  14. <div v-else class="tw-w-full">
  15. <ContactInfoContent
  16. :contacts="userContact"
  17. @refetch-contact-info="successUpdate"
  18. ></ContactInfoContent>
  19. </div>
  20. <div :class="userContact.length < 1 ? 'tw-flex tw-justify-center tw-mt-[50px] md:tw-mt-[60px]' : 'tw-flex tw-justify-center tw-mt-[20px] md:tw-mt-[30px]'">
  21. <button @click="$modal.show('add-contact-modal')" type="button" class="tw-bg-primary-1 tw-px-6 tw-rounded-2xl tw-h-[40px] tw-w-[169px]">
  22. <div class="tw-flex tw-items-center">
  23. <img :src="plusImg" alt="" class="tw-h-[18px] tw-w-[18px] tw-mr-2">
  24. <span class="tw-t16 tw-text-white">{{ $t('Add Contact') }}</span>
  25. </div>
  26. </button>
  27. </div>
  28. <AddContactModal @update="successUpdate"></AddContactModal>
  29. </div>
  30. </template>
  31. <script>
  32. import AddContactModal from '../newComponent/modal/UserAddContactModal.vue'
  33. import ContactInfoContent from './contactInfoContent.vue'
  34. import Swal from 'sweetalert2'
  35. export default {
  36. // async asyncData() {
  37. // const { data } = await axios.get(`/member/contacts?jwt=${this.$auth.$storage.getUniversal('jwt').token || ''}`).then( res => {
  38. // return { userContact: data.contacts }
  39. // })
  40. // },
  41. components: {
  42. ContactInfoContent,
  43. AddContactModal,
  44. },
  45. data() {
  46. return {
  47. contactImg: require('../../assets/img/noContact.png'),
  48. plusImg: require('../../assets/img/plus-white.png'),
  49. userContact: [],
  50. }
  51. },
  52. methods: {
  53. fetchContactInfo() {
  54. this.$axios.get(`/member/contacts?jwt=${this.$auth.$storage.getUniversal('jwt').token || ''}`)
  55. .then((result) => {
  56. this.userContact = result.data.contacts
  57. }).catch((err) => {
  58. console.log(err)
  59. });
  60. },
  61. successUpdate() {
  62. Swal.fire({
  63. position: 'top',
  64. icon: 'success',
  65. title: 'Your work has been saved',
  66. showConfirmButton: false,
  67. timer: 1500
  68. })
  69. this.fetchContactInfo()
  70. },
  71. },
  72. created() {
  73. if (this.$auth.loggedIn) {
  74. this.fetchContactInfo()
  75. }
  76. },
  77. }
  78. </script>
  79. <style scoped lang="scss"></style>