creation/affichage operation commerciale OK creation du component carte de parrainage

thierry
Tmadkaud 7 years ago
parent 895ceea448
commit a9bba41625

@ -4,8 +4,8 @@
</div>
</div>
<ul *ngFor="let op of opCommData | async">
<li>Operation Commerciale: {{op.name}}</li>
<ul>
<li *ngFor="let op of opCommData | async">Operation Commerciale: {{op.name}}</li>
</ul>
<button (click)="goToCreaOpCom()">Nouvelle opération Commercial</button>
<button (click)="goToProfil()">Back</button>

@ -38,7 +38,6 @@ export class ProfilComponent implements OnInit, OnDestroy {
this.user = afAuth.authState;
this.user.subscribe(
(auth) => {
if (auth) {

@ -136,6 +136,5 @@
</div>
</div>
<!--Fin Si cest un commercant-->
</div>
</div>

@ -30,6 +30,7 @@ export class RegisterComponent implements OnInit, OnDestroy {
register() {
if (this.currentUser.status === 'Parrain') {
this.parrain.status = this.currentUser.status;
this.parrain.secretCode = this.getRandomArbitrary(1111, 9999).toString();
this.authService.signUp(this.parrain);
}else if (this.currentUser.status === 'Commercant') {
this.commercant.status = this.currentUser.status;
@ -37,6 +38,12 @@ export class RegisterComponent implements OnInit, OnDestroy {
}
}
// On renvoie un nombre aléatoire entre une valeur min (incluse)
// et une valeur max (exclue)
getRandomArbitrary(min, max) {
return Math.trunc(Math.random() * (max - min) + min);
}
loadHomeComponent() {
this.router.navigate(['/']);
}

@ -29,9 +29,19 @@ export class OpCommercialService {
this.databaseRef = firebase.database().ref();
}
saveOpComm(user: firebase.User, infoOpComm: OperationCommerciale) {
saveOpComm(user: firebase.User, infoOpCom: OperationCommerciale) {
infoOpCom.uid = firebase.database().ref().child('OperationCommercial').push().key;
// Write the new post's data simultaneously in the opCom list and the commercant's opComm list.
let updates = {};
updates['/OperationCommercial/' + infoOpCom.uid] = infoOpCom;
// updates['/commercial-opComs/' + user.uid + '/' + infoOpCom.uid] = infoOpCom;
firebase.database().ref().update(updates);
/*
const userRef = this.databaseRef.child('OperationCommercial').child(user.uid);
userRef.set(infoOpComm);
userRef.set(infoOpCom);
*/
}
}

Loading…
Cancel
Save