import {
  Component,
  ChangeDetectionStrategy,
  OnDestroy,
  inject,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { TabService } from '@isa/core/tabs';
import { map } from 'rxjs/operators';

@Component({
  selector: 'page-customer',
  templateUrl: 'customer-page.component.html',
  styleUrls: ['customer-page.component.css'],
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: false,
})
export class CustomerComponent implements OnDestroy {
  private _tabService = inject(TabService);
  processId$ = this._activatedRoute.data.pipe(map((data) => data.processId));

  constructor(private _activatedRoute: ActivatedRoute) {}

  ngOnDestroy() {
    const tab = this._tabService.activatedTab();
    // #5512 Always clear preserved select-customer context if navigating out of customer area
    this._tabService.patchTabMetadata(tab.id, {
      'select-customer': null,
    });
  }
}
