Conto Comunitario...

This commit is contained in:
Surya Paolo
2023-01-12 01:03:19 +01:00
parent 2acf161d5d
commit 3d77cf671d
21 changed files with 436 additions and 65 deletions

View File

@@ -8,6 +8,7 @@ import { useCircuitStore } from '@store/CircuitStore'
import { useQuasar } from 'quasar'
import { useI18n } from '@/boot/i18n'
import { CMyUserOnlyView } from '@/components/CMyUserOnlyView'
import { CMyGroupOnlyView } from '@/components/CMyGroupOnlyView'
import { costanti } from '@costanti'
export default defineComponent({
@@ -22,6 +23,11 @@ export default defineComponent({
type: String,
default: ''
},
qtydefault: {
type: String,
required: false,
default: '1'
},
to_user: {
type: Object as PropType<IUserFields>,
required: false,
@@ -38,7 +44,7 @@ export default defineComponent({
default: null,
},
},
components: { CSaldo, CMyUserOnlyView },
components: { CSaldo, CMyUserOnlyView, CMyGroupOnlyView },
setup(props, { emit }) {
const $q = useQuasar()
@@ -48,18 +54,22 @@ export default defineComponent({
const circuitStore = useCircuitStore()
const from_username = ref(userStore.my.username)
const from_groupname = ref('')
const circuitsel = ref('')
const qty = ref(<string | number>'')
const causal = ref('')
const bothcircuits = ref(<any>[])
const groupSel = ref(<IMyGroup | null | undefined>null)
const circuitloaded = ref(<ICircuit | undefined>undefined)
const circuitdest = ref(<ICircuit | undefined>undefined)
const accountloaded = ref(<IAccount | undefined>undefined)
const accountloaded = ref(<IAccount | undefined | null>undefined)
const accountdest = ref(<IAccount | undefined>undefined)
const remainingCoins = ref(0)
const maxsendable = ref(0)
const numstep = ref(0)
const tipoConto = ref(0)
const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '')
const arrayMarkerLabel = ref(<any>[])
@@ -67,20 +77,52 @@ export default defineComponent({
const qtyRef = ref(<any>null)
const causalRef = ref(<any>null)
const groupsListAdmin = ref(<IMyGroup[]>[])
const arrGroupsList = ref(<any[]>[])
watch(() => circuitsel.value, (newval, oldval) => {
tools.setCookie(tools.CIRCUIT_USE, newval)
aggiorna()
})
watch(() => tipoConto.value, (newval, oldval) => {
aggiorna()
})
watch(() => from_groupname.value, (newval, oldval) => {
aggiorna()
})
watch(() => from_username.value, (newval, oldval) => {
aggiorna()
})
watch(() => props.showprop, (newval, oldval) => {
console.log('props.showprop', props.showprop, newval)
show.value = newval
})
function aggiorna() {
groupSel.value = null
accountloaded.value = null
circuitloaded.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value)
if (circuitloaded.value) {
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
if (tipoConto.value === costanti.AccountType.USER) {
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
} else if (tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT) {
groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname)
accountloaded.value = groupSel.value ? groupSel.value.account : null
}
groupsListAdmin.value = userStore.GroupsListWhereIAmAdmin()
arrGroupsList.value = []
for (const group of groupsListAdmin.value) {
arrGroupsList.value.push({ label: group.groupname, value: group.groupname });
}
// accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
if (accountloaded.value) {
remainingCoins.value = circuitStore.getRemainingCoinsToSend(accountloaded.value)
@@ -132,6 +174,8 @@ export default defineComponent({
circuitsel.value = bothcircuits.value[0]
}
qty.value = props.qtydefault
aggiorna()
show.value = true
@@ -191,6 +235,8 @@ export default defineComponent({
}
}
onMounted(mounted)
return {
@@ -217,6 +263,9 @@ export default defineComponent({
numstep,
costanti,
userStore,
tipoConto,
arrGroupsList,
from_groupname,
}
},
})