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

@Component({
  selector: 'app-product-management',
  templateUrl: './product-management.component.html',
  styleUrls: ['./product-management.component.scss']
})
export class ProductManagementComponent {
  productList: any[] = [];
  disabled = '';
  active: any;
  get: any;
  delete: any;

  ngOnInit(): void {
    this.productList = [
      { id_product: 101, product_name: 'Laptop', product_amount: 5, category: 'Electronics', status: 'Available', time_date: '2025-03-11 14:30' },
      { id_product: 102, product_name: 'Smartphone', product_amount: 10, category: 'Electronics', status: 'Out of Stock', time_date: '2025-03-10 12:15' },
      { id_product: 103, product_name: 'Desk Chair', product_amount: 3, category: 'Furniture', status: 'Available', time_date: '2025-03-09 09:45' }
    ];
  }




  // constructor(
  //   private http: HttpClient,
  // ) {

  // }
  // ngOnInit(): void {
  //   this.getProduct();
  // }
  // getProduct(): void {
  //   this.http.get(environment.api + "/product").subscribe((result: any) => {
  //     console.log(result);
  //     this.productList = result.data;
  //   }, (error: HttpErrorResponse) => {
  //     alert(error.message);
  //   });
  // }
  // deleteProduct(id: string): void {
  //   this.http.delete(`${environment.api}/product/${id}`).subscribe(
  //     (result: any) => {
  //       console.log(result);
  //       this.getProduct();
  //     },
  //     (error: HttpErrorResponse) => {
  //       alert(error.message);
  //     }
  //   );
  // }

  addToCart(product: any) {
    let cart = localStorage.getItem('cart');
    let cartItems = cart ? JSON.parse(cart) : [];
    cartItems.push(product);
    localStorage.setItem('cart', JSON.stringify(cartItems));
  }
}


