import {Component} from '@angular/core';
import {PagesService} from "@app/_services/pages.service";
import { FormsService } from '@app/_services';

@Component({
  selector: 'administrate-site-pages',
  templateUrl: 'administrate-site-pages.component.html',
  styleUrls: ['administrate-site-pages.component.scss']
})
export class AdministrateSitePagesComponent {
  constructor(
    private pagesService: PagesService,
    private formsService: FormsService,
  ) {}

  public mainPage:any;

  ngOnInit() {
    this.fetchRootPage();
  }

  fetchRootPage() {
    let include = ['children.children','parent.children'];
    this.pagesService.root({include: include}).subscribe(res => {
      this.mainPage = res.data[0].parent?.data;
    });
  }

  addLocale(){
    this.formsService.createModel('page', null, null);
  }

}
