import { Component, computed, input } from '@angular/core';
import { PdfViewerModule } from 'ng2-pdf-viewer';
import { environment } from '@env/environment';
import { ProfileViewModel } from '@app/adapters/profiles/profile.presenter.model';

@Component({
  selector: 'app-pdf-viewer',
  standalone: true,
  imports: [PdfViewerModule],
  templateUrl: './pdf-viewer.component.html',
  styleUrl: './pdf-viewer.component.scss',
})
export class PdfViewerComponent {
  profile = input.required<ProfileViewModel>();
  protected readonly environment = environment;
  protected readonly cvUrl = computed(() => {
    const currentProfile = this.profile();

    if (!currentProfile || !currentProfile.cv) {
      return null;
    }

    return currentProfile.cv;
  });

  protected readonly hasCv = computed(() => {
    return this.cvUrl() !== null;
  });
}
