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

@Component({
  selector: 'app-portal-banner-content-select',
  template: `
    <div class="text-danger">{{data?.link}}</div>
    <nz-tabset>
      <nz-tab nzTitle="栏目"><select-column [productId]="productId" (itemClick)="onItemClick('column', $event)"></select-column></nz-tab>
      <nz-tab nzTitle="专辑"><select-album [productId]="productId" (itemClick)="onItemClick('album', $event)"></select-album></nz-tab>
      <nz-tab nzTitle="收集"><select-collection [productId]="productId" (itemClick)="onItemClick('collection', $event)"></select-collection></nz-tab>
    </nz-tabset>
  `,
  styles: [`
  `
  ]
})
export class PortalHeaderContentSelectComponent implements OnInit {

  @Input() productId: string;

  data: any;
  
  constructor() { }

  ngOnInit(): void {
    console.log(this.productId)
  }

  onItemClick(type, item) {
    if (!item) {
      this.data = null;
      return;
    }
    if (type == 'album') {
      this.data = { 
        title: item.title, 
        link: `art://inapp?type=album&id=${item._id}` 
      };
    } else if (type == 'collection') {
      this.data = { 
        title: item.title, 
        link: `art://inapp?type=collection&id=${item._id}`
      };
    } else if (type == 'column') {
      this.data = { 
        title: { _id: item.translate, zh: item.zh, en: item.en },
        link: `art://inapp?type=column&id=${item.id}`
      };
    }
  }



}
