import { Component , inject, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { OrderService } from '../services/order.service';

@Component({
  selector: 'app-ordersummarypage',
  imports: [],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  templateUrl: './ordersummarypage.html',
  styleUrl: './ordersummarypage.scss',
})
export class Ordersummarypage {

  orderService = inject(OrderService);

  get totalPrice() {
    const order = this.orderService.getOrder();
    return (order.product?.basePrice ?? 0) + (order.config?.priceDelta ?? 0);
  }

  get saladAmount(): number {
    const order = this.orderService.getOrder();
    switch (order.config?.saladAmount) {
      case 'less':
        return 1;
      case 'normal':
        return 2;
      case 'much':
        return 3;
    }
    return 2;
  }
  
  get order() {
    const order = this.orderService.getOrder();

    const basePrice = order.product?.basePrice ?? 0;
    return order;
  }
}
