admin opcom en cour
parent
430ccbaf66
commit
b1f13cedb0
@ -1,15 +1,67 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { OperationCommerciale } from '../../../../models/OperationCommerciale';
|
||||
import { AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2/database';
|
||||
|
||||
import * as firebase from 'firebase/app';
|
||||
import { AngularFireAuth } from 'angularfire2/auth';
|
||||
import { AuthService } from '../../../services/auth/auth.service';
|
||||
import { OpCommercialService } from '../../../services/opCommercial/op-commercial.service';
|
||||
import { Commercant } from '../../../../models/Commercant';
|
||||
|
||||
@Component({
|
||||
selector: 'app-demande-op-commercial',
|
||||
templateUrl: './demande-op-commercial.component.html',
|
||||
styleUrls: ['./demande-op-commercial.component.scss']
|
||||
styleUrls: ['./demande-op-commercial.component.scss'],
|
||||
providers: [AuthService, OpCommercialService]
|
||||
})
|
||||
export class DemandeOpCommercialComponent implements OnInit {
|
||||
export class DemandeOpCommercialComponent implements OnInit, OnDestroy {
|
||||
opComm: OperationCommerciale;
|
||||
user: Observable<firebase.User>;
|
||||
opCommData: FirebaseListObservable<any[]>;
|
||||
profileData: FirebaseListObservable<any[]>;
|
||||
commercant: Commercant;
|
||||
|
||||
constructor() { }
|
||||
constructor(public afAuth: AngularFireAuth, public afDb: AngularFireDatabase,
|
||||
private router: Router, private authService: AuthService, private opComService: OpCommercialService) {
|
||||
this.opComm = new OperationCommerciale();
|
||||
|
||||
this.user = afAuth.authState;
|
||||
this.commercant = new Commercant();
|
||||
this.user.subscribe(
|
||||
(auth) => {
|
||||
// console.log("afAuth.authState : " + auth.toJSON());
|
||||
if (auth) {
|
||||
this.opCommData = this.afDb.list('/OperationCommercial/',{
|
||||
query: {
|
||||
orderByChild: 'validationXJC',
|
||||
equalTo: 'En Cours'
|
||||
}
|
||||
}).map((array) => array.reverse()) as FirebaseListObservable<any[]>;
|
||||
}
|
||||
console.log(auth.uid);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
try {
|
||||
this.user.subscribe(
|
||||
(auth) => {
|
||||
if (auth) {
|
||||
console.log(auth.uid);
|
||||
} else {
|
||||
// this.router.navigate(['/']);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
// No content response..
|
||||
console.log(e);
|
||||
// this.router.navigate(['/']);
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue