import type { PropType } from 'vue';
import { defineComponent, ref, computed, toRef, onMounted } from 'vue'
import { useUserStore } from '@store/UserStore'
import { useCircuitStore } from '@store/CircuitStore'
import { useRouter } from 'vue-router'
import { useGlobalStore } from '@store/globalStore'
import { useI18n } from 'vue-i18n'
import { tools } from '@tools'
import type { IMyGroup, IUserFields } from '../../model';
import { IAccount, ICircuit, IOperators, ISendCoin, ISpecialField } from '../../model'
import { useQuasar } from 'quasar'

export default defineComponent({
  name: 'CCheckCircuitsEnabled',
  components: {},
  props: {
    to_user: {
      type: Object as PropType<IUserFields>,
      required: false,
      default: null
    },
    to_group: {
      type: Object as PropType<IMyGroup>,
      required: false,
      default: null,
    },
    to_contocom: {
      type: String,
      required: false,
      default: '',
    },
  },
  setup(props, { emit }) {
    const $q = useQuasar()
    const { t } = useI18n()
    const userStore = useUserStore()
    const circuitStore = useCircuitStore()
    const $router = useRouter()
    const globalStore = useGlobalStore()

    const non_hai_circuito_nazionale = ref(false)
    const destin_non_ha_circuito_naz = ref(false)

    function load() {
      non_hai_circuito_nazionale.value = !circuitStore.sonoDentroAlCircuitoNazionale()
      if (props.to_user) {
        destin_non_ha_circuito_naz.value = !circuitStore.EDentroAlCircuitoNazionale(props.to_user)
        if (userStore.getMyCircuitsInCommonByUser(props.to_user).length > 0) {
          destin_non_ha_circuito_naz.value = false
        }
      }
    }

    onMounted(load)

    return {
      userStore,
      tools,
      non_hai_circuito_nazionale,
      destin_non_ha_circuito_naz,
    }
  }
})
