import { Component, OnInit } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { CommonModule } from '@angular/common';
import { Router } from '@angular/router';

@Component({
  selector: 'app-view-all',
  templateUrl: './view-all.component.html',
  styleUrls: ['./view-all.component.scss'],
  standalone: true,
  imports: [IonicModule, CommonModule],
})
export class ViewAllComponent implements OnInit {
  recentBooks = [
    {
      id: '1',
      title: '城南旧事',
      author: '林海音',
      image: '../../assets/img/book1.png',
      progress: 35,
      description: '《城南旧事》是林海音创作的一部自传体小说集，以一个小女孩的视角讲述了在北京城南的生活往事。',
      lastRead: '2024-12-15'
    },
    {
      id: '2',
      title: '朝花夕拾',
      author: '鲁迅',
      image: '../../assets/img/book2.png',
      progress: 68,
      description: '《朝花夕拾》是鲁迅创作的一部回忆性散文集，记录了作者的童年往事和对社会的思考。',
      lastRead: '2024-12-14'
    },
    {
      id: '3',
      title: '狂人日记',
      author: '鲁迅',
      image: '../../assets/img/book3.png',
      progress: 42,
      description: '《狂人日记》是中国现代文学史上第一篇白话小说，以独特的视角揭示了封建社会的吃人本质。',
      lastRead: '2024-12-13'
    },
    {
      id: '4',
      title: '彷徨',
      author: '鲁迅',
      image: '../../assets/img/book4.png',
      progress: 25,
      description: '《彷徨》是鲁迅创作的第二部小说集，收录了多篇反映社会现实的优秀作品。',
      lastRead: '2024-12-12'
    }
  ];

  constructor(private router: Router) { }

  ngOnInit() { }

  goToBookDetail(bookId: string) {
    this.router.navigate(['/tabs/book-detail', bookId]);
  }

  formatProgress(progress: number): string {
    return `${progress}%`;
  }
}
