import { Component, EventEmitter, Input, Output } from '@angular/core';
import {AsyncPipe, CommonModule, NgOptimizedImage} from "@angular/common";
import { RouterLink } from "@angular/router";
import {ApiService} from "../../shared/services/api.service";

@Component({
  selector: 'app-origin',
  standalone: true,
  imports: [
    NgOptimizedImage,
    RouterLink,

    AsyncPipe,
    CommonModule
  ],
  templateUrl: './origin.component.html',
  styleUrl: './origin.component.scss'
})
export class OriginComponent {
  @Input() tab: 'info' | 'origin' | 'timeline' = 'info';
  @Output() tabChange = new EventEmitter<'info' | 'origin' | 'timeline'>();
  data$ = this.api$.data$;
  constructor(private api$: ApiService) {}

  getAddress(item: any): string{
    if (item){
      return [item.address, item.ward, item.district, item.city].filter(Boolean).join(", ");
    }
    return 'không xác định';
  }
}
