import { Component, OnInit } from '@angular/core';
import * as firebase from 'firebase/app';
import { AngularFireAuth } from 'angularfire2/auth';
import { Router } from '@angular/router';
import { HomeService } from '../../services/home/home.service';
import { OpCommercialService } from '../../services/opCommercial/op-commercial.service';
import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss'],
  providers: [HomeService, OpCommercialService]
})
export class HomeComponent implements OnInit {
  public loadComponentRegister = false;
  public loadComponentLogin = false;
  commList: FirebaseListObservable<any[]>;
  constructor(public afAuth: AngularFireAuth, private opComService: OpCommercialService, private router: Router) {
    try{
      opComService.updateCarteEtOpCom();
      this.commList = this.opComService.getCommercants();
      this.commList.subscribe(tabCommercant => console.log(''));
    }catch (e){
      console.log(e);
    }
  }

  loadRegisterComponent(){
    this.loadComponentRegister = !this.loadComponentRegister;
    this.loadComponentLogin = false;
  }

  loadRegisterComponent2(){
    this.loadComponentRegister = true;
    this.loadComponentLogin = false;
  }


  loadLoginComponent(){
    this.loadComponentLogin = !this.loadComponentLogin;
    this.loadComponentRegister = false;
  }

  ngOnInit() {
    firebase.auth().signOut();
  }


}
