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

@Component({
  selector: 'jumbotron',
  templateUrl: './jumbotron.component.html',
  styleUrls: ['./jumbotron.component.scss']
})
export class JumbotronComponent {

  constructor(
    private pagesService: PagesService,
  ){}

  get currentPage(){
    return this.pagesService.currentPage
  }

  get name(){
    return this.currentPage?.h1
  }

  get back(){
    let pictURL = this.currentPage?.picture?.data.links.open;
    return {'background-image' : `url(${pictURL})`||'none'}
  }

  get editable(){
    return this.currentPage?.permissions?.edit || this.currentPage?.permissions?.anything;
  }

  get editMode(){
    return this.pagesService.editMode.value
  }

  toggleEditMode(){
    this.pagesService.editMode.next(!this.editMode)
  }

}
