creer parrain avec commercant ok

thierry
Tmadkaud 7 years ago
parent f2d4e53bfb
commit d91648bc22

@ -31,7 +31,7 @@
</div>
<div class="text-center" style="margin-top:5%">
<button class="btn btn-light-green waves-light" (click)="creerOpComm()">Creer opération</button>
<button class="btn btn-light-green waves-light" [disabled]="(opComm.name === '') || (opComm.avantageParrain === '') || (opComm.avantageFilleul === '')" (click)="creerOpComm()">Creer opération</button>
<button class="btn btn-cyan" (click)="goToOpComm()">Back</button>
</div>
</div>

@ -59,7 +59,7 @@ export class CreationOpComComponent implements OnInit, OnDestroy {
utilisateur.forEach(element => {
console.log('element.uid: ' + element.uid);
this.opComm.idCommercant = element.uid;
this.opComm.status = "Non active";
this.opComm.status = 'Non active';
// let file = this.selectedFiles.item(0);
// this.opComm.carteTemplate = file;
// this.upload();

@ -45,6 +45,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
parSelect: string;
selectPar: boolean;
parrainAffListTemp = [];
databaseRef: any;
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
private router: Router, private authService: AuthService,
@ -60,7 +61,7 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
this.cartePar = new CarteParrainage();
this.parrainAffList = null;
this.user = afAuth.authState;
this.databaseRef = firebase.database().ref();
this.user.subscribe(
(auth) => {
if (auth) {
@ -148,27 +149,31 @@ export class EnvoyerCarteComponent implements OnInit, OnDestroy {
);
}
registerNewParrain() {
/*
this.parrain.status = 'Parrain';
this.parrain.secretCode = this.getRandomArbitrary(1111, 9999).toString();
this.parrain.password = this.getRandomArbitrary(111111, 999999).toString();
// this.authService.signUp(this.parrain);
firebase.auth().createUserWithEmailAndPassword(this.parrain.email, this.parrain.password).then(userCreate => {
this.cartePar.parrainID = userCreate.uid;
this.authService.setUserInfo(userCreate, this.parrain);
// this.authService.signIn(this.commercant.email, this.commercant.password);
firebase.auth().signInWithEmailAndPassword(this.commercant.email, this.commercant.password).then(user => {
if (user) {
console.log('salut le ' + user.displayName + ' ' + user.email + ' has signed!');
user.displayName = this.commercant.status;
}else {
console.log('error!!');
}
const imagePath = 'profilImage/' + userCreate.uid + '/userPic.jpg';
const userRef = this.databaseRef.child('Parrain').child(userCreate.uid);
userCreate.updateProfile({
displayName: this.parrain.status,
photoURL: imagePath
});
this.cartePar.parrainID = userCreate.uid;
this.parrain.uid = userCreate.uid;
userRef.set(this.parrain);
this.creerCartePar();
firebase.auth().signOut();
firebase.auth().signInWithEmailAndPassword(this.commercant.email, this.commercant.password);
});
*/
}
getRandomArbitrary(min, max) {
return Math.trunc(Math.random() * (max - min) + min);

@ -35,7 +35,7 @@ export class OpCommercialComponent implements OnInit, OnDestroy {
this.commercant = new Commercant();
this.user.subscribe(
(auth) => {
console.log("afAuth.authState : " + auth.toJSON());
// console.log("afAuth.authState : " + auth.toJSON());
if (auth) {
this.opCommData = this.afDb.list('/OperationCommercial/', {
query: {

@ -32,7 +32,7 @@
<h4 class="card-title"><p>Salut {{localUser.firstname}} {{localUser.familyname}} {{localUser.uid}} </p></h4>
<hr>
<ul>
<p class="text-left "><label class="text-uppercase">status </label>: {{localUser.status}}</p>
<p class="text-left"><label class="text-uppercase">status </label>: {{localUser.status}}</p>
<p class="text-left"><label class="text-uppercase">email </label>: {{localUser.email}}</p>
<p class="text-left"><label class="text-uppercase">emailVerified </label>: {{localUser.emailVerified}}</p>
<p class="text-left"><label class="text-uppercase">familyname </label>: {{localUser.familyname}}</p>
@ -41,7 +41,7 @@
<p class="text-left"><label class="text-uppercase">birthday </label> : {{localUser.birthday}}</p>
<p class="text-left"><label class="text-uppercase"> telephone :</label> {{localUser.telephone}}</p>
<p class="text-left"><label class="text-uppercase"> idCard </label>: {{localUser.idCard}}</p>
<p class="text-left"><label class="text-uppercase">secretCode </label> : {{localUser.secretCode}}</p>
<p class="text-left"><label class="text-uppase">secretCode </label> : {{localUser.secretCode}}</p>
</ul>
</div>

@ -52,7 +52,6 @@ export class ProfilComponent implements OnInit, OnDestroy {
);
this.profileData.forEach(utilisateur => {
utilisateur.forEach(element => {
console.log('blabla : ' + auth.displayName);
if (auth.displayName === 'Parrain') {
this.localUser = new Parrain();

@ -39,12 +39,14 @@ export class AuthService {
infoUser.uid = user.uid;
userRef.set(infoUser);
this.upload(infoUser);
//this.router.navigate(['/carteParrainageComponent']);
}else if (infoUser.status === 'Commercant') {
const userReff = this.databaseRef.child('Commercant').child(user.uid);
// var commercantInfo = infoUser;
infoUser.uid = user.uid;
userReff.set(infoUser);
this.upload(infoUser);
//this.router.navigate(['/opCommercial']);
}
}
@ -66,7 +68,7 @@ export class AuthService {
}
setUserInfo(user: firebase.User, infoUser: any) {
const imagePath = 'profilImage/!' + user.uid + '/userPic.jpg';
const imagePath = 'profilImage/' + user.uid + '/userPic.jpg';
firebase.auth().onAuthStateChanged(function (userUpdate) {
userUpdate.updateProfile({
displayName: infoUser.status,

@ -66,29 +66,30 @@ export class OpCommercialService {
let theNameOfFile = 'carteTemplate';
// This currently only grabs item 0, TODO refactor it to grab them all
for (let selectedFile of [(<HTMLInputElement>document.getElementById('orangeForm-File')).files[0]]) {
console.log(selectedFile);
// Make local copies of services because "this" will be clobbered
let router = this.router;
let folder = this.folder;
let path = `${this.folder}`;
let iRef = storageRef.child(path);
iRef.put(selectedFile).then((snapshot) => {
// console.log('Uploaded a blob or file! Now storing the reference at', `/${this.folder}/images/`);
// this.afDb.list(`/${folder}/`).push({ path: path, filename: selectedFile.name });
let updates = {};
info.carteTemplate.path = path;
info.carteTemplate.filename = info.name;
info.carteTemplate.downloadURL = snapshot.downloadURL;
updates[folder] = info.carteTemplate;
firebase.database().ref().update(updates);
});
if ((<HTMLInputElement>document.getElementById('orangeForm-File')) !== null) {
for (let selectedFile of [(<HTMLInputElement>document.getElementById('orangeForm-File')).files[0]]) {
console.log(selectedFile);
// Make local copies of services because "this" will be clobbered
let router = this.router;
let folder = this.folder;
let path = `${this.folder}`;
let iRef = storageRef.child(path);
iRef.put(selectedFile).then((snapshot) => {
// console.log('Uploaded a blob or file! Now storing the reference at', `/${this.folder}/images/`);
// this.afDb.list(`/${folder}/`).push({ path: path, filename: selectedFile.name });
let updates = {};
info.carteTemplate.path = path;
info.carteTemplate.filename = info.name;
info.carteTemplate.downloadURL = snapshot.downloadURL;
updates[folder] = info.carteTemplate;
firebase.database().ref().update(updates);
});
}
}
}
delete(image: Image) {

Loading…
Cancel
Save