import { Component, OnInit } from "@angular/core";
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { FaqService } from "src/app/cores/api-services/manage/faq.service";
import { SurveyorService } from "src/app/cores/api-services/manage/surveyor.service";
import { UserService } from "src/app/cores/api-services/manage/user.service";

@Component({
  selector: "app-setting",
  templateUrl: "./setting.component.html",
  styleUrls: ["./setting.component.scss"],
})
export class SettingComponent implements OnInit {
  active: any;

  dataLengthFaq: number = 0;
  dataLengthPengelola: number = 0;
  dataLengthSurveyor: number = 0;

  constructor(
    public modal: NgbModal,
    public apiFaq: FaqService,
    public apiUser: UserService
  ) {}

  queries = {
    filter: { urole_id: { eq: "1038dcc0-3bb0-4253-87fa-ef0e09a4429d" } },
    limit: 10,
  };

  ngOnInit(): void {
    this.apiFaq.getAll().subscribe({
      next: ({ data }) => {
        this.dataLengthFaq = data.length;
      },
    });
    this.apiUser.getAll(this.queries).subscribe({
      next: ({ data }) => {
        this.dataLengthPengelola = data.length;
      },
    });
    this.apiUser
      .getAll({
        filter: { urole_id: { eq: "1b4701ab-da41-405b-9fe3-039a4daf0094" } },
        limit: 10,
      })
      .subscribe({
        next: ({ data }) => {
          this.dataLengthSurveyor = data.length;
        },
      });
  }
}
