import { JalaliDateDirective } from '@/shared/directives';
import { Component, inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import images from 'src/assets/images';
import { PosOrderCardComponent } from '../components/order/order-card.component';
import { PosProductsComponent } from '../components/products/products.component';
import { POSStore, POS_ID } from '../store';

@Component({
  selector: 'app-pos',
  templateUrl: './pos.component.html',
  imports: [JalaliDateDirective, PosProductsComponent, PosOrderCardComponent],
  providers: [
    {
      provide: POS_ID,
      useFactory: (route: ActivatedRoute) => Number(route.snapshot.params['posId']),
      deps: [ActivatedRoute],
    },
    POSStore,
  ],
})
export class POSComponent {
  private readonly store = inject(POSStore);

  placeholderLogo = images.placeholders.logo;

  now = new Date();

  info = this.store.info;
  infoLoading = this.store.getInfoLoading;

  // getInfo() {
  //   this.infoLoading.set(true);
  //   this.service.getInfo(Number(this.posId)).subscribe({
  //     next: (res) => {
  //       this.info.set(res);
  //       this.infoLoading.set(false);
  //     },
  //     error: () => {
  //       this.infoLoading.set(false);
  //     },
  //   });
  // }
}
