import { computed, defineComponent, PropType, ref } from 'vue' import { ICalcStat, IOperators } from '../../model' import { useUserStore } from '../../store/UserStore' import { useRouter } from 'vue-router' import { useGlobalStore } from '../../store/globalStore' 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 { tools } from '@store/Modules/tools' import { useQuasar } from 'quasar' export default defineComponent({ name: 'CSendRISTo', props: {}, components: { CMyUser, CMyGroup }, setup(props) { const userStore = useUserStore() const globalStore = useGlobalStore() 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(costanti.AccountType.USER) const loading = ref(false) const arrTypesAccounts = ref([ { label: t('circuit.user'), value: costanti.AccountType.USER, }, { label: t('circuit.conticollettivi'), value: costanti.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, } }, })