import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';

interface Item {
  imgUrl: string;
  name: string;
  description: string;
}

@Component({
  selector: 'app-page-item-detail',
  templateUrl: './page-item-detail.component.html',
  styleUrls: ['./page-item-detail.component.scss']
})
export class PageItemDetailComponent implements OnInit {
  selectedItem: Item | null = null;

  constructor(private router: Router, private route: ActivatedRoute) { }

  ngOnInit() {
    const selectedItemString = localStorage.getItem('selectedItem');
    if (selectedItemString) {
      this.selectedItem = JSON.parse(selectedItemString);
    } else {
      // 如果没有选定的项目，导航回首页
      this.router.navigate(['/home']);
    }
  }

  backIconClicked() {
    this.router.navigate(['/home']);
  }
}
