import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { Meta, Title } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
declare let $: any;
@Component({
  selector: 'app-faq',
  templateUrl: './faq.component.html',
  styleUrls: ['./faq.component.scss']
})
export class FaqComponent implements OnInit {
  public isShow: boolean = true;
  public faqs = [
    {
      que: "What kind of financial consultancy you need?",
      ans: "You can generally seek a first time home loan for buying a house or a flat, renovation,extension and repairs to your existing house. Most banks have a separate policy for those who are going for a second house. Please remember to seek specific clarificationson the above-mentioned issues from your commercial bank. ",
      isCollapsed: false
    },
    {
      que: "How we help you for your business?",
      ans: "You can generally seek a first time home loan for buying a house or a flat, renovation, extension and repairs to your existing house. Most banks have a separate policy for those who are going for a second house. Please remember to seek specific clarificationson the above-mentioned issues from your commercial bank. ",
      isCollapsed: true
    },
    {
      que: "What is Firewall and why it is used?",
      ans: "You can generally seek a first time home loan for buying a house or a flat, renovation, extension and repairs to your existing house. Most banks have a separate policy forthose who are going for a second house. Please remember to seek specific clarificationson the above-mentioned issues from your commercial bank.",
      isCollapsed: true
    },
  ];
  public city: string = "";

  constructor(
    private meta: Meta,
    private title: Title,
    private route: ActivatedRoute,
    @Inject(PLATFORM_ID) public platformId: object
  ) {
    let city;
    if (isPlatformBrowser(this.platformId))
      city = sessionStorage.getItem("selectedCity");
    if (city) {
      this.city = city;
      // } else {
      //   this.city = "surat"
    }
    this.title.setTitle(this.route.snapshot.data['title']);
  }

  ngOnInit(): void {
    setTimeout(() => {
      this.isShow = false;
    }, 1000);
    this.setStep(0, 'initial')
  }

  public setStep(n: any, initial?: string) {
    if (initial) {
      this.faqs[0].isCollapsed = false;
    }
    else {
      if (this.faqs[n].isCollapsed == false) {
        this.faqs[n].isCollapsed = true;
      }
      else {
        for (let index = 0; index < this.faqs.length; index++) {
          if (this.faqs[index].isCollapsed == false) {
            this.faqs[index].isCollapsed = true;
          }
        }
        this.faqs[n].isCollapsed = false;
      }
    }
  }
}
