import { computed, defineComponent, PropType, ref, watch } from 'vue' import { ICalcStat, IOperators } from '../../model' import { useUserStore } from '../../store/UserStore' import { useRouter } from 'vue-router' import { useGlobalStore } from '../../store/globalStore' import { useCircuitStore } from '../../store/CircuitStore' import { useI18n } from '../../boot/i18n' import { shared_consts } from '@src/common/shared_vuejs' import { costanti, IMainCard } from '@store/Modules/costanti' import { CMyUser } from '../CMyUser' import { CMyGroup } from '../CMyGroup' import { CUserInfoAccount } from '../CUserInfoAccount' import { tools } from '@store/Modules/tools' import { useQuasar } from 'quasar' export default defineComponent({ name: 'CSendRISTo', props: {}, components: { CMyUser, CMyGroup, CUserInfoAccount }, setup(props) { const userStore = useUserStore() const globalStore = useGlobalStore() const circuitStore = useCircuitStore() const { t } = useI18n() const $q = useQuasar() const $router = useRouter() const receiveRislist = computed(() => globalStore.datastat ? globalStore.datastat.receiveRislist : []) const receiveRislistgroup = computed(() => globalStore.datastat ? globalStore.datastat.receiveRislistgroup : []) const usersList = ref({ show: false, title: '', list: [], listgroup: [] }) const tipoConto = ref(shared_consts.AccountType.USER) const loading = ref(false) const circuitpath = computed(() => { const circ = circuitStore.getCircuitByProvinceAndCard(userStore.my.profile.resid_province, userStore.my.profile.resid_card) return circ && circ.path ? circ.path : '' }) const contact = computed(() => userStore.my) const arrTypesAccounts = ref([ { label: t('circuit.user'), value: shared_consts.AccountType.USER, }, { label: t('circuit.conticollettivi'), value: shared_consts.AccountType.COLLECTIVE_ACCOUNT, } ]) async function sendCoinsToClick() { await updateUserListRIS() if ((globalStore.datastat!.receiveRislist!.length > 0 || (globalStore.datastat!.receiveRislistgroup!.length > 0))) { usersList.value.show = true; usersList.value.title = 'Lista Utenti Riceventi'; usersList.value.list = globalStore.datastat!.receiveRislist usersList.value.listgroup = globalStore.datastat!.receiveRislistgroup } else { $router.push(tools.updateLink('/circuits')) } } async function updateUserListRIS() { const userStore = useUserStore() loading.value = true await globalStore.getStatSite() usersList.value.list = globalStore.datastat!.receiveRislist usersList.value.listgroup = globalStore.datastat!.receiveRislistgroup loading.value = false } return { userStore, tools, costanti, shared_consts, usersList, receiveRislist, receiveRislistgroup, sendCoinsToClick, arrTypesAccounts, tipoConto, updateUserListRIS, loading, contact, circuitpath, } }, })