- Nella Lavagna, cliccando sul nome dell'invitato, compaiono le sue informazioni sugli step rimasti, in dettaglio.

- Ogni utente puo' cosi scegliere di regalare un proprio invitato, cliccando sull'invitato, scrivendo l'username del destinatario e premendo il bottone 'Regala Invitato'.
Al destinatario gli arriverà un messaggio sul Bot Telegram che indica che gli è stato regalato un'invitato.
This commit is contained in:
Paolo Arena
2020-02-02 04:07:24 +01:00
parent 4b54a9ce52
commit 20cd0f2e52
56 changed files with 881 additions and 132 deletions

View File

@@ -0,0 +1,12 @@
import { ISignupOptions } from 'model'
import { email, minLength, required, sameAs } from 'vuelidate/lib/validators'
// import { ValidationRuleset } from 'vuelidate'
import { complexity, registeredemail, registereduser, aportadorexist } from '../../validation'
export const validations = {
aportador_solidario: {
aportadorexist,
required
}
}

View File

@@ -9,19 +9,110 @@ import { CTitleBanner } from '../CTitleBanner'
import { CMyFieldDb } from '../CMyFieldDb'
import { CCopyBtn } from '../CCopyBtn'
import { CUserBadge } from '../CUserBadge'
import { CLegenda } from '../CLegenda'
import { IDashboard, IUserProfile } from '../../model'
import { IUserFields } from '../../model/UserStore'
import { CRequisito } from '../CRequisito'
import translate from '../../globalroutines/util'
import { tools } from '../../store/Modules/tools'
import { lists } from '../../store/Modules/lists'
import { validations } from './CMyDashboard-validate'
import { validationMixin } from 'vuelidate'
@Component({
components: { CProfile, CTitleBanner, CMyFieldDb, CCopyBtn, CUserBadge }
mixins: [validationMixin],
validations,
components: { CProfile, CTitleBanner, CMyFieldDb, CCopyBtn, CUserBadge, CLegenda, CRequisito }
})
export default class CMyDashboard extends MixinUsers {
@Prop({ required: true }) public username
public $v
public $q
public dashboard = { aportador: DefaultUser, numpeople_aportador: 0, downline: [], downbyuser: [] }
public myusername: string = ''
public showuserinfo: boolean = false
public notifBot: boolean = true
public seluser: IUserFields = null
public aportador_solidario: string = ''
public dashboard: IDashboard = {
myself: DefaultUser,
aportador: DefaultUser,
numpeople_aportador: 0,
downline: [],
downnotreg: [],
downbyuser: []
}
public mythis() {
@Prop({ required: true }) public username
public arrrequisiti = [
{
icon: 'email',
textlang: 'reg.verified_email',
isok(user) {
if (user)
return user.verified_email
else
return false
},
info: '',
},
{
icon: 'fab fa-telegram',
textlang: 'reg.telegram',
isok(user) {
if (user)
if (user.profile)
return user.profile.teleg_id > 0
return false
},
info: '',
},
{
icon: 'fas fa-video',
textlang: 'steps.zoom_partecipa',
isok(user) {
if (user)
if (user.profile)
return user.profile.saw_zoom_presentation
return false
},
info: '',
},
{
icon: 'fas fa-heart',
textlang: 'steps.dream',
isok(user) {
if (user)
if (user.profile.my_dream)
return user.profile.my_dream.length > 20
else
return false
},
info: '',
},
{
icon: 'far fa-credit-card',
textlang: 'steps.paymenttype',
isok(user) {
if (user)
if (user.profile.paymenttypes)
return user.profile.paymenttypes.length > 20
else
return false
},
info: '',
},
]
@Watch('UserStore.state.my.dashboard')
public changedash() {
console.log('changedash')
this.dashboard = UserStore.state.my.dashboard
}
get mythis() {
return this
}
@@ -34,40 +125,106 @@ export default class CMyDashboard extends MixinUsers {
this.update_username()
}
public update_username() {
public async update_username() {
// console.log('update_username')
if (this.username === '')
this.username = this.getMyUsername()
this.myusername = this.getMyUsername()
else
this.myusername = this.username
UserStore.actions.getDashboard({ username: this.username }).then((ris) => {
// console.log('getDashboard', ris)
if (ris.aportador === undefined) {
this.dashboard.aportador = DefaultUser
} else {
this.dashboard.aportador = ris.aportador
}
if (ris.numpeople_aportador === undefined) {
this.dashboard.numpeople_aportador = 0
} else {
this.dashboard.numpeople_aportador = ris.numpeople_aportador
}
if (ris.downline === undefined) {
this.dashboard.downline = []
} else {
this.dashboard.downline = ris.downline
}
if (ris.downbyuser === undefined) {
this.dashboard.downbyuser = []
} else {
this.dashboard.downbyuser = ris.downbyuser
}
// console.log('this.dashboard', this.dashboard)
await UserStore.actions.getDashboard({ username: this.myusername }).then((ris) => {
this.dashboard = UserStore.state.my.dashboard
})
}
get getRefLink() {
return UserStore.getters.getRefLink(this.username)
return UserStore.getters.getRefLink(this.myusername)
}
get invitatinotreg() {
if (this.dashboard)
if (this.dashboard.downnotreg)
return this.dashboard.downnotreg.length > 0
return false
}
public selectclick(user) {
this.showuserinfo = true
this.seluser = user
}
public isextralist(user) {
return !!user.cell_complete
}
public ismyinvited_notreg(user) {
return this.dashboard.downnotreg.find((rec) => rec.ind_order === user.ind_order)
}
public ismydownline(user) {
return this.dashboard.downline.find((rec) => rec.username === user.username)
}
public async deleteUserFromExtraList(user) {
await tools.askConfirm(this.$q, translate('reg.cancella_invitato'), translate('reg.cancella_invitato') + ' ' + user.name + ' ' + user.surname + '?', translate('dialog.yes'), translate('dialog.no'), this, '', lists.MenuAction.DELETE_EXTRALIST, 0, {
param1: user,
param2: true
})
}
public async RegalaInvitato(user, aportador_solidario, notifBottxt) {
let notiftxt = ''
if (this.notifBot)
notiftxt = notifBottxt
await tools.askConfirm(this.$q, translate('reg.regala_invitato'), translate('reg.regala_invitato') + ' ' + user.name + ' ' + user.surname + ' a ' + aportador_solidario + ' ?', translate('dialog.yes'), translate('dialog.no'), this, '', lists.MenuAction.REGALA_INVITATO, 0, {
param1: user,
param2: aportador_solidario,
param3: notiftxt
})
}
public errorMsg(cosa: string, item: any) {
try {
if (!item.$error) {
return ''
}
if (item.required !== undefined) {
if (!item.required) {
return this.$t('reg.err.required')
}
} else if (cosa === 'aportador_solidario') {
// console.log(item);
if (!item.aportadorexist) {
// console.log('!item.aportadorexist !')
return this.$t('reg.err.aportador_regalare_not_exist')
}
}
return ''
} catch (error) {
// console.log("ERR : " + error);
}
}
get allowSubmit() {
let error = this.$v.$error || this.$v.$invalid
error = error || (this.aportador_solidario === this.seluser.aportador_solidario)
return !error
}
get getnotifBotTxt() {
return this.$t('dashboard.ricevuto_dono', {
invitato: this.seluser.name + ' ' + this.seluser.surname,
mittente: this.dashboard.myself.username
})
}
}

View File

@@ -1,18 +1,16 @@
<template>
<div class="q-ma-xs q-gutter-xs q-pa-xs" v-if="username !== ''">
<CTitleBanner class="q-pa-xs" :title="$t('pages.dashboard') +` (`+ username + `)`" bgcolor="bg-info" clcolor="text-white"
<div class="q-ma-xs q-gutter-xs q-pa-xs" v-if="myusername !== ''">
<CTitleBanner class="q-pa-xs" :title="$t('pages.dashboard')" bgcolor="bg-info" clcolor="text-white"
mystyle=" " myclass="myshad">
<CCopyBtn :title="$t('reg.reflink')" :texttocopy="getRefLink">
</CCopyBtn>
<CTitleBanner class="shadow-2" :title="$t('reg.aportador_solidario')" bgcolor="bg-accent"
clcolor="text-white"
mystyle=" " myclass="myshad" :canopen="true">
<CUserBadge v-if="!!dashboard.aportador.name" :user="dashboard.aportador" :index="0" :numpeople="dashboard.numpeople_aportador"
mycolor="accent">
<CUserBadge v-if="!!dashboard.aportador" :user="dashboard.aportador" :index="0"
:numpeople="dashboard.numpeople_aportador"
mycolor="accent" @myclick="selectclick">
</CUserBadge>
<div v-else class="q-pa-sm text-center">
@@ -20,17 +18,35 @@
</div>
</CTitleBanner>
<CTitleBanner class="shadow-2" :title="$t('reg.you')" bgcolor="bg-blue"
clcolor="text-white"
mystyle=" " myclass="myshad" :canopen="true">
<CUserBadge v-if="!!dashboard.myself" :user="dashboard.myself" :index="0"
:numpeople="dashboard.downline.length"
@myclick="selectclick"
mycolor="blue">
</CUserBadge>
</CTitleBanner>
<CTitleBanner class="shadow-2 rounded-borders" :title="$t('dashboard.downline')" bgcolor="bg-positive"
clcolor="text-white"
mystyle=" " myclass="myshad" :canopen="true">
<q-list bordered v-if="!!dashboard.downline && dashboard.downline.length > 0" class="rounded-borders">
<div v-for="(user, index) in dashboard.downline" :key="index">
<CUserBadge :yourinvite="true" :user="user" mycolor="primary" :index="index" :numpeople="dashboard.downbyuser[user.username].length">
<CUserBadge :yourinvite="true" :user="user" mycolor="positive" :index="index"
:numpeople="dashboard.downbyuser[user.username].length"
@myclick="selectclick"
>
</CUserBadge>
<div style="margin-left:10px;" v-for="(user2, index2) in dashboard.downbyuser[user.username]" :key="index2">
<CUserBadge :yourinvite="false" :user="user2" mycolor="orange" :index="index2" :numpeople="dashboard.downbyuser[user2.username].length">
<CUserBadge :yourinvite="false" :user="user2" mycolor="orange" :index="index2"
:numpeople="dashboard.downbyuser[user2.username].length"
@myclick="selectclick"
>
</CUserBadge>
</div>
@@ -41,6 +57,21 @@
</div>
</CTitleBanner>
<CTitleBanner v-if="invitatinotreg" class="shadow-2 rounded-borders" :title="$t('dashboard.downnotreg')"
bgcolor="bg-grey"
clcolor="text-white"
mystyle=" " myclass="myshad" :canopen="true">
<q-list bordered v-if="!!dashboard.downnotreg" class="rounded-borders">
<div v-for="(user, index) in dashboard.downnotreg" :key="index">
<CUserBadge :yourinvite="true" :user="user" mycolor="grey" :index="index" :numpeople="user.num_invitati"
@myclick="selectclick">
</CUserBadge>
</div>
</q-list>
</CTitleBanner>
</CTitleBanner>
<!--
@@ -60,6 +91,103 @@
</div>
</CTitleBanner>
-->
<CCopyBtn :title="$t('reg.reflink')" :texttocopy="getRefLink">
</CCopyBtn>
<CTitleBanner class="shadow-2 rounded-borders" :title="$t('reg.legenda')"
bgcolor="bg-primary"
clcolor="text-white"
mystyle=" " myclass="myshad" :canopen="true">
<q-list bordered class="rounded-borders row justify-between">
<CLegenda icon="fab fa-telegram" :text="`Telegram ` + $t('pages.statusreg.verified')"></CLegenda>
<CLegenda icon="fas fa-video" :text="$t('pages.statusreg.seezoom')"></CLegenda>
<CLegenda icon="fas fa-user-friends" :text="$t('dashboard.numinvitati')"></CLegenda>
<CLegenda icon="fab fa-whatsapp" :text="$t('dashboard.telefono_wa')"></CLegenda>
</q-list>
</CTitleBanner>
<br>
<q-dialog v-model="showuserinfo">
<q-card v-if="seluser" :style="`min-width: `+ tools.myheight_dialog() + `px;`">
<q-toolbar class="bg-primary text-white">
<q-toolbar-title>
Info:
</q-toolbar-title>
<q-btn flat round color="white" icon="close" v-close-popup></q-btn>
</q-toolbar>
<q-card-section class="inset-shadow">
<CTitleBanner class="shadow-2 rounded-borders" :title="seluser.name + ` ` + seluser.surname"
bgcolor="bg-primary"
clcolor="text-white"
mystyle=" " myclass="myshad" :canopen="true">
<div v-if="!ismyinvited_notreg(seluser)" class="text-center">
<div v-if="!isextralist(seluser)">
<div v-for="req of arrrequisiti">
<CRequisito :icon="req.icon" :text="$t(req.textlang)" :isok="req.isok(seluser)"
:info="req.info"></CRequisito>
</div>
</div>
<div v-if="ismydownline(seluser)">
<CTitleBanner class="shadow-2 rounded-borders" :title="$t('reg.regala_invitato')"
bgcolor="bg-positive"
clcolor="text-white"
:visible="false"
mystyle=" " myclass="myshad" :canopen="true">
<div class="column q-gutter-sm justify-center text-center">
<q-input
bg-color="lightblue"
v-model="aportador_solidario"
rounded outlined
@blur="$v.aportador_solidario.$touch"
:error="$v.aportador_solidario.$error"
:error-message="errorMsg('aportador_solidario', $v.aportador_solidario)"
maxlength="20"
debounce="1000"
:label="$t('reg.username_regala_invitato')">
<template v-slot:prepend>
<q-icon name="person"/>
</template>
</q-input>
<q-toggle v-model="notifBot" :label="$t('dashboard.sendnotification')"/>
<q-btn class="q-ma-sm" rounded color="positive" text-color="white" icon="fas fa-gift" :label="$t('reg.regala_invitato')"
:disabled='!allowSubmit'
@click="RegalaInvitato(seluser, aportador_solidario, getnotifBotTxt)"></q-btn>
</div>
</CTitleBanner>
</div>
</div>
<div v-else>
<div class="column justify-center q-gutter-sm q-pa-sm">
<CRequisito icon="fas fa-user" text="dashboard.notreg" :isok="false"
info=""></CRequisito>
<q-btn rounded text-color="red" icon="delete" :label="$t('reg.cancella_invitato')"
@click="deleteUserFromExtraList(seluser)"></q-btn>
</div>
</div>
</CTitleBanner>
</q-card-section>
</q-card>
</q-dialog>
</div>
</template>