import { AuthServiceService } from './../../shared/auth-service.service';
import { ExternalPageService } from './../../shared/external-page.service';
import { Component, OnInit } from '@angular/core';
import { NgxSpinnerService } from 'ngx-spinner';

@Component({
  selector: 'app-external-contact-us',
  templateUrl: './external-contact-us.component.html',
  styleUrls: ['./external-contact-us.component.css']
})
export class ExternalContactUsComponent implements OnInit {

  constructor(private externalService: ExternalPageService, 
    private spinner: NgxSpinnerService,
    private authSer:AuthServiceService) { 
      this.spinner.show();
    }
  
  contactUs = [];

  ngOnInit() {

    this.authSer.homeActivate = false;
    //add active class in contact us menu header "active = 1"
    this.externalService.getHeader().subscribe(
      (responce) => {
        this.externalService.headerMenus = responce['parents'];
        for(let i = 0; i < this.externalService.headerMenus.length; i++) {
          if(this.externalService.headerMenus[i].id == 23) {
            this.externalService.headerMenus[i].active = 1;
          } else {
            this.externalService.headerMenus[i].active = 0;
          }
        }
      },
      (error) => {
        console.log(error);
      }
    );

    this.externalService.getContactUs().subscribe(
      (responce) => {
        console.log(responce);
        this.contactUs = responce['contact_us'];
        console.log('contact uus', this.contactUs);
        this.spinner.hide();
      },
      (error) => {
        console.log(error);
      }
    )
  }

}
