import {Component, Input} from '@angular/core';

@Component({
  selector: 'document-section',
  templateUrl: 'document-section.component.html',
  styleUrls: ['document-section.component.scss']
})
export class DocumentSectionComponent {
  @Input() section: any;

  constructor(
  ) {
  }

  ngOnInit() {
    // console.log(this.section);
  }

  get title(){
    return this.section.groups.data[0].fields.data[1].title;
  }

  get name(){
    return this.section.groups.data[0].fields.data[1].value.data[0];
  }

  get description(){
    return this.section.groups.data[0].fields.data[2].value.data[0];
  }

  get docIcon(){
    const ext = this.section.groups.data[0].fields.data[0].value.data[0].extension; 
    return DOC_TYPES_ICONS[ext]||'Unknown_file_24'
    // return `url('/assets/images/icons/document/document_pdf_60dp.svg')`
  }

  get download(){
    return this.section.groups.data[0].fields.data[0].value.data[0].links.download;
  }
}

const DOC_TYPES_ICONS = {
  pdf: 'PDF_24',
}
