Send Coins
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { computed, defineComponent, onMounted, PropType, ref, watch } from 'vue'
|
||||
|
||||
import { ICircuit, IOperators, ISendCoin, ISpecialField, IUserFields } from '../../model'
|
||||
import { IAccount, ICircuit, IOperators, ISendCoin, ISpecialField, IUserFields } from '../../model'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { CCurrencyValue } from '@/components/CCurrencyValue'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useCircuitStore } from '@store/CircuitStore'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useI18n } from '@/boot/i18n'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CSendCoins',
|
||||
@@ -19,9 +21,11 @@ export default defineComponent({
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
components: { CCurrencyValue },
|
||||
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
const show = ref(false)
|
||||
const userStore = useUserStore()
|
||||
const circuitStore = useCircuitStore()
|
||||
@@ -33,8 +37,16 @@ export default defineComponent({
|
||||
const causal = ref('')
|
||||
const bothcircuits = ref(<any>[])
|
||||
|
||||
const circuitloaded = ref(<ICircuit|undefined>undefined)
|
||||
const circuitloaded = ref(<ICircuit | undefined>undefined)
|
||||
const circuitdest = ref(<ICircuit | undefined>undefined)
|
||||
const accountloaded = ref(<IAccount | undefined>undefined)
|
||||
const accountdest = ref(<IAccount | undefined>undefined)
|
||||
const remainingCoins = ref(0)
|
||||
|
||||
const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '')
|
||||
const arrayMarkerLabel = ref(<any>[])
|
||||
|
||||
const qtyRef = ref(null)
|
||||
|
||||
watch(() => circuitsel.value, (newval, oldval) => {
|
||||
aggiorna()
|
||||
@@ -47,7 +59,28 @@ export default defineComponent({
|
||||
|
||||
function aggiorna() {
|
||||
circuitloaded.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value)
|
||||
if (circuitloaded.value) {
|
||||
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
|
||||
// accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
|
||||
if (accountloaded.value) {
|
||||
remainingCoins.value = tools.getRemainingCoinsToSend(accountloaded.value)
|
||||
const quanti = [ ...Array(100).keys() ].map( i => i+1)
|
||||
for (const ind of quanti) {
|
||||
let value = ind * 10
|
||||
if (value > remainingCoins.value) {
|
||||
break
|
||||
} else {
|
||||
const label = value.toString()
|
||||
arrayMarkerLabel.value.push({value, label})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
console.log('circuitStore.listcircuits', circuitStore.listcircuits, 'aggiorna', circuitloaded.value)
|
||||
console.log('userStore.my.profile.mycircuits', userStore.my.profile.mycircuits)
|
||||
}
|
||||
|
||||
function mounted() {
|
||||
@@ -95,16 +128,23 @@ export default defineComponent({
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
t,
|
||||
tools,
|
||||
show,
|
||||
bothcircuits,
|
||||
from_username,
|
||||
circuitsel,
|
||||
circuitloaded,
|
||||
accountloaded,
|
||||
accountdest,
|
||||
qty,
|
||||
hide,
|
||||
sendCoin,
|
||||
causal,
|
||||
priceLabel,
|
||||
arrayMarkerLabel,
|
||||
remainingCoins,
|
||||
qtyRef,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user