Version 1.0.1 with RIS Circuit Money Exchange !
This commit is contained in:
@@ -4738,6 +4738,20 @@ export const tools = {
|
||||
})
|
||||
},
|
||||
|
||||
updateMyData(res: any) {
|
||||
const userStore = useUserStore()
|
||||
const circuitStore = useCircuitStore()
|
||||
|
||||
// console.log('OUT', res)
|
||||
|
||||
if (res && res.user) {
|
||||
userStore.my = res.user
|
||||
|
||||
if (res.listcircuits) {
|
||||
circuitStore.listcircuits = res.listcircuits
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addToMyCircuits($q: any, username: string, circuitname: string) {
|
||||
|
||||
@@ -4752,12 +4766,15 @@ export const tools = {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.SET, true)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
if (res && res.result) {
|
||||
this.updateMyData(res)
|
||||
notifStore.updateNotification = true
|
||||
if (userStore.my.profile.mycircuits)
|
||||
userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res]
|
||||
else
|
||||
userStore.my.profile.mycircuits = [res]
|
||||
if (res.circuit) {
|
||||
if (userStore.my.profile.mycircuits)
|
||||
userStore.my.profile.mycircuits = [...userStore.my.profile.mycircuits, res.circuit]
|
||||
else
|
||||
userStore.my.profile.mycircuits = [res]
|
||||
}
|
||||
tools.showPositiveNotif($q, t('db.addedcircuit', { circuitname }))
|
||||
}
|
||||
})
|
||||
@@ -4797,10 +4814,8 @@ export const tools = {
|
||||
userStore.setCircuitCmd($q, t, username, notif.extrarec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT, 0, notif.extrarec)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
this.updateMyData(res)
|
||||
if (res.cansend) {
|
||||
if (res.user) {
|
||||
userStore.my = res.user
|
||||
}
|
||||
console.log('useraccounts', userStore.my.profile.useraccounts)
|
||||
tools.showPositiveNotif($q, t('circuit.coins_accepted'))
|
||||
} else {
|
||||
@@ -4816,7 +4831,8 @@ export const tools = {
|
||||
notif.extrarec.notifId = notif._id
|
||||
userStore.setCircuitCmd($q, t, username, notif.extrarec.circuitname, shared_consts.CIRCUITCMD.SENDCOINS_REFUSE, 0, notif.extrarec)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
if (res && res.result) {
|
||||
this.updateMyData(res)
|
||||
tools.showPositiveNotif($q, t('circuit.coins_refused'))
|
||||
}
|
||||
})
|
||||
@@ -5259,7 +5275,7 @@ export const tools = {
|
||||
if (res) {
|
||||
if (value) {
|
||||
// ADD to req
|
||||
userStore.my.profile.asked_circuits.push(res)
|
||||
userStore.my.profile.asked_circuits.push(res.circuit)
|
||||
tools.showPositiveNotif($q, t('circuit.askedto', { circuitname }))
|
||||
} else {
|
||||
// REMOVE to req
|
||||
@@ -5267,6 +5283,7 @@ export const tools = {
|
||||
tools.showPositiveNotif($q, t('circuit.revoketo', { circuitname }))
|
||||
}
|
||||
|
||||
this.updateMyData(res)
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
}
|
||||
@@ -5302,13 +5319,11 @@ export const tools = {
|
||||
if (res.useraccounts && res.useraccounts.length > 0) {
|
||||
userStore.my.profile.useraccounts = res.useraccounts
|
||||
}
|
||||
if (res.user) {
|
||||
userStore.my = res.user
|
||||
}
|
||||
tools.showPositiveNotif($q, t('circuit.coins_sendrequest_sent'))
|
||||
} else {
|
||||
tools.showNegativeNotif($q, res.errormsg)
|
||||
}
|
||||
this.updateMyData(res)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5327,11 +5342,12 @@ export const tools = {
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.CANCEL_REQ, null).then((res) => {
|
||||
if (res) {
|
||||
if (res && res.result) {
|
||||
if (username === userStore.my.username) {
|
||||
userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname)
|
||||
}
|
||||
tools.showPositiveNotif($q, t('db.cancel_req_group'))
|
||||
this.updateMyData(res)
|
||||
tools.showPositiveNotif($q, t('circuit.cancel_req'))
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -5349,12 +5365,13 @@ export const tools = {
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REFUSE_REQ, null).then((res) => {
|
||||
if (res) {
|
||||
if (res && res.result) {
|
||||
notifStore.updateNotification = true
|
||||
if (username === userStore.my.username) {
|
||||
userStore.my.profile.asked_circuits = userStore.my.profile.asked_circuits.filter((rec: ICircuit) => rec.name !== circuitname)
|
||||
}
|
||||
tools.showPositiveNotif($q, t('circuit.refusedcircuit', { username }))
|
||||
this.updateMyData(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -5371,11 +5388,12 @@ export const tools = {
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST, null).then((res) => {
|
||||
if (res) {
|
||||
if (res && res.result) {
|
||||
if (userStore.my.profile.mycircuits && username === userStore.my.username) {
|
||||
userStore.my.profile.mycircuits = userStore.my.profile.mycircuits.filter((rec: IMyCircuit) => rec.circuitname !== circuitname)
|
||||
}
|
||||
tools.showPositiveNotif($q, t('circuit.removed'))
|
||||
this.updateMyData(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -5392,7 +5410,7 @@ export const tools = {
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.ADDADMIN, null).then((res) => {
|
||||
if (res) {
|
||||
if (res && res.result) {
|
||||
const mycircuit = userStore.my.profile.manage_mycircuits.find((rec: ICircuit) => rec.name === circuitname)
|
||||
console.log('mycircuit', mycircuit)
|
||||
if (mycircuit && mycircuit.admins) {
|
||||
@@ -5400,6 +5418,7 @@ export const tools = {
|
||||
console.log('mycircuit.admins', mycircuit.admins)
|
||||
tools.showPositiveNotif($q, t('db.addedtoadmin', { username }))
|
||||
}
|
||||
this.updateMyData(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -5416,7 +5435,7 @@ export const tools = {
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.REMOVEADMIN, null).then((res) => {
|
||||
if (res) {
|
||||
if (res && res.result) {
|
||||
const mygrp = userStore.my.profile.manage_mycircuits.find((rec: ICircuit) => rec.name === circuitname)
|
||||
console.log('mygrp', mygrp)
|
||||
if (mygrp && mygrp.admins) {
|
||||
@@ -5424,6 +5443,7 @@ export const tools = {
|
||||
console.log('mygrp.admins', mygrp.admins)
|
||||
tools.showPositiveNotif($q, t('db.removedtoadmin', { username }))
|
||||
}
|
||||
this.updateMyData(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -5440,11 +5460,12 @@ export const tools = {
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setCircuitCmd($q, t, username, circuitname, shared_consts.CIRCUITCMD.DELETE, null).then((res) => {
|
||||
if (res) {
|
||||
if (res && res.result) {
|
||||
if (userStore.my.profile.manage_mycircuits) {
|
||||
userStore.my.profile.manage_mycircuits = userStore.my.profile.manage_mycircuits.filter((rec: ICircuit) => rec.name !== circuitname)
|
||||
tools.showPositiveNotif($q, t('circuit.deleted', { circuitname }))
|
||||
}
|
||||
this.updateMyData(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -5862,11 +5883,17 @@ export const tools = {
|
||||
},
|
||||
getdefaultnewrec_Circuit(): any {
|
||||
return {
|
||||
_id: 0,
|
||||
name: '',
|
||||
subname: '',
|
||||
img_logo: '',
|
||||
photos: [],
|
||||
admins: [],
|
||||
color: '#ff5500',
|
||||
deperimento: false,
|
||||
symbol: 'RIS',
|
||||
fido_scoperto_default: 100,
|
||||
qta_max_default: 500,
|
||||
totTransato: 0,
|
||||
totCircolante: 0,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -6333,7 +6360,7 @@ export const tools = {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
@@ -6345,10 +6372,7 @@ export const tools = {
|
||||
}
|
||||
},
|
||||
roundDec2(mynum: number): number {
|
||||
return (Math.round(mynum * 100)/100);
|
||||
},
|
||||
roundDec2Str(mynum: number): string {
|
||||
return (Math.round(mynum * 100)/100).toFixed(2);
|
||||
return (Math.round(mynum * 100) / 100)
|
||||
},
|
||||
// getLocale() {
|
||||
// if (navigator.languages && navigator.languages.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user