import { Component, OnInit } from '@angular/core';
import { HelpService } from '../services/help.service';
import { LoadingController } from '@ionic/angular';
import { AlertController } from '@ionic/angular';
import { ToastService } from '../services/toast.service';


@Component({
    selector: 'app-faq',
    templateUrl: './faq.component.html',
    styleUrls: ['./faq.component.scss'],
})
export class FaqComponent implements OnInit {

    allFaqs: any = [];
    loader: any;
    selectedQuestions: number = 0;


    constructor(
        private helpService: HelpService,
        public loadingController: LoadingController,
        public alertController: AlertController,
    ) { }

    ngOnInit() { 
        this.getAllfaqs()
    }

    async presentLoading() {
        this.loader = await this.loadingController.create({
            message: 'Please wait...',
            spinner: 'dots',
            mode: 'ios'
        });
        await this.loader.present();
    }

    async presentAlert(message: string) {
        const alert = await this.alertController.create({
            message: message,
            mode: 'ios',
            buttons: ['OK']
        });

        await alert.present();
    }


    getAllfaqs() {
        this.helpService.mallFaqs().then((response) => {
            this.allFaqs = response;
            this.loader ? this.loader.dismiss() : null;
        }, (error) => {
            this.loader ? this.loader.dismiss() : null
            console.log(error);
        });
    }

}
