import { Component, Input, Output, EventEmitter } from '@angular/core';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { faTrashAlt } from '@fortawesome/free-solid-svg-icons';

@Component({
  selector: 'app-cart-item', // 修正选择器名称
  standalone: true,
  imports: [FontAwesomeModule], // 添加 FontAwesomeModule 导入
  templateUrl: './cart-item.component.html',
  styleUrls: ['./cart-item.component.scss']
})
export class CartItemComponent {
  @Input() item: any; // 添加 item 输入属性
  @Output() quantityChange = new EventEmitter<number>();
  @Output() remove = new EventEmitter<void>();

  faTrashAlt = faTrashAlt; // 添加图标定义

  updateQuantity(change: number): void {
    this.quantityChange.emit(change);
  }

  removeItem(): void {
    this.remove.emit();
  }
}