|
|
|
@ -60,6 +60,9 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
yearTest: number;
|
|
|
|
|
|
|
|
|
|
minDateTimeTest: Date;
|
|
|
|
|
maxDateTimeTest: Date;
|
|
|
|
|
parrainDateTimeTest: Date;
|
|
|
|
|
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
|
|
|
|
|
private router: Router, private route: ActivatedRoute,
|
|
|
|
|
private authService: AuthService, private opComService: OpCommercialService) {
|
|
|
|
@ -73,7 +76,9 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
|
|
|
|
|
this.commercant = new Commercant();
|
|
|
|
|
this.cartePar = new CarteParrainage();
|
|
|
|
|
this.parrainAffList = null;
|
|
|
|
|
|
|
|
|
|
this.minDateTimeTest = new Date('1917-01-01');
|
|
|
|
|
this.maxDateTimeTest = new Date('2117-01-01');
|
|
|
|
|
this.parrainDateTimeTest = new Date(this.parrain.birthday);
|
|
|
|
|
this.yearTest = this.parrain.birthday.getFullYear();
|
|
|
|
|
this.databaseRef = firebase.database().ref();
|
|
|
|
|
this.user.subscribe(
|
|
|
|
@ -112,6 +117,13 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
|
|
|
|
|
this.cartePar.dateDebut = this.opComm.dateDebut;
|
|
|
|
|
this.cartePar.dateFin = this.opComm.dateFin;
|
|
|
|
|
|
|
|
|
|
console.log('bla' + this.minDateTimeTest);
|
|
|
|
|
console.log('bla' + this.maxDateTimeTest);
|
|
|
|
|
console.log('bla' + this.minDateTimeTest.getTime());
|
|
|
|
|
console.log('bla' + this.maxDateTimeTest.getTime());
|
|
|
|
|
|
|
|
|
|
console.log('bla' + this.parrainDateTimeTest);
|
|
|
|
|
console.log('bla' + this.parrainDateTimeTest.getTime());
|
|
|
|
|
|
|
|
|
|
var todayTemp = new Date(Date.now());
|
|
|
|
|
var debutTemp = new Date(this.opComm.dateDebut);
|
|
|
|
@ -186,10 +198,20 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
//////
|
|
|
|
|
|
|
|
|
|
validationBirthday(){
|
|
|
|
|
this.parrainDateTimeTest = new Date(this.parrain.birthday);
|
|
|
|
|
if (this.parrainDateTimeTest.getTime() <= this.minDateTimeTest.getTime()
|
|
|
|
|
|| this.parrainDateTimeTest.getTime() >= this.maxDateTimeTest.getTime()) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
registerNewParrain() {
|
|
|
|
|
|
|
|
|
|
this.parrain.status = 'Parrain';
|
|
|
|
|
|
|
|
|
|
this.parrain.birthday = this.parrainDateTimeTest;
|
|
|
|
|
this.parrain.secretCode = this.getRandomArbitrary(1111, 9999).toString();
|
|
|
|
|
this.parrain.password = this.getRandomArbitrary(111111, 999999).toString();
|
|
|
|
|
// this.authService.signUp(this.parrain);
|
|
|
|
@ -224,10 +246,12 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
|
|
|
|
|
firebase.auth().signOut();
|
|
|
|
|
firebase.auth().signInWithEmailAndPassword(this.commercant.email, this.commercant.password);
|
|
|
|
|
console.log('avant logout firebase.auth().currentUser.uid: '+ firebase.auth().currentUser.uid);
|
|
|
|
|
this.goToOpComm();
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// No content response..
|
|
|
|
|
console.log('error dans envoyer carte !')
|
|
|
|
|
console.log(e);
|
|
|
|
|
this.goToOpComm();
|
|
|
|
|
// this.router.navigate(['/']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -298,7 +322,10 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
|
|
|
|
|
console.log('this.cartePar.dateFin : ' + this.cartePar.dateFin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
envoyerCartePar(){
|
|
|
|
|
this.creerCartePar();
|
|
|
|
|
this.goToOpComm();
|
|
|
|
|
}
|
|
|
|
|
creerCartePar() {
|
|
|
|
|
// this.opComService.creerCartePar(this.cartePar); inutile
|
|
|
|
|
this.sectionToImage(this.cartePar);
|
|
|
|
|