Visu Sent Monete
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import {
|
||||
IAccount,
|
||||
ICircuit, ICircuitState, IGlobalState,
|
||||
} from '@src/model'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
@@ -29,6 +30,12 @@ export const useCircuitStore = defineStore('CircuitStore', {
|
||||
},
|
||||
|
||||
actions: {
|
||||
getRemainingCoinsToSend(account: IAccount) {
|
||||
return tools.roundDec2(account.saldo + account.fidoConcesso)
|
||||
},
|
||||
getMaxCoinsToSend(account: IAccount) {
|
||||
return tools.roundDec2(account.qta_maxConcessa - account.saldo)
|
||||
},
|
||||
|
||||
async loadCircuits() {
|
||||
return Api.SendReq('/users/circuits', 'POST', null)
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
ITodo,
|
||||
IUserFields,
|
||||
Privacy,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport, ISpecialField, IAccount, IMyCircuit, ISendCoin, IMovement, IMovVisu,
|
||||
TipoVisu, IGroup, IMySkill, IMyBacheca, IImgGallery, IMsgGlobParam, IUserExport, ISpecialField, IAccount, IMyCircuit, ISendCoin, IMovement, IMovVisu, INotif,
|
||||
} from '@model'
|
||||
|
||||
import { addToDate } from '@quasar/quasar-ui-qcalendar'
|
||||
@@ -3365,7 +3365,7 @@ export const tools = {
|
||||
return 'primary'
|
||||
},
|
||||
|
||||
convstrToNum(myval: any) {
|
||||
convstrToNum(myval: any): number {
|
||||
|
||||
if (typeof myval == 'number' && !isNaN(myval)) {
|
||||
if (Number.isInteger(myval)) {
|
||||
@@ -3375,6 +3375,7 @@ export const tools = {
|
||||
return parseFloat(myval)
|
||||
}
|
||||
}
|
||||
return parseFloat(myval)
|
||||
},
|
||||
|
||||
getCookie(mytok: any, def?: any, convertint: any = false) {
|
||||
@@ -4787,10 +4788,11 @@ export const tools = {
|
||||
},
|
||||
|
||||
|
||||
acceptCoins($q: any, username: string, recsendcoin: ISendCoin) {
|
||||
acceptCoins($q: any, username: string, notif: any) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
userStore.setCircuitCmd($q, t, username, recsendcoin.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT, 0, recsendcoin)
|
||||
notif.extrarec.notifId = notif._id
|
||||
userStore.setCircuitCmd($q, t, username, notif.extrarec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT, 0, notif.extrarec)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
if (res.cansend) {
|
||||
@@ -5265,7 +5267,7 @@ export const tools = {
|
||||
})
|
||||
},
|
||||
|
||||
sendCoinsByCircuit($q: any, circuit: ICircuit, sendcoinrec: ISendCoin): any {
|
||||
async sendCoinsByCircuit($q: any, circuit: ICircuit, sendcoinrec: ISendCoin) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -5274,7 +5276,7 @@ export const tools = {
|
||||
let msg = ''
|
||||
msg = t('circuit.question_sendcoinsto', { coin: circuit.symbol, dest: sendcoinrec.dest, qty: sendcoinrec.qty })
|
||||
|
||||
$q.dialog({
|
||||
return $q.dialog({
|
||||
message: msg,
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
@@ -5288,7 +5290,11 @@ export const tools = {
|
||||
|
||||
return userStore.setCircuitCmd($q, t, username, sendcoinrec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_REQ, true, sendcoinrec)
|
||||
.then((res: any) => {
|
||||
if (res.cansend) {
|
||||
console.log('setCircuitCmd ', res)
|
||||
if (res && res.cansend) {
|
||||
if (res.useraccounts && res.useraccounts.length > 0) {
|
||||
userStore.my.profile.useraccounts = res.useraccounts
|
||||
}
|
||||
tools.showPositiveNotif($q, t('circuit.coins_sendrequest_sent'))
|
||||
} else {
|
||||
tools.showNegativeNotif($q, res.errormsg)
|
||||
@@ -5296,7 +5302,9 @@ export const tools = {
|
||||
})
|
||||
})
|
||||
|
||||
return null
|
||||
return await new Promise((resolve, reject) => {
|
||||
resolve(false)
|
||||
})
|
||||
},
|
||||
|
||||
cancelReqCircuit($q: any, username: string, circuitname: string) {
|
||||
@@ -6311,11 +6319,11 @@ export const tools = {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
getRemainingCoinsToSend(account: IAccount) {
|
||||
return account.saldo + account.fidoConcesso;
|
||||
roundDec2(mynum: number): number {
|
||||
return (Math.round(mynum * 100)/100);
|
||||
},
|
||||
getMaxCoinsToSend(account: IAccount) {
|
||||
return account.qta_maxConcessa - account.saldo;
|
||||
roundDec2Str(mynum: number): string {
|
||||
return (Math.round(mynum * 100)/100).toFixed(2);
|
||||
},
|
||||
// getLocale() {
|
||||
// if (navigator.languages && navigator.languages.length > 0) {
|
||||
|
||||
@@ -60,6 +60,7 @@ export const func_tools = {
|
||||
export const toolsext = {
|
||||
TABUSER: 'users',
|
||||
TABFRIENDS: 'friends',
|
||||
TABMOVEMENTS: 'movements',
|
||||
TABMYGROUPS: 'mygroups',
|
||||
TABSKILLS: 'skills',
|
||||
TABGOODS: 'goods',
|
||||
|
||||
@@ -25,6 +25,12 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
|
||||
},
|
||||
|
||||
getnotifs_coinsreq: (mystate: INotifState) => (): INotif[] => {
|
||||
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => !rec.read && rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS && rec.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ) : []
|
||||
return (ctrec)
|
||||
|
||||
},
|
||||
|
||||
getnumNotifUnread: (mystate: INotifState) => () => {
|
||||
const myarr = mystate.last_notifs.filter((notif) => !notif.read)
|
||||
return (tools.isArray(myarr) ? myarr.length : 0)
|
||||
@@ -55,6 +61,19 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
this.updateArrNotif()
|
||||
},
|
||||
|
||||
updateRecNotif(recnotif: INotif) {
|
||||
if (recnotif) {
|
||||
const myrec = this.last_notifs.find((rec: any) => rec._id === recnotif._id)
|
||||
if (myrec) {
|
||||
myrec.status = recnotif.status
|
||||
myrec.read = recnotif.read
|
||||
myrec.descr = recnotif.descr
|
||||
|
||||
this.updateArrNotif()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async setBadgeIconApp(){
|
||||
// Get our dummy count and update it,
|
||||
// just to give more context for this demo.
|
||||
|
||||
@@ -27,6 +27,7 @@ import { costanti } from '@costanti'
|
||||
import { IMyGroup } from '@model/UserStore'
|
||||
|
||||
import globalroutines from '../globalroutines/index'
|
||||
import { useNotifStore } from '@store/NotifStore'
|
||||
|
||||
export const DefaultUser: IUserFields = {
|
||||
_id: '',
|
||||
@@ -1226,9 +1227,14 @@ export const useUserStore = defineStore('UserStore', {
|
||||
},
|
||||
|
||||
async setCircuitCmd($q: any, t: any, usernameOrig: string, circuitname: string, cmd: number, value: any, extrarec?: any) {
|
||||
return Api.SendReq('/users/circuits/cmd', 'POST', { usernameOrig, circuitname, cmd, value, extrarec })
|
||||
return await Api.SendReq('/users/circuits/cmd', 'POST', { usernameOrig, circuitname, cmd, value, extrarec })
|
||||
.then((res) => {
|
||||
this.updateTables = true
|
||||
if (res.data.recnotif) {
|
||||
const notifStore = useNotifStore()
|
||||
|
||||
notifStore.updateRecNotif(res.data.recnotif)
|
||||
}
|
||||
return res.data
|
||||
}).catch((error) => {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
|
||||
Reference in New Issue
Block a user