import { PriceMaskDirective } from '@/shared/directives';
import { enumTranslator } from '@/utils';
import { ChangeDetectionStrategy, Component, inject, Input, signal } from '@angular/core';
import { ButtonDirective } from 'primeng/button';
import images from 'src/assets/images';
import { IPosInOrderGood } from '../../models';
import { PosLandingStore } from '../../store/main.store';
import { PayloadFormDialogComponent } from '../payload-form.component';

@Component({
  selector: 'pos-order-card-template',
  templateUrl: './order-card-template.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [ButtonDirective, PayloadFormDialogComponent, PriceMaskDirective],
})
export class OrderCardTemplateComponent {
  @Input({ required: true }) inOrderGood!: IPosInOrderGood;

  private readonly store = inject(PosLandingStore);

  visible = signal(false);

  placeholderImage = images.placeholders.default;
  enumTranslator = (key: string) => enumTranslator(key);

  removeGoodFromOrder() {
    this.store.removeFromInOrderGoods(this.inOrderGood.id);
  }

  editOrderItem() {
    this.visible.set(true);
  }
}
