144 lines
3.4 KiB
TypeScript
Executable File
144 lines
3.4 KiB
TypeScript
Executable File
import { defineComponent, onMounted, PropType, ref, watch } from 'vue'
|
|
import { useUserStore } from '@store/UserStore'
|
|
import { IMyGroup, IImgGallery, IUserFields, IUserProfile, IFriends, ICircuit, IAccount } from 'model'
|
|
import { costanti } from '@costanti'
|
|
import { shared_consts } from '@/common/shared_vuejs'
|
|
import { tools } from '@store/Modules/tools'
|
|
import { useQuasar } from 'quasar'
|
|
import { useI18n } from '@/boot/i18n'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { CUserNonVerif } from '@/components/CUserNonVerif'
|
|
import { toolsext } from '@store/Modules/toolsext'
|
|
import { CSaldo } from '@/components/CSaldo'
|
|
import { CSendCoins } from '@/components/CSendCoins'
|
|
import { CCurrencyValue } from '@/components/CCurrencyValue'
|
|
import { CCurrencyV2 } from '@/components/CCurrencyV2'
|
|
import { useCircuitStore } from '@store/CircuitStore'
|
|
|
|
export default defineComponent({
|
|
name: 'CUserInfoAccount',
|
|
emits: ['setCmd'],
|
|
components: { CUserNonVerif, CSaldo, CSendCoins, CCurrencyValue, CCurrencyV2 },
|
|
props: {
|
|
user: {
|
|
type: Object as PropType<IUserFields>,
|
|
required: true,
|
|
},
|
|
circuitname: {
|
|
type: String,
|
|
required: false,
|
|
default: '',
|
|
},
|
|
circuitpath: {
|
|
type: String,
|
|
required: false,
|
|
default: '',
|
|
},
|
|
admin: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false,
|
|
},
|
|
onlysaldo: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false,
|
|
},
|
|
account: {
|
|
type: Object as PropType<IAccount>,
|
|
required: false,
|
|
default: null,
|
|
},
|
|
},
|
|
|
|
setup(props, { emit }) {
|
|
|
|
const userStore = useUserStore()
|
|
const $q = useQuasar()
|
|
const { t } = useI18n()
|
|
const $router = useRouter()
|
|
|
|
const myaccount = ref(<IAccount | undefined>undefined)
|
|
|
|
const circuitStore = useCircuitStore()
|
|
|
|
const table = ref(toolsext.TABMYGROUPS)
|
|
|
|
const circuit = ref(<ICircuit | null | undefined>null)
|
|
|
|
watch(() => props.user, (newval, oldval) => {
|
|
mounted()
|
|
})
|
|
|
|
watch(() => tools.isUserOk(), (newval, oldval) => {
|
|
if (userStore.isUserOk()) {
|
|
mounted()
|
|
}
|
|
})
|
|
|
|
function mounted() {
|
|
if (props.circuitname)
|
|
circuit.value = circuitStore.getCircuitByName(props.circuitname)
|
|
else if (props.circuitpath) {
|
|
circuit.value = circuitStore.getCircuitByPath(props.circuitpath)
|
|
}
|
|
|
|
if (props.account) {
|
|
myaccount.value = props.account
|
|
} else {
|
|
if (props.user.account) {
|
|
myaccount.value = props.user.account
|
|
} else {
|
|
if (circuit.value)
|
|
myaccount.value = userStore.getAccountByCircuitId(circuit.value._id)
|
|
}
|
|
}
|
|
}
|
|
|
|
function getImgGroup(group: IMyGroup) {
|
|
return userStore.getImgByGroup(group)
|
|
}
|
|
|
|
function naviga(path: string) {
|
|
$router.push(path)
|
|
}
|
|
|
|
function setCmd(cmd: number, myusername: string, value: any = '') {
|
|
emit('setCmd', cmd, myusername, value)
|
|
}
|
|
|
|
function myusername() {
|
|
return userStore.my.username
|
|
}
|
|
|
|
async function save(value: any) {
|
|
console.log('save and mounted')
|
|
await tools.loadCircuits()
|
|
// ricarico
|
|
mounted()
|
|
|
|
|
|
}
|
|
|
|
onMounted(mounted)
|
|
|
|
return {
|
|
costanti,
|
|
getImgGroup,
|
|
naviga,
|
|
setCmd,
|
|
shared_consts,
|
|
userStore,
|
|
tools,
|
|
table,
|
|
myusername,
|
|
circuit,
|
|
circuitStore,
|
|
t,
|
|
myaccount,
|
|
save,
|
|
toolsext,
|
|
}
|
|
},
|
|
})
|