@ -61,8 +61,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
yearTest : number ;
constructor ( public afAuth : AngularFireAuth , public afDb : AngularFireDatabase ,
private router : Router , private authService : AuthService ,
private opComService : OpCommercialService , private route : ActivatedRoute ) {
private router : Router , private route : ActivatedRoute ) {
this . user = afAuth . authState ;
@ -212,13 +211,19 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
userRef . set ( this . parrain ) ;
console . log ( 'crer par: ' + this . parrain . firstname ) ;
// this.cartePar.parrainCarte = this.parrain;
this . getIdParrain ( userCreate . uid ) ;
console . log ( 'creer par userCreate.uid: ' + userCreate . uid ) ;
this . creerCartePar ( ) ;
console . log ( 'creer par creerCartePar: ' + this . cartePar . uid ) ;
firebase . auth ( ) . sendPasswordResetEmail ( this . parrain . email ) ;
userCreate . sendEmailVerification ( ) ;
console . log ( 'avant logout firebase.auth().currentUser.uid: ' + firebase . auth ( ) . currentUser . uid ) ;
firebase . auth ( ) . signOut ( ) ;
firebase . auth ( ) . signInWithEmailAndPassword ( this . commercant . email , this . commercant . password ) ;
console . log ( 'avant logout firebase.auth().currentUser.uid: ' + firebase . auth ( ) . currentUser . uid ) ;
} ) ;
}
@ -230,6 +235,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
}
getIdParrain ( parUid ) {
console . log ( 'parUid getidpar: ' + parUid ) ;
const parlistTemp = this . afDb . list ( '/Parrain/' , {
query : {
orderByChild : 'uid' ,
@ -241,10 +247,11 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
parlistTemp . forEach ( par = > {
par . forEach ( elementParTemp = > {
this . cartePar . parrainCarte = elementParTemp ;
console . log ( 'ttthis.cartePar.parrainCarte.uid: ' + this . cartePar . parrainCarte . uid + this . cartePar . parrainCarte . firstname ) ;
} ) ;
} ) ;
this . selectPar = true ;
console . log ( 'this.cartePar.parrainCarte.uid: ' + this . cartePar . parrainCarte . uid + this . cartePar . parrainCarte . firstname ) ;
if ( this . radioParrain === 'Newparrain' ) {
this . parSelect = ' à : '
@ -285,14 +292,13 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
creerCartePar() {
// this.opComService.creerCartePar(this.cartePar); inutile
this . sectionToImage ( this . cartePar ) ;
console . log ( 'this.opComm.nbEnvoie: ' + this . opComm . nbEnvoie ) ;
this . opComm . nbEnvoie = ( ( + this . opComm . nbEnvoie ) + 1 ) . toString ( ) ;
console . log ( 'this.opComm.nbEnvoie: ' + this . opComm . nbEnvoie ) ;
const opEnvRef = this . databaseRef . child ( 'OperationCommercial' ) . child ( this . opComm . uid . toString ( ) ) . child ( 'nbEnvoie' ) ;
opEnvRef . set ( 'this.opComm.nbEnvoie: ' + this . opComm . nbEnvoie ) ;
opEnvRef . set ( this . opComm . nbEnvoie ) ;
this . validC = 'ok' ;
@ -351,21 +357,6 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
}
//////
ngOnInit() {
try {
this . user . subscribe (
( auth ) = > {
if ( auth ) {
this . subscription = this . opComService . getParrains ( )
. subscribe ( parrains = > this . parrainsTest = parrains ) ;
} else {
this . router . navigate ( [ '/' ] ) ;
}
} ) ;
} catch ( e ) {
// No content response..
console . log ( e ) ;
this . router . navigate ( [ '/' ] ) ;
}
}
//////