import { Component, inject, OnInit } from '@angular/core';
import { WriterService } from '../services/writer.service';
import { Writer } from '../models/writer';
import { DatePipe } from '@angular/common';

@Component({
  selector: 'app-writers',
  standalone: true,
  imports: [DatePipe],
  templateUrl: './writers.component.html',
  styleUrl: './writers.component.css'
})
export class WritersComponent implements OnInit {

  private writerService = inject(WriterService)

  ngOnInit(): void {
    this.allWriters = this.writerService.getAllWriters()
  }

  allWriters: Writer[] = []

  writerImage = "img/writerImage.png"

  sortByAwards(){
    this.allWriters = this.writerService.sortByAwards()
  }

  sortByBirthday(){
    this.allWriters = this.writerService.sortByBirthday()
  }
}
