import { tools } from '../../store/Modules/tools'
import { useQuasar } from 'quasar'
import { useI18n } from 'vue-i18n'
import { useUserStore } from '@store/UserStore'
import { useGlobalStore } from '@store/globalStore'
import type { PropType} from 'vue';
import { defineComponent, computed, ref } from 'vue'
import type { IUserFields } from 'model'
import { shared_consts } from '@src/common/shared_vuejs'
import { CLabel } from '@src/components/CLabel'
import { CSendCoins } from '@src/components/CSendCoins'

export default defineComponent({
  name: 'CContactUser',
  emits: ['showed'],
  props: {
    myuser: {
      type: Object as PropType<IUserFields>,
      required: true,
    },
    showBtnActivities: {
      type: Boolean,
      required: true,
    },
    showBtnRis: {
      type: Boolean,
      required: true,
    },
    sendRIS: {
      type: String,
      required: false,
      default: '',
    },
    causalDest: {
      type: String,
      required: false,
      default: '',
    },
  },
  components: { CLabel, CSendCoins },
  setup(props, { emit }) {
    const $q = useQuasar()
    const userStore = useUserStore()
    const globalStore = useGlobalStore()

    const showsendCoinTo = ref(false)
    const showingtooltip = ref(false)

    const site = computed(() => globalStore.site)
    const loading = ref(false)

    function myusername() {
      return userStore.my.username
    }

    function getLinkWebSite() {
      if (props.myuser) {
        let mysite = props.myuser.profile.website!
        if (mysite) {
          if (!mysite.startsWith('http')) {
            mysite = 'https://' + mysite
          }
        }
        return mysite
      } else {
        return ''
      }
    }

    function clickOpenSendCoin() {
      if (!userStore.my.profile.resid_province) {
        // showProvinceToSelect.value = true
      } else {
        loading.value = true
        showsendCoinTo.value = true
      }

    }

    function showed() {
      loading.value = false
      emit('showed')
    }


    return {
      tools,
      userStore,
      shared_consts,
      showsendCoinTo,
      getLinkWebSite,
      myusername,
      showingtooltip,
      clickOpenSendCoin,
      site,
      loading,
      showed,
    }
  },
})
