import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Router } from '@angular/router';
import { ApplicationService } from '@core/application';
import { EnvironmentService } from '@core/environment';
import { CheckoutNavigationService, ProductCatalogNavigationService } from '@shared/services/navigation';
import { UiModalRef } from '@ui/modal';

@Component({
  selector: 'added-to-cart-modal',
  templateUrl: 'added-to-cart-modal.component.html',
  styleUrls: ['added-to-cart-modal.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: false,
})
export class AddedToCartModalComponent {
  get isTablet() {
    return this._environment.matchTablet();
  }

  constructor(
    public ref: UiModalRef<any, any>,
    private readonly _router: Router,
    private readonly _applicationService: ApplicationService,
    private readonly _navigation: ProductCatalogNavigationService,
    private readonly _environment: EnvironmentService,
    private readonly _checkoutNavigationService: CheckoutNavigationService,
  ) {}
  async continue() {
    if (this.isTablet) {
      await this._navigation.getArticleSearchBasePath(this._applicationService.activatedProcessId).navigate();
    }
    this.ref.close();
  }

  async toCart() {
    await this._checkoutNavigationService.getCheckoutReviewPath(this._applicationService.activatedProcessId).navigate();
    this.ref.close();
  }
}
