import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class FavoritesService {
  addToFavorites(newItem: { title: string; description: string; imageUrl: string; }) {
    throw new Error('Method not implemented.');
  }
  private favoriteItems = [
    {
      title: '商品1',
      description: '这是商品1的描述',
      imageUrl: 'assets/images/product1.jpg'
    },
    {
      title: '商品2',
      description: '这是商品2的描述',
      imageUrl: 'assets/images/product2.jpg'
    },
    {
        title: '商品2',
        description: '这是商品2的描述',
        imageUrl: 'assets/images/product2.jpg'
      },
      {
        title: '商品2',
        description: '这是商品2的描述',
        imageUrl: 'assets/images/product2.jpg'
      },
      {
        title: '商品2',
        description: '这是商品2的描述',
        imageUrl: 'assets/images/product2.jpg'
      },
      {
        title: '商品2',
        description: '这是商品2的描述',
        imageUrl: 'assets/images/product2.jpg'
      },
      {
        title: '商品2',
        description: '这是商品2的描述',
        imageUrl: 'assets/images/product2.jpg'
      },
  ];

  getFavoriteItems() {
    return this.favoriteItems;
  }

  removeFromFavorites(item: { title: string; description: string; imageUrl: string; }) {
    const index = this.favoriteItems.indexOf(item);
    if (index > -1) {
      this.favoriteItems.splice(index, 1);
    }
  }
}